So we have to figure out what A is, and B, and X, okKay, cuz here's what's kinda cool
about MATLAB. How do you solve aX = b in MATLAB?
You do this. It's as simple as that, right?
The simplest command in MATLAB is just this backslash.
And why is it simplest? Because that's what MATLAB was meant to
do. Solve equations that are linear equations.
That is, yes? Yeah?
That's what you do with it. And that's how you do it.
Backslash, boom. Okay?
If you remember from linear algebra if you had a professor who taught you that
course, they maybe had you do, you know, AX B, AX equal to B by hand, you know, up
to a three by three. More nasty professors would make you do
hand by hand four by 4s. Okay and then, then there's people who
just want to punish you, and they make you do like five by five by hand, okay.
Now what we're gonna do is we're gonna do ultimately things like 10,000 by 10,000.
Now, you're not gonna do that by hand. But it's so easy, it's even easier by
hand. It's faster than doin' it two by two.
You just go, back slash done. Out comes your answer.
Okay? Alright so that's power.
So lets talk about what is A, B and, what are my unknowns?
X is what I'm trying to solve for, and so I have to know what A and B are, and what
I'm trying to solve for. What I'm trying to solve for here is Y.
Okay? So what I'm gonna be thinking about doing
is setting up this problem. Where I'm going from A to B.
Let me just discretize this thing. This is my Y.
And so, this is, let's say, call it y0, y1, y2, and so forth, all the way up to,
call it, y of m plus one. By the way, what is Y zero?
That's my boundary. Don't I already know that?
The fact due right, don't you have that y of a is equal to alpha?
In other words, on the left. And that translates to when we discretize
y zero is equal to alpha. Okay, and this one over here says, well Y
of B on the other end is equal to beta, these are my boundary conditions, that's
just Y of M plus one is equal to beta. So what I'm really going to do is solve
for the interior points of this thing. I don't have to solve for that point or
this point, I already have them, I have to solve, Y1, Y2, all the way to Y of N.
So what I'm going to do is construct my vector X in this AX equal to B.
The things I don't know, Y1, Y2, Y3, all the way to Y's end.
Those are my points. Okay.
So I, I know what X is. Now what's A and what's B for this system?
Well, this is what's telling me A and B are, right here.
Ax equals B. So, the stuff that's multiplying X, which
is the Y over there, is all over here. So this is gonna, this part here is gonna
make up my matrix A. And this part here is gonna, gonna make up
my vector B. Okay, so let's talk about what A might
look like. Not might look like.
Let's talk about what A does look like. Be a little bit more self assured.
Big, remember. We're no longer on the playground, doing
two by 2s. Okay.
This is big boy, big girl stuff now. Okay.
People get hurt, right. So, let's talk about how to build big
matrix and how you want to do this thing effectively.
So, first of all this matrix, what is the structure of it?.
Notice, what does this equation say? When I think about a point y of t, but now
it's not just y of t, these y of t s are gonna be y1, y2, y3, y4 and when I think
about any one of those points, what does it depend on?.
So friends, since if I want to solve this thing at y2, well y2 over here depends
upon, y3, and y1. Neighbors.
So you only care about your two neighbors and yourself.
You do care about yourself, like minus two of yourself.
If we multiply by a negative sign, it might be nicer.
It'd be a more positive and uplifting message.
You'd care about yourself with plus two, okay?
Cuz this is kind of a negative thing, here.
Alright, so, but we'll just go with this. Minus two, this is how much you care about
yourself. Yourself.
It's how you interact with yourself. So, this is the diagonal of that matrix.
Y of N, cares about Y of N. Like this.
So when you think about this thing being here, on your diagonal, you have minus
two, minus delta T squared, and you evaluate this thing here at, let's call it
q1. And in the next diagram, minus two minus
delta t squared, q2. Minus two minus delta t squared, q3, all
the way down to minus two minus delta t squared, q of n.
What are Q1, Q2, Q3? This is the value of this function q
evaluated at all the points. Right?
So if you look here, you have Y1. At Y1 you have a function p or q evaluated
there as well. So, here you have a value q1 and p1, q2
p2, q3 p3. And you walk it all the way across to Y
[inaudible] over here. Okay?
So these are all the interior points. And if you're Y of N, this is how, this is
the diagonal turn, this is how you interact with yourself.
Okay, now. Member I'm solving for this point here.
Member this is multiplying vector, the vector x over there which is Y over Y
vent. If Y1 multiplies this guy here, which is
consistent with this formula. Y2 and by the way Y1 also cares about what
else? Well, it cares about Y2 and Y0.
So, let's talk about Y2 first of all. So the point in front.
Well here's the point in front. The point T plus delta T.
The neighbor on the right. Here's the waiting of that neighbor on the
right. Right there, okay.
So here you're evaluating the next point. One minus delta T over two P of one.
Here, one minus delta t, and two p of two. So the next, off diagonal element.
Now from somewhere down here, let's think about, like, say, I'm at the point YF2.
Yf2 cares about Y3 and Y1, the other neighbor.
The other neighbor has a weight one plus delta T.
Okay? So here you have one plus delta T over two
P of two. One plus delta T, p02, p03.
What are the other matrix elements? Zero.
There's your matrix, called tridiagonal. Tri for three.
Diagonal for diagonal. See, I'm so good at Latin.
Right. It's not even Latin.
I don't know what it is. Alright, so there you go.
Everybody's good with that? Tridiagonal matrix.
That's a matrix A. So, your job is to construct that matrix
A. Now what about the vector B?
Associated with the right, the B is the right hand side of this.
The B is right here. Delta T squared, r of t.
So, this is pretty easy, actually. The B vector is easy to construct, because
this is just what's on the right hand side.
So, let's do it over here on this board. So the vector B.
Is R1, R2, oh sorry there's a delta T squared there.
Delta T squared, R1, delta T squared, R2. Always delta T squared.
Are, yea. There's A, there's B, there's one thing
we've swept under the rug. Let's get to it now.
Okay, is everybody comfortable with this, so far?
This step is really important that you kind of work through, make sure you really
have this step down. Cuz the discretization rely, everything
relies on it. Taking these set of equations here, and
translating it to a x equal to b, that's your job.
Remember, when we do the shooting method, when we have a system of differential
equations, your first job always in that is to turn it into a system of first order
equations. Here, your job is to say, how do I
translate this into a x equal to b, and construct those matrices?