From charlesreid1

No edit summary
Line 185: Line 185:
What about the matrix representation of 4 equations?  5 equations?  6 equations?
What about the matrix representation of 4 equations?  5 equations?  6 equations?


The matrix representation is really easy
The matrix representation is easy and flexible
 
 
 
== Solving Systems of Equations ==
 
Now let's talk about how you actually solve these systems...
 
Going back to original example:
 
<math>
\begin{align}
x - 2y &=& 1 \\
3x + 2y &=& 11
\end{align}
</math>
 
or,
 
<math>
\left[
\begin{array}{cc}
1 & -2 \\
3 & 2
\end{array}
\right]
 
\left[
\begin{array}{c}
x \\
y
\end{array}
\right]
 
=
 
\left[
\begin{array}{c}
1 \\
11
\end{array}
\right]
</math>
 
'''Option A:'''
 
Use elimination to eliminate one variable, solve for the other variable
 
Then plug that into one of these equations to find the other variable
 
Example:
 
Eliminate y by adding the two equations:
 
<math>
\begin{align}
x - 2y & = & 1 \\
\underline{ + \left( 3x + 2y \right) } &=& \underline{ +(11) } \\
4x + 0y & = & 12
\end{align}
</math>
 
and therefore
 
<math>
x = 3
</math>
 
Then solve for y by plugging <math>x=3</math> into original equations:
 
<math>
\begin{align}
x - 2y &=& 1 \\
(3) - 2y &=& 1 \\
-2y &=& -2 \\
y &=& 1
</math>
 
Let's see what's happening in matrix form:
 
<math>
\left[
\begin{array}{cc}
1 & -2 \\
3 & 2
\end{array}
\right]
 
\left[
\begin{array}{c}
x \\
y
\end{array}
\right]
 
=
 
\left[
\begin{array}{c}
1 \\
11
\end{array}
\right]
</math>
 
We're adding equation (1) to equation (2), and using that as our new equation (2)
 
So in the matrix, we're replacing row(2) with ( row(1) + row(2) )
 
The matrix becomes:
 
<math>
\left[
\begin{array}{cc}
1 & -2 \\
4 & 0
\end{array}
\right]
 
\left[
\begin{array}{c}
x \\
y
\end{array}
\right]
 
=
 
\left[
\begin{array}{c}
1 \\
12
\end{array}
\right]
</math>
 
'''Option B:'''
 
What's another way we can solve this?
 
