>> So, we're going to do boundary value problems today.
By the way, we're off loading today. This lecture's not in the notes like
everything else. I know, I know, crazy.
Okay. Anyway, I'm going to write this up and I
will probably have it up within the next couple of days, we'll see.
But, of course, it's available online and I may be will, I might email you these
codes or I might just try to type it up quickly so then I can just send it all at
once to you. So, we're going to talk about MATLAB's
boundary value problem solver, okay? That's built in and how to use it.
So, what we have right now are two techniques.
We have techniques of, of shooting, right? Where you go from one end, you shoot
across trying to land on the two boundaries.
You also have the idea that we talked about last time, which is, you can
discretize. You can take this domain that you're
solving for, and just use what the definition of derivative using the slope
formulas essentially, to discretize the domain and set up a giant matrix problem.
Now, in general, when it's non-linear, it's no longer just a x equal to b, but
some non-linear system of equations to solve.
Okay? So, you could program that up.
But, in fact, MATLAB has already done it for you.
So, we'll learn how to see how they think about this.
We're going to start off with a simple example, okay?
So, here's the example we'll start with today.
This, with the following boundaries. We'll solve it, let's say, from x is an
interval between one and three. And, my boundary conditions would be the
following. Y at one will be equal to three, and y at
three plus 2y prime at three is equal to five, okay?
I just made this to, I just made that up, right?
Okay. Okay.
So, we go, okay, how to solve this? Now, this, this is a simple problem.
I could actually, I could do it analytically.
I know how to solve this thing. I could write down solutions by hand,
okay? So, to some extent we're going to test
this. Can I take something like this and can I
put it into MATLAB, have MATLAB solve it for me, get out this solution I want.
Okay. So, as before, the first thing you're
going to have to do, is you're going to, to transform the second order equation
int, to first order equation. Second, you can just start thinking about
these boundaries as functions that need to be satisfied, okay?
And, so, what we want to do is set this up.
We have the equations itself and the boundaries.
These are two things that have to be satisfied.
So, I gotta satisfy this, you gotta satisfy that.
So we're going to tell the program how to this.
So, first, lets break it up into a system of first order equations, right?
So first, I might do something like this, I will define y1 to be y and y2 to be y
prime, okay? So then, again, let's just go through this
process again. Take the derivative of both sides, you get
y1 prime is equal to y prime, y2 prime is equal to y double prime.
And the first equation says, y1 prime is equal to y prime, but wait a minute, y
prime was just y2. So, I have an equation, y1 prime is equal
to y2, and then I have y2 prime is equal to y double prime.
But, what's y double prime? Well, I know what that is cuz that's in my
equation. So, y double prime, I can come back over
here and look at here. Y double prime is five minus 3y prime
minus 6y, okay? So, I can move this to other side, and if
I do that, I get five minus three y prime minus six y.
But, y prime is y2 and y is y1. So, these just get traded out for a y two,
and a y1. There it is, first order form.
We're set to go, we're going to use that. What about the binary conditions?
We also want to state the binary conditions in the following way.
What we want to think of is, I have some binary condition on the left, let's call
it f of l, for left. In this case, it's one.
I want to figure out how to write this, this, I have some conditions on the left,
some function. What's that?
>>, To the left, and right for each. Then, function on the right.
So, what are these two functions? Well, from here, they're pretty simple,
actually. I want this, something equal to zero.
So, what I have over here is y at one is equal to three.
Well, y is what? Y is y sub one, right?
I'm going to trade that out. I'm going to say that, I'm going to write
it in terms of y1 and y2. And so, my boundary conditions are the
following. On the left, I'm going to have, y1 minus
three is equal to zero. That's my boundary condition at one, my
left boundary condition. >> I'm sorry.
[indiscernible] that's the convention for the solver.
>> That's the convention for the solver. For the [inaudible]?
>> Yup. >> Okay.
You want some function that's equal to zero.
The other one. So, I move that over, the other one here I
just move the five over. And what I have is y3 plus 2y prime at
three minus five would be equal to zero. And, so I know that y is y1 to y prime, y
prime is y2. So, what I really get there is y1 plus two
y2 minus five is equal to zero at x equals three.
So, I've rewritten the equation, and the boundary conditions.
Okay? So, that's it.
Everything's now, in terms of y1 and y2, I'm trying to satisfy this and this
simultaneously, okay? Alright.
So, this is the information that MATLAB needs from you.
What you're responsible for is giving it the right hand side, just like in the ODE
solvers, right? It assumes that you have a DYDT equals
some right hand side. Here's your right hand side right there.
Matlab needs to know that. It also needs to know what these two
functions are. So, you have to give those as well.