Solving Systems of Linear Equations Using Matrices, Matrices to solve a system of equations

Solving Systems of Linear Equations

The example:

Consider the system of linear equations

3x + 2y - 5z =  12  x - 3y + 2z = -13 5x -  y + 4z =  10

Write the coefficients in an A matrix.

Write the variables in an X matrix.

Write the constants in a B matrix.

Verify that AX = B

This step isn't really needed, but I wanted to show you that this thing really does work.

AX will be a (3×3) × (3×1) = 3×1 matrix. The B matrix is also a 3×1 matrix, so at least the dimensions work out right.

Here's A times X.

Notice that turns out to be the left side of the system of equations. The B is the right hand side, so we have achieved equality. Woohoo! You can write a system of linear equations as AX = B.

So, if you can write a system of linear equations as AX=B where A is the coefficient matrix, X is the variable matrix, and B is the right hand side, you can find the solution to the system by X = A-1 B.

Place the coefficient matrix into [A] on the calculator and the right hand side into [B].

If you asked the calculator to find the inverse of the coefficient matrix, it would give you this for A-1

You could do that, and then multiply that by B, but it would be easier just to put the whole expression into the calculator and get the answer directly. Even what is shown below is more work than is necessary.

X = A-1 B = ...

There you go, x = 191/88, y = 519/88, and z = 111/88. That would be a real pain to solve by hand.

The Example

One of the last examples on Systems of Linear Equations was this one:

Example: Solve

We then went on to solve it using "elimination" ... but we could have solved it using Matrices!

Using Matrices makes life easier because we can use a computer program (such as the Matrix Calculator) to do all the "number crunching".

First, we need to write the question in Matrix form.

In Matrix Form?

OK. A Matrix is an array of numbers, right?

 

A Matrix

Well, think about the equations:

They could be turned into a table of numbers like this:

We could even separate the numbers before and after the "=" into:

Now it looks like we have 2 Matrices.

In fact we have a third one, which is [x y z], and the way that matrices are multiplied (read How to Multiply Matrices) means we need to set it up like this:

And we know that x + y + z = 6, etc, so we can write the system of equations like this:

Pretty neat, hey?

The Matrix Solution

We can call the matrices "A", "X" and "B" and the equation becomes:

AX = B

Where

Then (as shown on the Inverse of a Matrix page) the solution is this:

X = A-1B

(Assuming we can calculate the Inverse Matrix A-1)

In fact we get this (using the Matrix Calculator):

(I left the 1/determinant outside the matrix to make the numbers simpler)

Then multiply A-1 by B (we can use the Matrix Calculator again):

And we are done! The solution is:

x = 5, y = 3 and z = -2

Quite neat and elegant, and the human does the thinking while the computer does the calculating.