(Cramer's Rule homework assignment)
 
Cramer's Rule:
 
If we have a system like:
 
<math>
\left[
\begin{array}{cc}
a & b \\
c & d
\end{array}
\right]
 
\left[
\begin{array}{c}
x \\
y
\end{array}
\right]
 
=
 
\left[
\begin{array}{c}
e \\
f
\end{array}
\right]
</math>
 
then the solution is:
 
<math>
\begin{align}
x &=& \frac{ed - bf}{ad - bc} = \frac{ (1)(2) - (-2)(11) }{ (1)(2) - (-2)(3) } \\
  &=& \frac{2 + 22}{2 + 6} \\
x &=& 3
\end{align}
</math>
 
and for y:
 
<math>
\begin{align}
y &=& \frac{af - ec}{ad - bc} = \frac{ (1)(11) - (1)(3) }{ (1)(2) - (-2)(3) }
  &=& \frac{11-3}{2+6}
y &=& 1
\end{align}
</math>
 
 
 
One more 2x2 example:
 
<math>
\begin{align}
2x + 4y &=& 1 \\
-3x - 2y &=& 3
\end{align}
</math>
 
or,
 
<math>
\left[
\begin{array}{cc}
2 & 4 \\
-3 & -2
\end{array}
\right]
 
\left[
\begin{array}{c}
x \\
y
\end{array}
\right]
 
=
 
\left[
\begin{array}{c}
1 \\
3
\end{array}
\right]
</math>
 
Let's try eliminating x or y and then solving for the remaining variable
 
So try (1) + 2*(2):
 
<math>
\begin{align}
2x + 4y &=& 1 \\
\underline{ +2 \left( -3x - 2y \right) } &=& \underline{ +2 (3) } \\
-4x + 0y &=& 7
\end{align}
</math>
 
and solving for x,
 
<math>
x = -\frac{7}{4}
</math>
 
Then we can plug this into our remaining equation and solve for y:
 
<math>
\begin{align}
2x + 4y &=& 1 \\
2 \left( - \frac{7}{4} \right) + 4y &=& 1 \\
-\frac{14}{4} + 4y &=& 1 \\
4y &=& \frac{4}{4} + \frac{14}{4} = \frac{18}{4} \\
y &=& \frac{9}{8}
\end{align}
</math>
 
 





Revision as of 21:58, 15 October 2010

1703 Lecture: Introduction to Matlab

Matrix Representation

$ x - 2y = 1 $

Can someone give me some values of x and y that satisfy this equation?

x y
3 1
1 0
2 $ \frac{1}{2} $
101 50

How many combinations of x and y will satisfy this equation? $ \infty $

How else can we represent this equation?

As a line:

(insert figure here)

Is the slope positive or negative?

What's the slope?


$ 3x + 2y = 11 $

Some values of x and y that satisfy this equation?

x y
3 1
1 4
75 -107

How many combinations of x and y will satisfy this equation? $ \infty $

We can also represent this equation as a line

(insert figure here - both lines on same plot)

What's the slope?

We can see that the point x=3, y=1 is where these two lines meet - which means it is the combination of x and y that satisfies both of these equations.


How else can we represent these equations?

In column form:

$ \left[ \begin{array}{cc} 1 \\ 3 \end{array} \right] x + \left[ \begin{array}{cc} -2 \\ 2 \end{array} \right] y = \left[ \begin{array}{cc} 1 \\ 11 \end{array} \right] $

After pushing these two columns together, we get:

$ \left[ \begin{array}{cc} 1 & -2 \\ 3 & 2 \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] = \left[ \begin{array}{c} 1 \\ 11 \end{array} \right] $

What about the equations:

$ \begin{align} 3x + 5y + z & = & 16 \\ 2x - y - z & = & 3 \\ x + 4y - 2z &=& 3 \end{align} $

How to represent this graphically?

Instead of lines, use planes

Let's look at the first 2 equations only:

(Insert figure here)

The two planes intersect to form a line

Now the third equation: Also a plane

The line that represents the intersection of these first two equations will intersect the third equation's plane at one point

We can also represent these equations in matrix form:

$ \left[ \begin{array}{cc} 3 \\ 2 \\ 1 \end{array} \right] x + \left[ \begin{array}{cc} 5 \\ -1 \\ 4 \end{array} \right] y + \left[ \begin{array}{cc} 1 \\ -1 \\ -2 \end{array} \right] z = \left[ \begin{array}{cc} 16 \\ 3 \\ 3 \end{array} \right] $


$ \left[ \begin{array}{ccc} 3 & 5 & 1 \\ 2 & -1 & -1 \\ 1 & 4 & -2 \end{array} \right] \left[ \begin{array}{c} x \\ y \\ z \end{array} \right] = \left[ \begin{array}{c} 16 \\ 3 \\ 3 \end{array} \right] $

How do we represent 4 equations graphically?

5 equations?

6 equations?

We run into a limit using graphical methods

What about the matrix representation of 4 equations? 5 equations? 6 equations?

The matrix representation is easy and flexible


Solving Systems of Equations

Now let's talk about how you actually solve these systems...

Going back to original example:

$ \begin{align} x - 2y &=& 1 \\ 3x + 2y &=& 11 \end{align} $

or,

$ \left[ \begin{array}{cc} 1 & -2 \\ 3 & 2 \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] = \left[ \begin{array}{c} 1 \\ 11 \end{array} \right] $

Option A:

Use elimination to eliminate one variable, solve for the other variable

Then plug that into one of these equations to find the other variable

Example:

Eliminate y by adding the two equations:

$ \begin{align} x - 2y & = & 1 \\ \underline{ + \left( 3x + 2y \right) } &=& \underline{ +(11) } \\ 4x + 0y & = & 12 \end{align} $

and therefore

$ x = 3 $

Then solve for y by plugging $ x=3 $ into original equations:

$ \begin{align} x - 2y &=& 1 \\ (3) - 2y &=& 1 \\ -2y &=& -2 \\ y &=& 1 $

Let's see what's happening in matrix form:

$ \left[ \begin{array}{cc} 1 & -2 \\ 3 & 2 \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] = \left[ \begin{array}{c} 1 \\ 11 \end{array} \right] $

We're adding equation (1) to equation (2), and using that as our new equation (2)

So in the matrix, we're replacing row(2) with ( row(1) + row(2) )

The matrix becomes:

$ \left[ \begin{array}{cc} 1 & -2 \\ 4 & 0 \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] = \left[ \begin{array}{c} 1 \\ 12 \end{array} \right] $

Option B:

What's another way we can solve this?

(Cramer's Rule homework assignment)

Cramer's Rule:

If we have a system like:

$ \left[ \begin{array}{cc} a & b \\ c & d \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] = \left[ \begin{array}{c} e \\ f \end{array} \right] $

then the solution is:

$ \begin{align} x &=& \frac{ed - bf}{ad - bc} = \frac{ (1)(2) - (-2)(11) }{ (1)(2) - (-2)(3) } \\ &=& \frac{2 + 22}{2 + 6} \\ x &=& 3 \end{align} $

and for y:

$ \begin{align} y &=& \frac{af - ec}{ad - bc} = \frac{ (1)(11) - (1)(3) }{ (1)(2) - (-2)(3) } &=& \frac{11-3}{2+6} y &=& 1 \end{align} $


One more 2x2 example:

$ \begin{align} 2x + 4y &=& 1 \\ -3x - 2y &=& 3 \end{align} $

or,

$ \left[ \begin{array}{cc} 2 & 4 \\ -3 & -2 \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] = \left[ \begin{array}{c} 1 \\ 3 \end{array} \right] $

Let's try eliminating x or y and then solving for the remaining variable

So try (1) + 2*(2):

$ \begin{align} 2x + 4y &=& 1 \\ \underline{ +2 \left( -3x - 2y \right) } &=& \underline{ +2 (3) } \\ -4x + 0y &=& 7 \end{align} $

and solving for x,

$ x = -\frac{7}{4} $

Then we can plug this into our remaining equation and solve for y:

$ \begin{align} 2x + 4y &=& 1 \\ 2 \left( - \frac{7}{4} \right) + 4y &=& 1 \\ -\frac{14}{4} + 4y &=& 1 \\ 4y &=& \frac{4}{4} + \frac{14}{4} = \frac{18}{4} \\ y &=& \frac{9}{8} \end{align} $