Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford


This notebook solves the 3x3 linear system in  "Case Study: Mixing Chemicals" in Section 5.1.

Here we demonstrate two ways to solve the 3x3 system of equations mat*sol = rhs.
1) Find the inverse of  mat and form sol = mat^{-1} * rhs
2) Use the function LinearSolve in which Mathematica determines the best method.

See "Linear Systems" or the tutorial "Solving Linear Systems" in the Mathematica Help for more information.

See Chapter 5: Solving Linear Systems for details.

Updated July 2008

(* Enter the matrix, row by row *)
mat=
(({{40, 40, 70}, {30, 80, 60}, {60, 10, 30}}));

(* Enter the right-hand side *)
rhs={50, 50, 50};

(* Solve the linear system using the inverse funciton *)
sol=Inverse[mat].rhs//N;

(* Or solve the system using the LinearSolve function *)
sol2 = LinearSolve[mat, rhs] //N

Print["sol = ",sol,"  sol2 = ",sol2]
Print["Solution to chemical mixing problem:"]
Print["Take ",sol[[1]]*100,"% of container 1"]
Print["Take ",sol[[2]]*100,"% of container 2"]
Print["Take ",sol[[3]]*100,"% of container 3"]