Solving Systems

To solve the linear system Ax=b, use Mathematica's LinearSolve[A,b] command. The following example solves mx=v. The output is of the form {x1, x2}.

In[104]:=

  Clear[a,b,x]
  m={{1, 5}, {2, 1}};
  MatrixForm[m]

Out[104]=

  1   5
  
  2   1

In[105]:=

  v={a,b}

Out[105]=

  {a, b}

In[106]:=

  x=LinearSolve[m, v]

Out[106]=

       5 (2 a - b)  2 a - b
  {a - -----------, -------}
            9          9

Note that x is a solution to mx=v if and only if v is a linear combination of the columns of m (see Manipulation with Matrices above). Let's use some of our tools to check this out. (See Basic Manipulations above.)

Column1 of m is:

In[107]:=

  column1=Transpose[m][[1]]

Out[107]=

  {1, 2}

Column2 of m is:

In[108]:=

  column2=Transpose[m] [[2]]

Out[108]=

  {5, 1}

Here is our linear combination of the columns of m. Is it v?

In[109]:=

  x[[1]]column1+x[[2]]column2
  v

Out[109]=

             5 (2 a - b)    2 a - b
  {a, 2 (a - -----------) + -------}
                  9            9

Out[110]=

  {a, b}

Maybe this will help.

In[111]:=

  Simplify[x[[1]]column1+x[[2]]column2]
  v

Out[111]=

  {a, b}

Out[112]=

  {a, b}

Up to Gaussian Elimination and Solving Systems