Introduction to Matlab
From charlesreid1
Contents
1703 Lecture: Introduction to Matlab
Matrix Representation
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle x - 2y = 1}
Can someone give me some values of x and y that satisfy this equation?
| x | y |
| 3 | 1 |
| 1 | 0 |
| 2 | Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \frac{1}{2}} |
| 101 | 50 |
How many combinations of x and y will satisfy this equation? Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \infty}
How else can we represent this equation?
As a line:
(insert figure here)
Is the slope positive or negative?
What's the slope?
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 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?
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:
After pushing these two columns together, we get:
What about the equations:
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:
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:
or,
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:
and therefore
Then solve for y by plugging into original equations:
Let's see what's happening in matrix form:
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:
Option B:
What's another way we can solve this?
(Cramer's Rule homework assignment)
Cramer's Rule:
If we have a system like:
then the solution is:
and for y:
One more 2x2 example:
or,
Let's try eliminating x or y and then solving for the remaining variable
So try (1) + 2*(2):
and solving for x,
Then we can plug this into our remaining equation and solve for y:
Look at what we did with our matrix:
We changed row (2) to be row (1) + 2*row(2)
(Can you tell me what I should change in my matrix?)
Now an example for a 3x3 system:
or,
Using elimination: First, we want 1 equation with 1 unknown
Try eqn (3) + eqn (2) - eqn (1)
so,
Next, we want an equation with two unknowns: y, and something else
Let's try (3) + 2*(2):
Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle {\begin{aligned}3x+5y-2z&=&4\\{\underline {+2(-2x-6y+z)}}&=&{\underline {-3}}\\-x-7y+0z&=&-2\end{aligned}}}
Next when we plug in we get
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle x = 2 }
Finally, we want an equation with all 3 unknowns, so that we can plug in the values for x and y that we just found
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \begin{align} 3x + 5y - 2z &=& 4 \\ 3(2)+0-2z &=& 4 \\ -2z &=& -2 \end{align} }
so,
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle z = 1 }
What happened to our matrix? What did our matrix become?
Did row 1 change?
Did row 2 change?
For the first step, we transformed row (3) into row(3) + row(2) - row(1)
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left[ \begin{array}{ccc} 1 & 3 & -1 \\ -2 & -6 & 1 \\ 3 & 5 & -2 \end{array} \right] \rightarrow \left[ \begin{array}{ccc} 1 & 3 & -1 \\ -2 & -6 & 1 \\ 0 & -4 & 0 \end{array} \right] }
What happened in the second step?
Row(2) changed to row(3) + 2*row(2)
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left[ \begin{array}{ccc} 1 & 3 & -1 \\ -2 & -6 & 1 \\ 0 & -4 & 0 \end{array} \right] \rightarrow \left[ \begin{array}{ccc} 1 & 3 & -1 \\ -1 & -7 & 0 \\ 0 & -4 & 0 \end{array} \right] }
or, we could swap column 1 and column 2 and rewrite this as:
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left[ \begin{array}{ccc} 3 & 1 & -1 \\ -7 & -1 & 0 \\ -4 & 0 & 0 \end{array} \right] }
If we swapped column 1 and column 2, how would we have to change the unknowns vector?
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left[ \begin{array}{c} x \\ y \\ z \end{array} \right] \rightarrow \left[ \begin{array}{c} y \\ x \\ z \end{array} \right] }