>> It's a problem when you start thinking about nonlinear equations.
I'm going to erase this. Everybody okay with that?
Alright. Now, let's talk about how to think about
this method, which is, let's just go back to something like this.
I can still have the same boundary conditions as before.
Let's say, y of a is equal to alpha, y of b is equal to beta.
And then, I ask the question, I would like to solve this for some generic f.
Now, the f here might be nonlinear, okay? So, you still do the discretization
process. You still would say, okay, let's, let's do
the following. This, this thing here is y of point front
minus twice the current point plus point behind over delta t squared is equal to f
t, you know, y of n, y of n plus one minus y of n minus one over two delta t.
And I have this. And, you know, if I multiply by delta t, t
squared, let's call this f of n because we're evaluating it.
So, what I'm going to get is big, nonlinear system of equations.
Okay. Let's talk about also the importance of x
equal to b. The importance of x to b is, there's a,
there's a few things about it. First of all, there's a procedure you
could write to do it, right? There's and algorithm that you do, and
underlying there is a big assumption. Underlying there's this big assumption
that when you solve x equal to b, there is one unique solution.
And if there isn't, it's because that determinant of that matrix say, was zero,
and there's problems. But, right?
As long as it's not singular, you know that when you get an answer, it is the
only answer possible. And when you have a null in your system,
tell me, how many solutions does it have? 31.
You don't know. It could be 31.
It could be seventeen, it could be three, it could be zero, could be infinity.
That's a little bit of a problem for you, because you're going to try to solve this
thing, right? And you don't know if there is a solution,
if there isn't a solution, there's seventeen of them, did I find the right
one? Nonlinear systems are problematic.
Most the techniques set up to solve such nonlinear systems, and this is going to
typically a huge nonlinear system, right? I'm going to discretize this thing and I
then I gotta solve, let's say, suppose I discretize it into a 100 points.
I've got to solve a 100 nonlinear equations simultaneously.
Almost every method used to solve a nonlinear system relies on you giving it a
guess, okay? So, nonlinear systems, the best way to
solve them is being a really awesome guesser, okay?
And by the way, how would you think about solving a nonlinear system?
I just want to make a couple of comments about it because it's not clear.
We want to go too depth, into much depth with this, except to say there are
algorithms to do it. Does this have zeroes command in MATLAB
that looks for zeros of a function. What's it doing?
And what does it need from you? The f zeros command typically wants you to
guess the solution first. And it'll take that solution, and what
it's going to do, it's going to iterate, okay?
This is a method called Newton Method. So, you guys have been using it, right?
The Newton Method for the practice was there, and the whole idea behind the
Newton Method was to say, how about, you know, I have this function.
And, here's the solution. I'm trying to find, here's my function f
of x, I'm trying to find when is f of x equal to zero?
And there's some value, that's called x not.
Let's call it, actually, something else called x bar.
There's an x bar where that's zero. And how do you find that?
If it's a complicated function, often times, you're not going to be able to
write down the solution. So, what you're going to have to do is
find a numerical way to find this and this is why I had you just do a little practice
problem with this, but Newton's method says, okay, guess the solution.
And, what Newton's method said is, the way that Newton's method is going to work is
going to be the following. I'm going to guess the solution, x not,
and it's going to be wrong. The way it's going to do is it's going to
say take that solution and try to iterate towards the real solution.
So, the way it does it, is goes up from here and it, where ever this thing is, so
I picked that x not and clearly my function is not a zero there.
Here it is, this is the value, it's supposed to be appear x not.
But, what I'll do is to get my next value, is I'll take off on a tangent line.
And look where I hit. This I'm going to call x1.
And ask the question, is that the solution?
No, cuz look. Here's my value which is clearly not zero.
Alright, do it again. Take off on the tangent.
There's x2. Is that the solution?
No. Take off on the tangent.
You see what's happening there?
And I keep going, and I converge to x bar. It's a, it's a iterative procedure that
does the following. It says, how do I know which way to go on
a guess? You give me a guess.
Fine. What's the computer good at?
What's it love to do? It loves to iterate.
So, let's just have it something to iterate on.
So, the way it iterates is to say, I will take off on slopes, and hope that I'm
heading in the right direction. This concept is the same that applies
here. If you're going to solve a nonlinear
system, so, that, this Newton method is just a one dimensional version of this.
No, think about going to some higher space.
What you really want to do is take off on the gradient.
The gradient tells you essentially, it's just like the slope.
How do I, I pick a solution, I pick a guess, and it's wrong.
How do I get to the next guess, and the next guess, and iterate forward?
You do it according to the gradient. And what you hope is the gradient is
pointing you in the right direction. Now, for this case here, clearly, I made
up an example. The slopes point you to here and get you
to converge. Okay?
And, by the way, here's a really awesome, yet completely useless theorem.
Ready for it? Newton's method is guaranteed to converge
if your guess is sufficiently close. Tell me what sufficiently means.
Sufficiently could mean, hey, anywhere in the ballpark of infinity, you know,
depending on the function, converge no matter how you guess.
And some of it, you better guess within ten to the minus six.
The thing's taking off on you. But, it is guaranteed to converge.
>> [laugh] >> If you are a good enough guesser.
So, that is how people build these routines to say, you know, what?
Maybe you know something. And, by the way, so, on a practical note,
this is kind of true. A lot of these nonlinear systems, you
might actually have some insight to the system.
You might know how it sort of behaves, you know what you're kind of looking for.
Maybe out of this whole sea of, you know, 31 solutions, the one you want you kinda
know what it should kinda look like. And you guess that.
And then, you hope for the best. So, but if you don't know anything, you're
just stuck. Now, if, although if you do have zeros,
you know what it gets us if you don't give it a guess?
It just says, how about if we get zero as the solution.
It'll take off from there and it will go somewhere.
It might be where you want, it might not be, okay?
So, nonlinear systems are difficult, and this is why there's not a, a nonlinear
version of a backslash b cuz you can't build it.
So, but what they can guarantee is backslash will work nicely and here's the
example of it.