next up previous
Next: Stuff to Hand In Up: Warmup Previous: Entering Matrices

Linear Systems

Let's try to get the computer to solve the system

x_1 - 2 x_2 + x_3 &=& 1\  3x_1 + x_2 - 4x_3 &=& 0\  2x_1 + 2 x_2 - x_3 &=& 2\end{eqnarraystar}

The first thing to do is to represent it as a matrix equation. The coefficient matrix is

A = \left[\begin{array}
 1&-2&1\  3&1&-4\  2&2&-1

and the forcing matrix is

B = \left[\begin{array}
 1\ 0\ 2

The system can be abbreviated as AX=B. After you enter the matrices A and B (do it now!), you can ask Matlab or Octave to solve the system by Gaussian elimination. Just row reduce the augmented matrix with the command
and read off the solutions. Do it now![*]

Alternatively, you can ask Matlab or Octave to calculate X by ``dividing'' the equation AX=B by A on the left (since the factor A is on the left). Left division is indicated by a backslash:

  X = A\B
Try it now. You should get the same answer that you got from Gaussian elimination. Note, however, that left division will only produce one solution, even if the system has infinitely many solutions.

Frank Beatrous