home *** CD-ROM | disk | FTP | other *** search
/ Math Solutions 1995 October / Math_Solutions_CD-ROM_Walnut_Creek_October_1995.iso / pc / mac / mathpad2 / examples / solve < prev    next >
Encoding:
Text File  |  1994-06-11  |  399 b   |  24 lines

  1. -- Solution of a system of equations by Cramers rule.
  2. include ":incl:solver"
  3.  
  4. -- example system of equations
  5. -- 2x +  y +  z = 2
  6. --  x -  y + 5z = 4
  7. --       y -  z = 4
  8.  
  9. A={{ 2, 1, 1},  -- coefficients
  10.    { 1,-1, 5},
  11.    { 0, 1,-1}}
  12.  
  13. C= { 2, 4, -4}   -- constants
  14.  
  15. solve(A,C):{4.0,-5.0,-1.0}
  16.  
  17. x=solve(A,C)[1]
  18. y=solve(A,C)[2]
  19. z=solve(A,C)[3]
  20.  
  21. 2*x +  y +   z:2.0
  22.   x -  y + 5*z:4.0
  23.        y -   z:-4.0
  24.