1
00:00:00,000 --> 00:00:00,500
2
00:00:00,500 --> 00:00:02,944
The following content is
provided under a Creative
3
00:00:02,944 --> 00:00:03,610
Commons license.
4
00:00:03,610 --> 00:00:06,730
Your support will help
MIT OpenCourseWare
5
00:00:06,730 --> 00:00:09,920
offer high quality educational
resources for free.
6
00:00:09,920 --> 00:00:12,590
To make a donation or to
view additional materials
7
00:00:12,590 --> 00:00:16,150
from hundreds of MIT courses,
visit MIT OpenCourseWare
8
00:00:16,150 --> 00:00:19,990
at ocw.mit.edu.
9
00:00:19,990 --> 00:00:22,750
PROFESSOR STRANG: Starting
with a differential equation.
10
00:00:22,750 --> 00:00:24,820
So key point here
in this lecture
11
00:00:24,820 --> 00:00:28,850
is how do you start with
a differential equation
12
00:00:28,850 --> 00:00:38,540
and end up with a discrete
problem that you can solve?
13
00:00:38,540 --> 00:00:40,820
But simple
differential equation.
14
00:00:40,820 --> 00:00:44,590
It's got a second derivative and
I put a minus sign for a reason
15
00:00:44,590 --> 00:00:46,810
that you will see.
16
00:00:46,810 --> 00:00:50,760
Second derivatives are
essentially negative
17
00:00:50,760 --> 00:00:54,710
definite things so that
minus sign is to really
18
00:00:54,710 --> 00:00:56,720
make it positive definite.
19
00:00:56,720 --> 00:01:01,120
And notice we have
boundary conditions.
20
00:01:01,120 --> 00:01:04,990
At one end the solution is zero,
at the other end it's zero.
21
00:01:04,990 --> 00:01:07,850
So this is fixed-fixed.
22
00:01:07,850 --> 00:01:10,260
And it's a boundary
value problem.
23
00:01:10,260 --> 00:01:14,390
That's different from an
initial value problem.
24
00:01:14,390 --> 00:01:17,340
We have x space, not time.
25
00:01:17,340 --> 00:01:19,440
So we're not starting
from some thing
26
00:01:19,440 --> 00:01:24,080
and oscillating or growing
or decaying in time.
27
00:01:24,080 --> 00:01:25,270
We have a fixed thing.
28
00:01:25,270 --> 00:01:27,470
Think of an elastic bar.
29
00:01:27,470 --> 00:01:30,580
An elastic bar
fixed at both ends,
30
00:01:30,580 --> 00:01:33,020
maybe hanging by its own weight.
31
00:01:33,020 --> 00:01:37,880
So that load f(x) could
represent the weight.
32
00:01:37,880 --> 00:01:39,900
Maybe the good place
to sit is over there,
33
00:01:39,900 --> 00:01:43,200
there are tables
just, how about that?
34
00:01:43,200 --> 00:01:48,130
It's more comfortable.
35
00:01:48,130 --> 00:01:51,470
So we can solve that equation.
36
00:01:51,470 --> 00:01:54,700
Especially when I
change f(x) to be one.
37
00:01:54,700 --> 00:01:56,890
As I plan to do.
38
00:01:56,890 --> 00:01:58,345
So I'm going to
change, I'm going
39
00:01:58,345 --> 00:02:01,200
to make it-- it's a
uniform bar because there's
40
00:02:01,200 --> 00:02:04,530
no variable coefficient in
there and let me make it
41
00:02:04,530 --> 00:02:07,090
a uniform load, just one.
42
00:02:07,090 --> 00:02:12,520
So it actually shows you
that, I mentioned differential
43
00:02:12,520 --> 00:02:15,960
equations and we'll certainly
get onto Laplace's equation,
44
00:02:15,960 --> 00:02:19,100
but essentially our differential
equations will not--
45
00:02:19,100 --> 00:02:23,420
this isn't a course in
how to solve ODEs or PDEs.
46
00:02:23,420 --> 00:02:25,270
Especially not ODEs.
47
00:02:25,270 --> 00:02:28,940
It's a course in how
to compute solutions.
48
00:02:28,940 --> 00:02:32,650
So the key idea will be to
replace the differential
49
00:02:32,650 --> 00:02:34,980
equation by a
difference equation.
50
00:02:34,980 --> 00:02:37,350
So there's the
difference equation.
51
00:02:37,350 --> 00:02:40,040
And I have to talk about that.
52
00:02:40,040 --> 00:02:46,500
That's the sort of key
point, that-- up here you
53
00:02:46,500 --> 00:02:50,570
see what I would call
a second difference.
54
00:02:50,570 --> 00:02:54,270
Actually with a minus sign.
55
00:02:54,270 --> 00:02:59,950
And on the right-hand side
you see the load, still f(x).
56
00:02:59,950 --> 00:03:03,950
Can I move to this board
to explain differences?
57
00:03:03,950 --> 00:03:06,970
Because this is
like, key step is
58
00:03:06,970 --> 00:03:09,720
given the differential
equation replace it
59
00:03:09,720 --> 00:03:11,860
by difference equation.
60
00:03:11,860 --> 00:03:15,900
And the interesting point
is you have many choices.
61
00:03:15,900 --> 00:03:17,450
There's one
differential equation
62
00:03:17,450 --> 00:03:23,120
but even for a first
derivative, so this,
63
00:03:23,120 --> 00:03:26,150
if you remember from
calculus, how did you
64
00:03:26,150 --> 00:03:28,210
start with the derivative?
65
00:03:28,210 --> 00:03:32,900
You started by something
before going to the limit.
66
00:03:32,900 --> 00:03:38,970
h or delta x goes to zero in
the end to get the derivative.
67
00:03:38,970 --> 00:03:41,680
But this was a
finite difference.
68
00:03:41,680 --> 00:03:44,690
You moved a finite amount.
69
00:03:44,690 --> 00:03:48,210
And this is the one you always
see in calculus courses.
70
00:03:48,210 --> 00:03:55,140
u(x+h) - u(x), just how
much did that step go.
71
00:03:55,140 --> 00:03:58,320
You divide by the
delta x, the h,
72
00:03:58,320 --> 00:04:03,400
and that's approximately
the derivative, u'(x).
73
00:04:03,400 --> 00:04:07,160
74
00:04:07,160 --> 00:04:11,070
Let me just continue
with these others.
75
00:04:11,070 --> 00:04:15,170
I don't remember if calculus
mentions a backward difference.
76
00:04:15,170 --> 00:04:21,150
But you won't be surprised that
another possibility, equally
77
00:04:21,150 --> 00:04:24,400
good more or less, would
be to take the point
78
00:04:24,400 --> 00:04:29,170
and the point before, take the
difference, divide by delta x.
79
00:04:29,170 --> 00:04:32,890
So again all these
approximate u'.
80
00:04:32,890 --> 00:04:38,000
And now here's one that
actually is really important.
81
00:04:38,000 --> 00:04:39,910
A center difference.
82
00:04:39,910 --> 00:04:43,260
It's the average of
the forward and back.
83
00:04:43,260 --> 00:04:47,440
If I take that plus that,
the u(x)'s cancel and I'm
84
00:04:47,440 --> 00:04:50,850
left with, I'm centering it.
85
00:04:50,850 --> 00:04:53,820
This idea of centering
is a good thing actually.
86
00:04:53,820 --> 00:04:57,930
And of course I have to divide
by 2h because this step is now
87
00:04:57,930 --> 00:05:00,660
2h, two delta x's.
88
00:05:00,660 --> 00:05:02,890
So that again is
going to represent u'.
89
00:05:02,890 --> 00:05:05,720
90
00:05:05,720 --> 00:05:10,910
But so we have a choice if
we have a first derivative.
91
00:05:10,910 --> 00:05:15,210
And actually that's a big issue.
92
00:05:15,210 --> 00:05:18,790
You know, one might
be called upwind,
93
00:05:18,790 --> 00:05:21,490
one might be called downwind,
one may be called centered.
94
00:05:21,490 --> 00:05:25,120
It comes up constantly in aero,
in mechanical engineering,
95
00:05:25,120 --> 00:05:26,660
everywhere.
96
00:05:26,660 --> 00:05:28,870
You have these choices to make.
97
00:05:28,870 --> 00:05:30,830
Especially for the
first difference.
98
00:05:30,830 --> 00:05:35,590
We don't have, I didn't
allow a first derivative
99
00:05:35,590 --> 00:05:40,410
in that equation because I
wanted to keep it symmetric
100
00:05:40,410 --> 00:05:43,540
and first derivatives,
first differences
101
00:05:43,540 --> 00:05:45,750
tend to be anti-symmetric.
102
00:05:45,750 --> 00:05:49,310
So if we want to get
our good matrix K,
103
00:05:49,310 --> 00:05:52,670
and I better remember
to divide by h squared,
104
00:05:52,670 --> 00:05:56,500
because the K just has those
that I introduced last time
105
00:05:56,500 --> 00:06:02,730
and will repeat, the K just
has the numbers -1, 2, -1.
106
00:06:02,730 --> 00:06:11,380
Now, first point before we leave
these guys what's up with them?
107
00:06:11,380 --> 00:06:13,960
How do we decide
which one is better?
108
00:06:13,960 --> 00:06:17,110
There's something called
the order of accuracy.
109
00:06:17,110 --> 00:06:21,590
How close is the difference
to the derivative?
110
00:06:21,590 --> 00:06:26,880
And the answer is the
error is of size h.
111
00:06:26,880 --> 00:06:33,390
So I would call that
first order accurate.
112
00:06:33,390 --> 00:06:37,020
And I can repeat here
but the text does it,
113
00:06:37,020 --> 00:06:43,580
how you recognize what-- This
is the sort of local error,
114
00:06:43,580 --> 00:06:48,050
truncation error, whatever,
you've chopped off
115
00:06:48,050 --> 00:06:51,900
the exact answer and
just did differences.
116
00:06:51,900 --> 00:06:55,310
This one is also order h.
117
00:06:55,310 --> 00:07:00,200
And in fact, the h
terms, the leading error,
118
00:07:00,200 --> 00:07:02,480
which is going to
multiply the h,
119
00:07:02,480 --> 00:07:05,530
has opposite sign in
these two and that's
120
00:07:05,530 --> 00:07:08,230
the reason centered
differences are great.
121
00:07:08,230 --> 00:07:13,380
Because when you average
them your center things--
122
00:07:13,380 --> 00:07:15,850
this is correct to
order h squared.
123
00:07:15,850 --> 00:07:19,240
124
00:07:19,240 --> 00:07:24,760
And I may come back and find
out why that h squared term is.
125
00:07:24,760 --> 00:07:25,711
Maybe I'll do that.
126
00:07:25,711 --> 00:07:26,210
Yeah.
127
00:07:26,210 --> 00:07:27,400
Why don't I just?
128
00:07:27,400 --> 00:07:29,270
Second differences
are so important.
129
00:07:29,270 --> 00:07:31,270
Why don't we just see.
130
00:07:31,270 --> 00:07:32,980
And centered differences.
131
00:07:32,980 --> 00:07:34,690
So let me see.
132
00:07:34,690 --> 00:07:36,270
How do you figure u(x+h)?
133
00:07:36,270 --> 00:07:40,850
134
00:07:40,850 --> 00:07:48,900
This is a chance to remember
something called Taylor series.
135
00:07:48,900 --> 00:07:51,630
But that was in calculus.
136
00:07:51,630 --> 00:07:55,140
If you forgot it,
you're a normal person.
137
00:07:55,140 --> 00:07:58,550
So but what does it say?
138
00:07:58,550 --> 00:08:01,000
That's the whole point
of calculus, in a way.
139
00:08:01,000 --> 00:08:07,000
That if I move a little
bit, I start from the point
140
00:08:07,000 --> 00:08:08,770
x and then there's
a little correction
141
00:08:08,770 --> 00:08:11,990
and that's given
by the derivative
142
00:08:11,990 --> 00:08:14,000
and then there's a
further correction
143
00:08:14,000 --> 00:08:15,630
if I want to go
further and that's
144
00:08:15,630 --> 00:08:19,160
given by half of h squared,
you see the second order
145
00:08:19,160 --> 00:08:23,270
correction, times the
second derivative.
146
00:08:23,270 --> 00:08:25,500
And then, of course, more.
147
00:08:25,500 --> 00:08:28,430
But that's all you
ever have to remember.
148
00:08:28,430 --> 00:08:29,620
It's pretty rare.
149
00:08:29,620 --> 00:08:35,110
Second order accuracy
is often the goal
150
00:08:35,110 --> 00:08:38,150
in scientific computing.
151
00:08:38,150 --> 00:08:41,420
First order accuracy is,
like, the lowest level.
152
00:08:41,420 --> 00:08:44,920
You start there, you write a
code, you test it and so on.
153
00:08:44,920 --> 00:08:48,140
But if you want production,
if you want accuracy,
154
00:08:48,140 --> 00:08:50,200
get to second order if possible.
155
00:08:50,200 --> 00:08:53,580
Now, what about this u(x-h)?
156
00:08:53,580 --> 00:08:56,700
Well, that's a step
backwards, so that's u(x),
157
00:08:56,700 --> 00:09:02,210
now the step is -h, but
then when I square that step
158
00:09:02,210 --> 00:09:08,030
I'm back to +h^2
u''(x) and so on.
159
00:09:08,030 --> 00:09:09,550
Ooh!
160
00:09:09,550 --> 00:09:14,130
Am I going to find
even more accuracy?
161
00:09:14,130 --> 00:09:17,790
I could tell you what
the next term is.
162
00:09:17,790 --> 00:09:25,480
Plus h^3 upon 6, that's
3*2*1, u triple-prime.
163
00:09:25,480 --> 00:09:29,380
And this would be, since
this step is -h now,
164
00:09:29,380 --> 00:09:30,750
it would be -h^3 / 6 u'''.
165
00:09:30,750 --> 00:09:34,070
166
00:09:34,070 --> 00:09:37,340
So what happens when I take
the difference of these two?
167
00:09:37,340 --> 00:09:40,810
Remember now that centered
differences subtract this
168
00:09:40,810 --> 00:09:42,050
from this.
169
00:09:42,050 --> 00:09:51,170
So now that u(x+h)
- u(x-h) is zero,
170
00:09:51,170 --> 00:09:58,370
2hu' subtracting that from
that is zero, two of these,
171
00:09:58,370 --> 00:10:02,390
so I guess that we really
have an h^3 / 3 u'''.
172
00:10:02,390 --> 00:10:05,760
173
00:10:05,760 --> 00:10:11,730
And now when I divide by the 2h,
can I just divide by 2h here?
174
00:10:11,730 --> 00:10:14,450
Oh yeah, it's coming
out right, divide by 2h,
175
00:10:14,450 --> 00:10:19,950
divide this by 2h, that'll
make it an h squared over six.
176
00:10:19,950 --> 00:10:22,440
I've done what looks
like a messy computation.
177
00:10:22,440 --> 00:10:26,800
I'm a little sad to start a
good lecture, important lecture
178
00:10:26,800 --> 00:10:29,140
by such grungy stuff.
179
00:10:29,140 --> 00:10:33,510
But it makes the key point.
180
00:10:33,510 --> 00:10:38,420
That the centered difference
gives the correct derivative
181
00:10:38,420 --> 00:10:41,860
with an error of order h^2.
182
00:10:41,860 --> 00:10:46,620
Where the error for
the first differences,
183
00:10:46,620 --> 00:10:49,500
the h would have been there.
184
00:10:49,500 --> 00:10:51,180
And we can test it.
185
00:10:51,180 --> 00:10:54,430
Actually we'll test it.
186
00:10:54,430 --> 00:10:55,290
Okay for that?
187
00:10:55,290 --> 00:10:57,420
This is first differences.
188
00:10:57,420 --> 00:10:59,580
And that's a big
question: what do you
189
00:10:59,580 --> 00:11:03,510
replace the first derivative
by if there is one?
190
00:11:03,510 --> 00:11:05,270
And you've got
these three choices.
191
00:11:05,270 --> 00:11:08,420
And usually this
is the best choice.
192
00:11:08,420 --> 00:11:10,990
Now to second derivatives.
193
00:11:10,990 --> 00:11:17,270
Because our equation
has got u'' in it.
194
00:11:17,270 --> 00:11:20,040
So what's a second derivative?
195
00:11:20,040 --> 00:11:23,000
It's the derivative
of the derivative.
196
00:11:23,000 --> 00:11:24,980
So what's the second difference?
197
00:11:24,980 --> 00:11:27,080
It's the difference,
first difference
198
00:11:27,080 --> 00:11:29,150
of the first difference.
199
00:11:29,150 --> 00:11:32,380
So the second difference,
the natural second difference
200
00:11:32,380 --> 00:11:36,360
would be-- so now
let me use this space
201
00:11:36,360 --> 00:11:39,510
for second differences.
202
00:11:39,510 --> 00:11:42,300
Second differences.
203
00:11:42,300 --> 00:11:46,270
I could take the
forward difference
204
00:11:46,270 --> 00:11:48,680
of the backward difference.
205
00:11:48,680 --> 00:11:51,090
Or I could take the
backward difference
206
00:11:51,090 --> 00:11:52,620
of the forward difference.
207
00:11:52,620 --> 00:11:55,780
Or you may say why don't I
take the centered difference
208
00:11:55,780 --> 00:11:57,110
of the centered difference.
209
00:11:57,110 --> 00:12:02,940
All those, in some sense
it's delta squared,
210
00:12:02,940 --> 00:12:05,720
but which to take?
211
00:12:05,720 --> 00:12:13,070
Well actually those are the
same and that's the good choice,
212
00:12:13,070 --> 00:12:16,520
that's the 1, -2, 1 choice.
213
00:12:16,520 --> 00:12:18,560
So let me show you that.
214
00:12:18,560 --> 00:12:20,270
Let me say what's
the matter with that.
215
00:12:20,270 --> 00:12:25,730
Because now having said how
great centered differences are,
216
00:12:25,730 --> 00:12:28,930
first differences, why
don't I just repeat them
217
00:12:28,930 --> 00:12:31,040
for second differences?
218
00:12:31,040 --> 00:12:35,520
Well the trouble is, let me say
in a word without even writing,
219
00:12:35,520 --> 00:12:40,320
well I could even write a
little, the center difference,
220
00:12:40,320 --> 00:12:43,510
suppose I'm at a
typical mesh point here.
221
00:12:43,510 --> 00:12:45,360
The center difference
is going to take
222
00:12:45,360 --> 00:12:48,220
that value minus that value.
223
00:12:48,220 --> 00:12:51,020
But then if I take the
center difference of that
224
00:12:51,020 --> 00:12:52,380
I'm going to be out here.
225
00:12:52,380 --> 00:12:56,150
I'm going to take this value,
this value, and this value.
226
00:12:56,150 --> 00:12:58,130
I'll get something correct.
227
00:12:58,130 --> 00:13:00,800
Its accuracy will be
second order, good.
228
00:13:00,800 --> 00:13:05,050
But it stretches too far.
229
00:13:05,050 --> 00:13:09,320
We want compact
difference molecules.
230
00:13:09,320 --> 00:13:15,330
We don't want this one, minus
two of this, plus one of that.
231
00:13:15,330 --> 00:13:22,470
So this would give
us a 1, 0, -2 , 0, 1.
232
00:13:22,470 --> 00:13:26,420
I'm just saying this and then
I'll never come back to it
233
00:13:26,420 --> 00:13:29,960
because I don't like
this one, these guys
234
00:13:29,960 --> 00:13:36,020
give 1, -2, 1 without any gaps.
235
00:13:36,020 --> 00:13:37,550
And that's the right choice.
236
00:13:37,550 --> 00:13:40,700
And that's the choice made here.
237
00:13:40,700 --> 00:13:45,800
So I'm not thinking you
can see it in your head,
238
00:13:45,800 --> 00:13:48,850
that the difference
of the difference--
239
00:13:48,850 --> 00:13:51,200
But well, you almost can.
240
00:13:51,200 --> 00:13:53,430
If I take this, yeah.
241
00:13:53,430 --> 00:13:56,360
Can you sort of see this
without my writing it?
242
00:13:56,360 --> 00:13:59,880
If I take the forward
difference and then
243
00:13:59,880 --> 00:14:06,480
I subtract the forward
difference to the left,
244
00:14:06,480 --> 00:14:08,450
do you see that
I'll have minus two.
245
00:14:08,450 --> 00:14:10,890
So there is what I started with.
246
00:14:10,890 --> 00:14:19,640
I subtract u(x) - U(x-h) and I
get two -u(x)'s This is what I
247
00:14:19,640 --> 00:14:22,170
get.
248
00:14:22,170 --> 00:14:23,870
Now I'm calling that u_i.
249
00:14:23,870 --> 00:14:29,600
250
00:14:29,600 --> 00:14:33,840
I better make completely
clear about the minus sign.
251
00:14:33,840 --> 00:14:36,030
The forward difference or
the backward difference,
252
00:14:36,030 --> 00:14:41,230
what this leads is 1, -2, 1.
253
00:14:41,230 --> 00:14:44,080
That's the second difference.
254
00:14:44,080 --> 00:14:48,900
Very important to remember, the
second difference of a function
255
00:14:48,900 --> 00:14:54,110
is the function, the value
ahead, minus two of the center,
256
00:14:54,110 --> 00:14:56,330
plus one of the left.
257
00:14:56,330 --> 00:14:59,610
It's centered obviously,
symmetric, right?
258
00:14:59,610 --> 00:15:02,630
Second differences
are symmetric.
259
00:15:02,630 --> 00:15:06,300
And because I want
a minus sign I
260
00:15:06,300 --> 00:15:09,000
want minus the second
difference and that's
261
00:15:09,000 --> 00:15:14,090
why you see here -1, 2, -1.
262
00:15:14,090 --> 00:15:18,070
Because I wanted
positive two there.
263
00:15:18,070 --> 00:15:18,880
Are you okay?
264
00:15:18,880 --> 00:15:26,740
This is the natural
replacement for -u''.
265
00:15:26,740 --> 00:15:29,885
And I claim that this
second difference
266
00:15:29,885 --> 00:15:34,220
is like the second
derivative, of course.
267
00:15:34,220 --> 00:15:36,600
And why don't we just
check some examples
268
00:15:36,600 --> 00:15:40,030
to see how like the
second derivative it is.
269
00:15:40,030 --> 00:15:41,780
So I'm going to take
the second difference
270
00:15:41,780 --> 00:15:47,560
of some easy functions.
271
00:15:47,560 --> 00:15:51,100
It's very important that
these come out so well.
272
00:15:51,100 --> 00:15:54,580
So I'm going to take
the second difference.
273
00:15:54,580 --> 00:15:56,840
I'm going to write it
as sort of a matrix.
274
00:15:56,840 --> 00:15:58,880
So this is like the
second difference.
275
00:15:58,880 --> 00:16:02,610
Yeah, because this is good.
276
00:16:02,610 --> 00:16:04,690
I'm inside the region, here.
277
00:16:04,690 --> 00:16:07,590
I'm not worried about
the boundaries now.
278
00:16:07,590 --> 00:16:09,700
Let me just think
of myself as inside.
279
00:16:09,700 --> 00:16:12,930
So I have second
differences and suppose
280
00:16:12,930 --> 00:16:18,280
I'm applying it to a
vector of all ones.
281
00:16:18,280 --> 00:16:22,440
What answer should I get?
282
00:16:22,440 --> 00:16:28,910
So if I think of calculus, it's
the second derivative of one,
283
00:16:28,910 --> 00:16:30,610
of the constant function.
284
00:16:30,610 --> 00:16:32,500
So what answer am
I going to get?
285
00:16:32,500 --> 00:16:33,050
Zero.
286
00:16:33,050 --> 00:16:34,320
And do I get zero?
287
00:16:34,320 --> 00:16:35,140
Of course.
288
00:16:35,140 --> 00:16:35,640
I get zero.
289
00:16:35,640 --> 00:16:36,890
Right?
290
00:16:36,890 --> 00:16:39,840
All these second
differences are zero.
291
00:16:39,840 --> 00:16:43,500
Because I'm not worrying
about the boundary yet.
292
00:16:43,500 --> 00:16:46,510
So that's like, check one.
293
00:16:46,510 --> 00:16:48,460
It passed that simple test.
294
00:16:48,460 --> 00:16:57,010
Now let me move up from
constant to linear.
295
00:16:57,010 --> 00:16:58,710
And so on.
296
00:16:58,710 --> 00:17:00,570
So let me apply
second differences
297
00:17:00,570 --> 00:17:04,440
to a vector that's
growing linearly.
298
00:17:04,440 --> 00:17:08,520
What answer do I
expect to get for that?
299
00:17:08,520 --> 00:17:11,210
So remember I'm doing
second differences,
300
00:17:11,210 --> 00:17:13,020
like second
derivatives, or minus
301
00:17:13,020 --> 00:17:16,880
second derivatives, actually.
302
00:17:16,880 --> 00:17:20,640
So what do second derivatives
do to a linear function?
303
00:17:20,640 --> 00:17:23,250
If I take a straight
line I take the-- sorry,
304
00:17:23,250 --> 00:17:25,170
second derivatives.
305
00:17:25,170 --> 00:17:29,470
If I take second derivatives
of a linear function I get?
306
00:17:29,470 --> 00:17:30,510
Zero, right.
307
00:17:30,510 --> 00:17:34,630
So I would hope to get
zero again here and I do.
308
00:17:34,630 --> 00:17:35,650
Right?
309
00:17:35,650 --> 00:17:36,150
-1+4-3=0.
310
00:17:36,150 --> 00:17:38,780
311
00:17:38,780 --> 00:17:44,270
Minus one, sorry, let
me do it here, -2+6-4.
312
00:17:44,270 --> 00:17:48,000
And actually, that's consistent
with our little Taylor series
313
00:17:48,000 --> 00:17:49,690
stuff.
314
00:17:49,690 --> 00:17:52,270
The function x should
come out right.
315
00:17:52,270 --> 00:17:55,180
Now what about-- now
comes the moment.
316
00:17:55,180 --> 00:17:57,140
What about x squared?
317
00:17:57,140 --> 00:18:00,220
So I'm going to
put squares in now.
318
00:18:00,220 --> 00:18:04,080
Do I expect to get zeroes?
319
00:18:04,080 --> 00:18:06,550
I don't think so.
320
00:18:06,550 --> 00:18:09,920
Because let me again
test it by thinking
321
00:18:09,920 --> 00:18:12,390
about what second derivative.
322
00:18:12,390 --> 00:18:18,360
So now I'm sort of copying
second derivative of x squared,
323
00:18:18,360 --> 00:18:20,470
which is?
324
00:18:20,470 --> 00:18:24,350
Second derivative
of x squared is?
325
00:18:24,350 --> 00:18:25,980
Two, right?
326
00:18:25,980 --> 00:18:29,200
First derivative's 2x, second
derivative is just two.
327
00:18:29,200 --> 00:18:31,170
So it's a constant.
328
00:18:31,170 --> 00:18:35,170
And remember I put in a
minus sign so I'm wondering,
329
00:18:35,170 --> 00:18:39,520
do I get the answer minus two?
330
00:18:39,520 --> 00:18:42,420
All the way down.
331
00:18:42,420 --> 00:18:43,020
-4+8-9.
332
00:18:43,020 --> 00:18:45,650
333
00:18:45,650 --> 00:18:47,940
Whoops.
334
00:18:47,940 --> 00:18:50,540
What's that?
335
00:18:50,540 --> 00:18:52,480
What do I get there?
336
00:18:52,480 --> 00:18:57,640
What do I get from that second
difference of these squares?
337
00:18:57,640 --> 00:19:00,640
-4+8-9 is?
338
00:19:00,640 --> 00:19:03,140
Minus two, good.
339
00:19:03,140 --> 00:19:04,831
So can we keep going?
340
00:19:04,831 --> 00:19:05,330
-4+18-16.
341
00:19:05,330 --> 00:19:08,650
342
00:19:08,650 --> 00:19:10,730
What's that?
343
00:19:10,730 --> 00:19:15,200
-4+18-16, so I've got -20+18.
344
00:19:15,200 --> 00:19:19,190
345
00:19:19,190 --> 00:19:21,330
I got minus two again.
346
00:19:21,330 --> 00:19:24,940
-9, 32, -25, it's right.
347
00:19:24,940 --> 00:19:32,670
The second differences
of the vector of squares,
348
00:19:32,670 --> 00:19:37,290
you could say, is a constant
vector with the right number.
349
00:19:37,290 --> 00:19:39,515
And that's because
that second difference
350
00:19:39,515 --> 00:19:41,260
is second order accurate.
351
00:19:41,260 --> 00:19:45,400
It not only got constants
right and linears right,
352
00:19:45,400 --> 00:19:48,860
it got quadratics right.
353
00:19:48,860 --> 00:19:52,910
So that's, you're seeing
second differences.
354
00:19:52,910 --> 00:19:57,060
We'll soon see that second
differences are also
355
00:19:57,060 --> 00:20:01,180
on the ball when you apply
them to other vectors.
356
00:20:01,180 --> 00:20:06,070
Like vectors of sines or vectors
of cosines or exponentials,
357
00:20:06,070 --> 00:20:08,150
they do well.
358
00:20:08,150 --> 00:20:12,890
So that's just a useful check
which will help us over here.
359
00:20:12,890 --> 00:20:17,220
Okay, can I come back to
the part of the lecture now?
360
00:20:17,220 --> 00:20:23,060
Having prepared
the way for this.
361
00:20:23,060 --> 00:20:26,270
Well, let's start right off
by solving the differential
362
00:20:26,270 --> 00:20:29,120
equation.
363
00:20:29,120 --> 00:20:33,650
So I'm bringing you back years
and years and years, right?
364
00:20:33,650 --> 00:20:38,160
Solve that differential
equation with these two boundary
365
00:20:38,160 --> 00:20:40,290
conditions.
366
00:20:40,290 --> 00:20:42,960
How would you do that
in a systematic way?
367
00:20:42,960 --> 00:20:45,250
You could almost
guess after a while,
368
00:20:45,250 --> 00:20:48,950
but systematically
if I have a linear,
369
00:20:48,950 --> 00:20:51,300
I notice-- What do I
notice about this thing?
370
00:20:51,300 --> 00:20:53,950
It's linear.
371
00:20:53,950 --> 00:20:55,410
So what am I expecting?
372
00:20:55,410 --> 00:20:58,530
I'm expecting, like,
a particular solution
373
00:20:58,530 --> 00:21:05,160
that gives the correct answer,
one, and some null space
374
00:21:05,160 --> 00:21:07,280
solution or whatever
I want to call it,
375
00:21:07,280 --> 00:21:11,290
homogeneous solution
that gives zero
376
00:21:11,290 --> 00:21:13,920
and has some arbitrary
constants in it.
377
00:21:13,920 --> 00:21:15,790
Give me a particular solution.
378
00:21:15,790 --> 00:21:18,100
So this is going
to be our answer.
379
00:21:18,100 --> 00:21:23,850
This'll be the general solution
to this differential equation.
380
00:21:23,850 --> 00:21:27,510
What functions have minus the
second derivative equal one,
381
00:21:27,510 --> 00:21:28,870
that's all I'm asking.
382
00:21:28,870 --> 00:21:30,980
What are they?
383
00:21:30,980 --> 00:21:33,400
So what is one of them?
384
00:21:33,400 --> 00:21:38,510
One function that has its
second derivative is a constant
385
00:21:38,510 --> 00:21:41,850
and that constant is minus one.
386
00:21:41,850 --> 00:21:44,410
So if I want the second
derivative to be a constant,
387
00:21:44,410 --> 00:21:47,400
what am I looking at? x squared.
388
00:21:47,400 --> 00:21:49,190
I'm looking at x squared.
389
00:21:49,190 --> 00:21:51,510
And I just want to
figure out how many x
390
00:21:51,510 --> 00:21:53,380
squareds to get a one.
391
00:21:53,380 --> 00:21:58,510
So some number of x squareds
and how many do I want?
392
00:21:58,510 --> 00:21:59,940
-1/2, good.
393
00:21:59,940 --> 00:22:01,410
Good.
394
00:22:01,410 --> 00:22:01,970
-1/2.
395
00:22:01,970 --> 00:22:04,030
Because x squared
would give me two
396
00:22:04,030 --> 00:22:07,860
but I want minus
one so I need -1/2.
397
00:22:07,860 --> 00:22:10,590
Okay that's the
particular solution.
398
00:22:10,590 --> 00:22:18,320
Now throw in all the solutions,
I can add in any solution
399
00:22:18,320 --> 00:22:20,420
that has a zero
on the right side,
400
00:22:20,420 --> 00:22:29,130
so what functions have second
derivatives equals zero?
401
00:22:29,130 --> 00:22:30,980
x is good.
402
00:22:30,980 --> 00:22:34,310
I'm looking for two because
it's a second derivative, second
403
00:22:34,310 --> 00:22:35,510
order equation.
404
00:22:35,510 --> 00:22:37,100
What's the other guy?
405
00:22:37,100 --> 00:22:38,480
Constant, good.
406
00:22:38,480 --> 00:22:43,590
So let me put the constant
first, C, say, and Dx.
407
00:22:43,590 --> 00:22:46,660
Two constants that I can
play with and what use
408
00:22:46,660 --> 00:22:49,140
am I going to make of them?
409
00:22:49,140 --> 00:22:52,710
I'm going to use those to
satisfy the two boundary
410
00:22:52,710 --> 00:22:56,270
conditions.
411
00:22:56,270 --> 00:23:00,830
And it won't be difficult.
You could say plug
412
00:23:00,830 --> 00:23:03,910
in the first boundary
condition, get
413
00:23:03,910 --> 00:23:05,880
an equation for the
constants, plug in
414
00:23:05,880 --> 00:23:07,950
the second, got
another equation,
415
00:23:07,950 --> 00:23:09,620
we'll have two
boundary conditions,
416
00:23:09,620 --> 00:23:11,790
two equations, two constants.
417
00:23:11,790 --> 00:23:15,050
Everything's going to come out.
418
00:23:15,050 --> 00:23:22,260
So if I plug in u(0)=0,
what do I learn?
419
00:23:22,260 --> 00:23:23,710
C is zero, right?
420
00:23:23,710 --> 00:23:25,720
If I plug in, is that right?
421
00:23:25,720 --> 00:23:28,500
If I plug in zero, then
that's zero already,
422
00:23:28,500 --> 00:23:32,190
this is zero already, so I
just learned that C is zero.
423
00:23:32,190 --> 00:23:36,720
So C is zero.
424
00:23:36,720 --> 00:23:42,320
So I'm down to one constant,
one unused boundary condition.
425
00:23:42,320 --> 00:23:43,550
Plug that in. u(1) = -1/2.
426
00:23:43,550 --> 00:23:48,550
427
00:23:48,550 --> 00:23:50,630
What's D?
428
00:23:50,630 --> 00:23:51,940
It's 1/2, right.
429
00:23:51,940 --> 00:23:54,290
D is 1/2.
430
00:23:54,290 --> 00:23:56,340
So can I close this up?
431
00:23:56,340 --> 00:23:58,920
There's 1/2.
432
00:23:58,920 --> 00:24:00,380
Dx is 1/2.
433
00:24:00,380 --> 00:24:03,450
Now it just always
pays to look back.
434
00:24:03,450 --> 00:24:06,100
At x=0, that's obviously zero.
435
00:24:06,100 --> 00:24:11,720
At x=1 it's zero because those
are the same and I get zero.
436
00:24:11,720 --> 00:24:14,170
So -1/2 x squared plus 1/2 x.
437
00:24:14,170 --> 00:24:19,950
438
00:24:19,950 --> 00:24:23,620
That's the kind of differential
equation and solution
439
00:24:23,620 --> 00:24:25,070
that we're looking for.
440
00:24:25,070 --> 00:24:28,850
Not complicated nonlinear stuff.
441
00:24:28,850 --> 00:24:35,480
So now I'm ready to move
to the difference equation.
442
00:24:35,480 --> 00:24:41,350
So again, this is a major step.
443
00:24:41,350 --> 00:24:46,780
I'll draw a picture of
this from zero to one.
444
00:24:46,780 --> 00:24:51,000
And if I graph that I think
I get a parabola, right?
445
00:24:51,000 --> 00:24:53,550
A parabola that has
to go through here.
446
00:24:53,550 --> 00:24:56,940
So it's some parabola like that.
447
00:24:56,940 --> 00:25:01,540
That would be always good, to
draw a graph of the solution.
448
00:25:01,540 --> 00:25:03,790
Now, what do I get here?
449
00:25:03,790 --> 00:25:06,260
Moving to the
difference equation.
450
00:25:06,260 --> 00:25:12,480
So that's the equation, and
notice its boundary conditions.
451
00:25:12,480 --> 00:25:15,540
Those boundary conditions
just copied this one
452
00:25:15,540 --> 00:25:20,160
because I've chopped this up.
453
00:25:20,160 --> 00:25:26,920
I've got i = 1, 2, 3,
4, 5, and this is one,
454
00:25:26,920 --> 00:25:31,530
the last point then is 6h.
455
00:25:31,530 --> 00:25:32,320
h is 1/6.
456
00:25:32,320 --> 00:25:35,080
457
00:25:35,080 --> 00:25:37,450
What's going to be
the size of my matrix
458
00:25:37,450 --> 00:25:41,600
and my vector and
my unknown u here?
459
00:25:41,600 --> 00:25:43,390
How many unknowns
am I going to have?
460
00:25:43,390 --> 00:25:46,344
Let's just get the
overall picture right.
461
00:25:46,344 --> 00:25:47,760
What are the
unknowns going to be?
462
00:25:47,760 --> 00:25:49,593
They're going to be
u_1, u_2, u_3, u_4, u_5.
463
00:25:49,593 --> 00:25:51,930
464
00:25:51,930 --> 00:25:52,700
Those are unknown.
465
00:25:52,700 --> 00:25:54,360
Those will be some
values, I don't
466
00:25:54,360 --> 00:25:58,980
know where, maybe something
like this because they'll
467
00:25:58,980 --> 00:26:01,060
be sort of like that one.
468
00:26:01,060 --> 00:26:06,430
And this is not an unknown, u_6;
this is not an unknown, u_0;
469
00:26:06,430 --> 00:26:08,350
those are the ones we know.
470
00:26:08,350 --> 00:26:14,390
So this is what the solution
to a difference equation
471
00:26:14,390 --> 00:26:15,180
looks like.
472
00:26:15,180 --> 00:26:18,480
It gives you a discrete
set of unknowns.
473
00:26:18,480 --> 00:26:20,990
And then, of course
MATLAB or any code
474
00:26:20,990 --> 00:26:24,020
could connect them
up by straight lines
475
00:26:24,020 --> 00:26:28,410
and give you a function.
476
00:26:28,410 --> 00:26:33,630
But the heart of it
is these five values.
477
00:26:33,630 --> 00:26:38,890
Okay, good.
478
00:26:38,890 --> 00:26:44,400
And those five values
come from these equations.
479
00:26:44,400 --> 00:26:46,440
I'm introducing
this subscript stuff
480
00:26:46,440 --> 00:26:49,960
but I won't need it all the time
because you'll see the picture.
481
00:26:49,960 --> 00:26:56,250
This equation applies for
i equal one up to five.
482
00:26:56,250 --> 00:27:01,280
Five inside points and then
you notice how when i is one,
483
00:27:01,280 --> 00:27:04,310
this needs u_0, but we know u_0.
484
00:27:04,310 --> 00:27:08,910
And when i is five, this
needs u_6, but we know u_6.
485
00:27:08,910 --> 00:27:12,300
So it's a closed
five by five system
486
00:27:12,300 --> 00:27:17,220
and it will be our matrix.
487
00:27:17,220 --> 00:27:21,050
That -1, 2, -1 is what
sits on the matrix.
488
00:27:21,050 --> 00:27:24,490
When we close it with the
two boundary conditions
489
00:27:24,490 --> 00:27:28,190
it chops off the
zero column, you
490
00:27:28,190 --> 00:27:30,510
could say and chops
off the six column
491
00:27:30,510 --> 00:27:37,650
and leaves us with a five
by five problem and yeah.
492
00:27:37,650 --> 00:27:44,300
I guess this is a step not
to jump past because it
493
00:27:44,300 --> 00:27:48,370
takes a little practice.
494
00:27:48,370 --> 00:27:51,270
You see I've written
the same thing two ways.
495
00:27:51,270 --> 00:27:53,080
Let me write it a third way.
496
00:27:53,080 --> 00:27:55,270
Let me write it out clearly.
497
00:27:55,270 --> 00:27:59,210
So now here I'm going to
complete this matrix with a two
498
00:27:59,210 --> 00:28:04,370
and a minus one and a two and
a minus one and now it's five
499
00:28:04,370 --> 00:28:05,550
by five.
500
00:28:05,550 --> 00:28:09,480
And those might
be u, but I don't
501
00:28:09,480 --> 00:28:18,650
know if they are, so let me put
in u_1, u_2, u_3, u_4, and u_5.
502
00:28:18,650 --> 00:28:23,200
503
00:28:23,200 --> 00:28:26,700
Oh and divide by h squared.
504
00:28:26,700 --> 00:28:31,160
I'll often forget that.
505
00:28:31,160 --> 00:28:32,740
So I'm asking you
to see something
506
00:28:32,740 --> 00:28:35,530
that if you haven't, after
you get the hang of it
507
00:28:35,530 --> 00:28:38,070
it's like, automatic.
508
00:28:38,070 --> 00:28:40,261
But I have to remember
it's not automatic.
509
00:28:40,261 --> 00:28:41,760
Things aren't
automatic until you've
510
00:28:41,760 --> 00:28:43,150
done them a couple of times.
511
00:28:43,150 --> 00:28:53,430
So do you see that that is a
concrete statement of this?
512
00:28:53,430 --> 00:28:56,720
This delta x squared
is the h squared.
513
00:28:56,720 --> 00:28:59,850
And do you see those
differences when
514
00:28:59,850 --> 00:29:04,290
I do that multiplication that
they produce those differences?
515
00:29:04,290 --> 00:29:07,300
And now, what's my
right-hand side?
516
00:29:07,300 --> 00:29:12,720
Well I've changed the right-hand
side to one to make it easy.
517
00:29:12,720 --> 00:29:17,400
So this right-hand
side is all ones.
518
00:29:17,400 --> 00:29:25,660
And this is the problem
that MATLAB would solve
519
00:29:25,660 --> 00:29:27,800
or whatever code.
520
00:29:27,800 --> 00:29:30,330
Find a difference code.
521
00:29:30,330 --> 00:29:34,900
I've got to a linear
system, five by five,
522
00:29:34,900 --> 00:29:39,640
it's fortunately-- the
matrix is not singular,
523
00:29:39,640 --> 00:29:44,020
there is a solution.
524
00:29:44,020 --> 00:29:45,400
How does MATLAB find it?
525
00:29:45,400 --> 00:29:50,540
It does not find it by finding
the inverse of that matrix.
526
00:29:50,540 --> 00:29:53,320
Monday's lecture
will quickly review
527
00:29:53,320 --> 00:29:58,720
how to solve five equations
and five unknowns.
528
00:29:58,720 --> 00:30:02,440
It's by elimination, I'll
tell you the key word.
529
00:30:02,440 --> 00:30:05,380
And that's what every code does.
530
00:30:05,380 --> 00:30:08,320
And sometimes you would
have to exchange rows,
531
00:30:08,320 --> 00:30:10,990
but not for a positive
definite matrix like that.
532
00:30:10,990 --> 00:30:13,260
It'll just go bzzz,
right through.
533
00:30:13,260 --> 00:30:17,990
When it's tridiagonal it'll go
like with the speed of light
534
00:30:17,990 --> 00:30:20,010
and you'll get the answer.
535
00:30:20,010 --> 00:30:23,012
And those five answers will
be these five heights. u_1,
536
00:30:23,012 --> 00:30:23,970
u_2, u_3, u_4, and u_5.
537
00:30:23,970 --> 00:30:29,160
538
00:30:29,160 --> 00:30:31,520
And we could figure it out.
539
00:30:31,520 --> 00:30:35,430
Actually I think section
1.2 gives the formula
540
00:30:35,430 --> 00:30:41,260
for this particular model
problem for any size,
541
00:30:41,260 --> 00:30:44,380
in particular for five by five.
542
00:30:44,380 --> 00:30:55,440
And there is something
wonderful for this special case.
543
00:30:55,440 --> 00:31:00,230
The five points fall right
on the correct parabola,
544
00:31:00,230 --> 00:31:01,910
they're exactly right.
545
00:31:01,910 --> 00:31:06,310
So for this particular case when
the solution was a quadratic,
546
00:31:06,310 --> 00:31:09,830
the exact solution was
a quadratic, a parabola,
547
00:31:09,830 --> 00:31:14,540
it will turn out-- and
that quadratic matches
548
00:31:14,540 --> 00:31:17,210
these boundary conditions,
it will turn out
549
00:31:17,210 --> 00:31:25,410
that those points are
right on the money.
550
00:31:25,410 --> 00:31:27,970
So that's, you
could call, is like,
551
00:31:27,970 --> 00:31:29,510
super-convergence or something.
552
00:31:29,510 --> 00:31:32,680
I mean that won't
happen every time,
553
00:31:32,680 --> 00:31:39,740
otherwise life would
be like, too easy.
554
00:31:39,740 --> 00:31:46,360
It's a good life, but it's
not that good as a rule.
555
00:31:46,360 --> 00:31:56,360
So they fall right
on that curve.
556
00:31:56,360 --> 00:31:59,820
And we can say what
those numbers are.
557
00:31:59,820 --> 00:32:01,790
Actually, we know what they are.
558
00:32:01,790 --> 00:32:03,860
Actually, I guess
I could find them.
559
00:32:03,860 --> 00:32:09,940
What are those numbers then?
560
00:32:09,940 --> 00:32:12,300
And of course,
one over h squared
561
00:32:12,300 --> 00:32:16,140
is-- What's one over h
squared, just to not forget?
562
00:32:16,140 --> 00:32:20,870
One over h squared
there, h is what?
563
00:32:20,870 --> 00:32:22,400
1/6.
564
00:32:22,400 --> 00:32:24,430
Squared, it's going to be a 36.
565
00:32:24,430 --> 00:32:30,040
So if I bring it up here,
bring the h squared up here,
566
00:32:30,040 --> 00:32:33,570
it would be times a 36.
567
00:32:33,570 --> 00:32:37,680
Well let me leave it here, 36.
568
00:32:37,680 --> 00:32:41,050
And I'm just saying that these
numbers would come out right.
569
00:32:41,050 --> 00:32:42,970
Maybe I'll just
do the first one.
570
00:32:42,970 --> 00:32:45,570
What's the exact u_1, u_2?
571
00:32:45,570 --> 00:32:48,370
u_1 and u_2 would be what?
572
00:32:48,370 --> 00:32:51,160
The exact u_1, ooh!
573
00:32:51,160 --> 00:32:53,920
Oh shoot, I've got
to figure it out.
574
00:32:53,920 --> 00:32:58,280
If I plug in x=1/6...
575
00:32:58,280 --> 00:33:04,460
Do we want to do this?
576
00:33:04,460 --> 00:33:05,980
Plug in x=1/6?
577
00:33:05,980 --> 00:33:08,310
No, we don't.
578
00:33:08,310 --> 00:33:08,840
We don't.
579
00:33:08,840 --> 00:33:11,370
We've got something better
to do with our lives.
580
00:33:11,370 --> 00:33:14,740
But if we put that
number in, whatever
581
00:33:14,740 --> 00:33:19,460
the heck it is, in this one, we
would find out came out right.
582
00:33:19,460 --> 00:33:22,580
The fact that it comes
out right is important.
583
00:33:22,580 --> 00:33:34,430
But I'd like to move on
to a similar problem.
584
00:33:34,430 --> 00:33:38,400
But this one is going
to be free-fixed.
585
00:33:38,400 --> 00:33:44,850
So if this problem was like
having an elastic bar hanging
586
00:33:44,850 --> 00:33:47,340
under its own weight
and these would
587
00:33:47,340 --> 00:33:53,390
be the displacements points on
the bar and fixed at the ends,
588
00:33:53,390 --> 00:33:56,410
now I'm freeing up the top end.
589
00:33:56,410 --> 00:34:02,250
I'm not making u_0 zero anymore.
590
00:34:02,250 --> 00:34:05,410
I better maybe use a
different blackboard
591
00:34:05,410 --> 00:34:12,010
because that's so important
that I don't want to erase it.
592
00:34:12,010 --> 00:34:20,850
So let me take the same problem,
uniform bar, uniform load,
593
00:34:20,850 --> 00:34:27,400
but I'm going to fix
u(1), that's fixed,
594
00:34:27,400 --> 00:34:30,160
but I'm going to free this end.
595
00:34:30,160 --> 00:34:32,450
And from a differential
equation point of view,
596
00:34:32,450 --> 00:34:39,001
that means I'm going to set
the slope at zero to be zero.
597
00:34:39,001 --> 00:34:39,500
u'(0)=0.
598
00:34:39,500 --> 00:34:44,930
599
00:34:44,930 --> 00:34:48,130
That's going to have
a different solution.
600
00:34:48,130 --> 00:34:51,000
Change the boundary conditions
is going to change the answer.
601
00:34:51,000 --> 00:34:52,470
Let's find the solution.
602
00:34:52,470 --> 00:34:56,000
So here's another
differential equation.
603
00:34:56,000 --> 00:34:58,330
Same equation, different
boundary conditions,
604
00:34:58,330 --> 00:35:00,680
so how do we go?
605
00:35:00,680 --> 00:35:04,170
Well I had the general
solution over there.
606
00:35:04,170 --> 00:35:10,570
It still works, right? u(x)
is still -1/2 of x squared.
607
00:35:10,570 --> 00:35:13,690
The particular solution
that gives me the one.
608
00:35:13,690 --> 00:35:19,300
Plus the Cx plus D that
gives me zero and zero
609
00:35:19,300 --> 00:35:22,120
for second derivatives
but gives me
610
00:35:22,120 --> 00:35:27,220
the possibility to satisfy
the two boundary conditions.
611
00:35:27,220 --> 00:35:29,760
And now again, plug in
the boundary conditions
612
00:35:29,760 --> 00:35:35,380
to find C and D.
Slope is 0 at 0.
613
00:35:35,380 --> 00:35:37,960
What does that tell me?
614
00:35:37,960 --> 00:35:39,450
I have to plug that in.
615
00:35:39,450 --> 00:35:43,190
Here's my solution, I have
to take its derivative
616
00:35:43,190 --> 00:35:46,620
and set x to zero.
617
00:35:46,620 --> 00:35:50,410
So its derivative
is a 2x or a minus x
618
00:35:50,410 --> 00:35:53,560
or something which is zero.
619
00:35:53,560 --> 00:36:00,390
The derivative of that is C and
the derivative of that is zero.
620
00:36:00,390 --> 00:36:03,500
What am I learning from
that left, the free boundary
621
00:36:03,500 --> 00:36:06,690
condition?
622
00:36:06,690 --> 00:36:08,820
C is zero, right?
623
00:36:08,820 --> 00:36:11,730
C is zero because
the slope here is C
624
00:36:11,730 --> 00:36:12,980
and it's supposed to be zero.
625
00:36:12,980 --> 00:36:16,210
So C is zero.
626
00:36:16,210 --> 00:36:19,070
Now the other
boundary condition.
627
00:36:19,070 --> 00:36:21,880
Plug in x=1.
628
00:36:21,880 --> 00:36:24,840
I want to get the answer zero.
629
00:36:24,840 --> 00:36:32,090
The answer I do get is -1/2 at
x=1, plus D. So what is D then?
630
00:36:32,090 --> 00:36:33,150
What's D?
631
00:36:33,150 --> 00:36:36,740
Let me raise that.
632
00:36:36,740 --> 00:36:40,320
What do I learn about D?
633
00:36:40,320 --> 00:36:43,680
It's 1/2.
634
00:36:43,680 --> 00:36:45,180
I need 1/2.
635
00:36:45,180 --> 00:36:57,980
So the answer is -1/2
of x squared plus 1/2.
636
00:36:57,980 --> 00:37:04,940
Not 1/2 x as it was
over there, but 1/2.
637
00:37:04,940 --> 00:37:06,250
And now let's graph it.
638
00:37:06,250 --> 00:37:08,350
Always pays to
graph these things
639
00:37:08,350 --> 00:37:12,760
between x equals zero and one.
640
00:37:12,760 --> 00:37:15,690
What does this looks like?
641
00:37:15,690 --> 00:37:17,550
It starts at 1/2, right?
642
00:37:17,550 --> 00:37:19,730
At x=0.
643
00:37:19,730 --> 00:37:21,680
And it's a parabola, right?
644
00:37:21,680 --> 00:37:22,610
It's a parabola.
645
00:37:22,610 --> 00:37:24,820
And I know it goes
through this point.
646
00:37:24,820 --> 00:37:28,970
What else do I know?
647
00:37:28,970 --> 00:37:32,250
Slope starts at?
648
00:37:32,250 --> 00:37:33,760
The slope starts at zero.
649
00:37:33,760 --> 00:37:35,470
The other, the
boundary condition,
650
00:37:35,470 --> 00:37:37,800
the free condition
at the left-hand end,
651
00:37:37,800 --> 00:37:42,530
so slope starts at zero, so the
parabola comes down like that.
652
00:37:42,530 --> 00:37:45,430
It's like half
a-- where that was
653
00:37:45,430 --> 00:37:51,160
a symmetric bit of a parabola,
this is just half of it.
654
00:37:51,160 --> 00:37:56,670
The slope is zero.
655
00:37:56,670 --> 00:38:00,090
And so that's a graph of u(x) .
656
00:38:00,090 --> 00:38:07,370
Now I'm ready to replace it
by a difference equation.
657
00:38:07,370 --> 00:38:09,440
So what'll be the
difference equation?
658
00:38:09,440 --> 00:38:13,780
It'll be the same
equation for the -u''.
659
00:38:13,780 --> 00:38:16,880
No change.
660
00:38:16,880 --> 00:38:25,620
So minus u_(i+1) minus 2u_i,
minus u_(i-1) over h squared
661
00:38:25,620 --> 00:38:34,650
equals-- I'm taking f(x) to be
one, so let's stay with one.
662
00:38:34,650 --> 00:38:38,390
Okay, big moment.
663
00:38:38,390 --> 00:38:40,930
What boundary conditions?
664
00:38:40,930 --> 00:38:42,560
What boundary conditions?
665
00:38:42,560 --> 00:38:45,700
Well, this guy is pretty clear.
666
00:38:45,700 --> 00:38:51,760
That says u_(n+1) is zero.
667
00:38:51,760 --> 00:38:55,790
What do I do for zero slope?
668
00:38:55,790 --> 00:38:57,480
What do I do for a zero slope?
669
00:38:57,480 --> 00:39:00,200
Okay, let me suggest
one possibility.
670
00:39:00,200 --> 00:39:05,520
It's not the greatest, but one
possibility for zero slope is
671
00:39:05,520 --> 00:39:11,800
(u_1-u_0)/h -- that's
the approximate slope --
672
00:39:11,800 --> 00:39:14,660
should be zero.
673
00:39:14,660 --> 00:39:21,460
So that's my choice for the
left-hand boundary condition.
674
00:39:21,460 --> 00:39:24,820
It says u_1 is u_0 .
675
00:39:24,820 --> 00:39:28,390
It says that u_1 is u_0 .
676
00:39:28,390 --> 00:39:37,592
So now I've got
again five equations
677
00:39:37,592 --> 00:39:39,550
for five unknowns, u_1,
u_2, u_3, u_4, and u_5.
678
00:39:39,550 --> 00:39:44,930
679
00:39:44,930 --> 00:39:46,640
I'll write down what they are.
680
00:39:46,640 --> 00:39:49,960
Well, you know what they are.
681
00:39:49,960 --> 00:39:52,910
So this thing
divided by h squared
682
00:39:52,910 --> 00:39:57,970
is all ones, just like before.
683
00:39:57,970 --> 00:40:05,210
And of course all these
rows are not changed.
684
00:40:05,210 --> 00:40:07,860
But the first row is changed
because we have a new boundary
685
00:40:07,860 --> 00:40:09,880
condition at the left end.
686
00:40:09,880 --> 00:40:11,620
And it's this.
687
00:40:11,620 --> 00:40:14,130
So u_1, well u_0
isn't in the picture,
688
00:40:14,130 --> 00:40:19,900
but previously what
happened to u_0, when
689
00:40:19,900 --> 00:40:22,180
i is one, I'm in the
first equation here,
690
00:40:22,180 --> 00:40:24,590
that's where I'm
looking. i is one.
691
00:40:24,590 --> 00:40:26,210
It had a u_0.
692
00:40:26,210 --> 00:40:28,190
Gone.
693
00:40:28,190 --> 00:40:34,800
In this case it's not gone.
u_0 comes back in, u_0 is u_1.
694
00:40:34,800 --> 00:40:36,600
That might-- Ooh!
695
00:40:36,600 --> 00:40:38,090
Don't let me do this wrong.
696
00:40:38,090 --> 00:40:38,590
Ah!
697
00:40:38,590 --> 00:40:42,350
Don't let me do it worse!
698
00:40:42,350 --> 00:40:43,140
All right.
699
00:40:43,140 --> 00:40:43,780
There we go.
700
00:40:43,780 --> 00:40:44,280
Good.
701
00:40:44,280 --> 00:40:47,820
Okay.
702
00:40:47,820 --> 00:40:52,580
Please, last time I
videotaped lecture 10
703
00:40:52,580 --> 00:40:56,310
had to fix up lecture 9,
because I don't go in.
704
00:40:56,310 --> 00:40:59,720
Professor Lewin in the
physics lectures, he cheats,
705
00:40:59,720 --> 00:41:03,760
doesn't cheat, but he goes
into the lectures afterwards
706
00:41:03,760 --> 00:41:05,340
and fixes them.
707
00:41:05,340 --> 00:41:10,920
But you get exactly
what it looks like.
708
00:41:10,920 --> 00:41:13,160
So now it's fixed, I hope.
709
00:41:13,160 --> 00:41:16,830
But don't let me screw up.
710
00:41:16,830 --> 00:41:22,320
So now, what's on this top row?
711
00:41:22,320 --> 00:41:23,260
When i is one.
712
00:41:23,260 --> 00:41:26,710
I have minus u_2, that's fine.
713
00:41:26,710 --> 00:41:31,590
I have 2u_1 as before,
but now I have a minus
714
00:41:31,590 --> 00:41:34,390
u_1 because u_0 and
u_1 are the same.
715
00:41:34,390 --> 00:41:37,100
So I just have a one in there.
716
00:41:37,100 --> 00:41:42,810
That's our matrix that we called
T. The top row is changed,
717
00:41:42,810 --> 00:41:44,430
the top row is free.
718
00:41:44,430 --> 00:41:48,910
This is the equation T
times u divided by h squared
719
00:41:48,910 --> 00:41:57,170
is the right-hand side, ones.
ones(5), I would call that.
720
00:41:57,170 --> 00:42:00,430
Properly I would
call it ones(5, 1),
721
00:42:00,430 --> 00:42:04,410
because the MATLAB command
'ones' wants matrix
722
00:42:04,410 --> 00:42:08,990
and it's a matrix with
five rows, one column.
723
00:42:08,990 --> 00:42:12,940
But it's T, that's
the important thing.
724
00:42:12,940 --> 00:42:20,970
And would you like to guess
what the solution looks like?
725
00:42:20,970 --> 00:42:25,520
In particular, is it
again exactly right?
726
00:42:25,520 --> 00:42:29,460
Is it right on the money?
727
00:42:29,460 --> 00:42:35,790
Or if not, why not?
728
00:42:35,790 --> 00:42:38,610
The computer will
tell us, of course.
729
00:42:38,610 --> 00:42:41,390
It will tell us whether we
get agreement with this.
730
00:42:41,390 --> 00:42:48,060
This is the exact solution here
and this is the exact parabola
731
00:42:48,060 --> 00:42:51,720
starting with zero slope.
732
00:42:51,720 --> 00:42:54,430
So but I solved this problem.
733
00:42:54,430 --> 00:42:58,252
Oh, let me see, I didn't get
u_1, u_2 to u_5 in there.
734
00:42:58,252 --> 00:43:00,460
So it didn't look right.
u_1, u_2, u_3, u_4, and u_5.
735
00:43:00,460 --> 00:43:04,830
736
00:43:04,830 --> 00:43:06,390
And that's the right-hand side.
737
00:43:06,390 --> 00:43:08,250
Sorry about that.
738
00:43:08,250 --> 00:43:12,310
So that's T divided
by h squared.
739
00:43:12,310 --> 00:43:19,090
T, with that top row changed,
times U is the right-hand side.
740
00:43:19,090 --> 00:43:23,960
By the way, I
better just say what
741
00:43:23,960 --> 00:43:30,990
was the reason that we came out
exactly right on this problem?
742
00:43:30,990 --> 00:43:35,050
Would we come out exactly right
if it was some general load
743
00:43:35,050 --> 00:43:36,910
f(x)?
744
00:43:36,910 --> 00:43:38,120
No.
745
00:43:38,120 --> 00:43:42,240
Finite differences
can't do miracles.
746
00:43:42,240 --> 00:43:44,820
They have no way to know
what's happening to f(x)
747
00:43:44,820 --> 00:43:47,760
between the mesh points, right?
748
00:43:47,760 --> 00:43:52,860
If I took this to be f(x) and
took this at the five points,
749
00:43:52,860 --> 00:43:55,770
at these five
points, this wouldn't
750
00:43:55,770 --> 00:44:00,590
know what f(x) is in between,
couldn't be exactly right.
751
00:44:00,590 --> 00:44:05,900
It's exactly right in
this lucky special case
752
00:44:05,900 --> 00:44:11,070
because, of course,
it has the right ones.
753
00:44:11,070 --> 00:44:14,460
But also because, the
reason it's exactly right
754
00:44:14,460 --> 00:44:19,670
is that second differences of
quadratics are exactly right.
755
00:44:19,670 --> 00:44:24,740
That's what we checked on this
board that's underneath there.
756
00:44:24,740 --> 00:44:29,420
Second differences of
squares came out perfectly.
757
00:44:29,420 --> 00:44:33,830
And that's why the second
differences of this guy
758
00:44:33,830 --> 00:44:37,980
give the right
answer, so that guy
759
00:44:37,980 --> 00:44:41,610
is the answer to both the
differential and the difference
760
00:44:41,610 --> 00:44:43,960
equation.
761
00:44:43,960 --> 00:44:46,710
I had to say that word about
why was that exactly right.
762
00:44:46,710 --> 00:44:49,390
It was exactly right because
second differences of squares
763
00:44:49,390 --> 00:44:50,720
are exactly right.
764
00:44:50,720 --> 00:44:53,770
Now, again, we have second
differences of squares.
765
00:44:53,770 --> 00:44:57,915
So you could say
exactly right or no?
766
00:44:57,915 --> 00:44:58,790
What are you betting?
767
00:44:58,790 --> 00:45:03,260
How many think, yeah, it's going
to come out on the parabola?
768
00:45:03,260 --> 00:45:04,450
Nobody.
769
00:45:04,450 --> 00:45:06,590
Right.
770
00:45:06,590 --> 00:45:10,110
Everybody thinks there's
something going to miss here.
771
00:45:10,110 --> 00:45:11,690
And why?
772
00:45:11,690 --> 00:45:14,340
Why am I going to
miss something?
773
00:45:14,340 --> 00:45:17,530
Yes?
774
00:45:17,530 --> 00:45:20,490
It's a first-order approximation
at the left boundary.
775
00:45:20,490 --> 00:45:22,690
Exactly right, exactly right.
776
00:45:22,690 --> 00:45:26,890
It's a first-order
approximation to take this
777
00:45:26,890 --> 00:45:29,600
and I'm not going
to get it right.
778
00:45:29,600 --> 00:45:33,140
That first-order approximation,
that error of size h
779
00:45:33,140 --> 00:45:39,400
is going to penetrate
over the whole interval.
780
00:45:39,400 --> 00:45:40,430
It'll be biggest here.
781
00:45:40,430 --> 00:45:43,250
Actually I think it turns
out, and the book has a graph,
782
00:45:43,250 --> 00:45:47,960
I think it comes out
wrong by 1/2 h there.
783
00:45:47,960 --> 00:45:49,640
1/2 h, first order.
784
00:45:49,640 --> 00:45:53,770
And then it, of
course, it's discrete
785
00:45:53,770 --> 00:45:56,070
and of course it's straight
across because that's
786
00:45:56,070 --> 00:45:57,830
the boundary condition, right?
787
00:45:57,830 --> 00:46:03,750
And then it starts down, it gets
sort of closer, closer, closer
788
00:46:03,750 --> 00:46:06,280
and gets, of course,
that's right at the end.
789
00:46:06,280 --> 00:46:08,850
But there's an error.
790
00:46:08,850 --> 00:46:15,970
The difference between u, the
true u, and the computed u
791
00:46:15,970 --> 00:46:22,680
is of order h.
792
00:46:22,680 --> 00:46:28,340
So you could say alright, if h
is small I can live with that.
793
00:46:28,340 --> 00:46:32,150
But as I said in
the end you really
794
00:46:32,150 --> 00:46:34,650
want to get second order
accuracy if you can.
795
00:46:34,650 --> 00:46:36,380
And in a simple
problem like this
796
00:46:36,380 --> 00:46:39,320
we should be able to do it.
797
00:46:39,320 --> 00:46:44,630
What I've done already
covers section 1.2
798
00:46:44,630 --> 00:46:48,120
but then there's a
note, a worked example
799
00:46:48,120 --> 00:46:56,820
at the end of 1.2 that tells you
how to upgrade to second order.
800
00:46:56,820 --> 00:47:00,860
And maybe we've got a moment
to see how would we do it.
801
00:47:00,860 --> 00:47:04,230
What would you suggest
that I do differently?
802
00:47:04,230 --> 00:47:07,290
I'll get a different matrix.
803
00:47:07,290 --> 00:47:09,640
I'll get a different
discrete problem.
804
00:47:09,640 --> 00:47:10,860
But that'll be okay.
805
00:47:10,860 --> 00:47:12,930
I can solve that just as well.
806
00:47:12,930 --> 00:47:16,910
And what shall I
replace that by?
807
00:47:16,910 --> 00:47:19,480
because that was the
guilty party, as you said.
808
00:47:19,480 --> 00:47:21,270
That was guilty.
809
00:47:21,270 --> 00:47:23,400
That's only a first
order approximation
810
00:47:23,400 --> 00:47:28,670
to zero slope at zero.
811
00:47:28,670 --> 00:47:30,510
A couple of ways we could go.
812
00:47:30,510 --> 00:47:33,920
This is a correct second
order approximation
813
00:47:33,920 --> 00:47:38,070
at what mesh point?
814
00:47:38,070 --> 00:47:44,060
That is a correct second order
approximation to u'=0, but not
815
00:47:44,060 --> 00:47:48,470
at that point or at
that point where?
816
00:47:48,470 --> 00:47:50,760
Halfway between.
817
00:47:50,760 --> 00:47:52,550
If I was looking
at a point halfway
818
00:47:52,550 --> 00:47:54,970
between that, that
would be centered there,
819
00:47:54,970 --> 00:47:56,580
that would be a
centered difference
820
00:47:56,580 --> 00:47:57,640
and it would be good.
821
00:47:57,640 --> 00:48:00,350
But we're not looking there.
822
00:48:00,350 --> 00:48:02,280
So I'm looking here.
823
00:48:02,280 --> 00:48:06,980
So what do you suggest I do?
824
00:48:06,980 --> 00:48:10,880
Well I've got to center it.
825
00:48:10,880 --> 00:48:12,900
Essentially I'm
going to use u_(-1).
826
00:48:12,900 --> 00:48:15,990
827
00:48:15,990 --> 00:48:17,420
I'm going to use u_(-1).
828
00:48:17,420 --> 00:48:23,050
And let me just say
what the effect is.
829
00:48:23,050 --> 00:48:27,920
You remember we started with
the usual second difference
830
00:48:27,920 --> 00:48:31,730
here, 2, -1, -1.
831
00:48:31,730 --> 00:48:34,670
This is what got chopped
off for the fixed method.
832
00:48:34,670 --> 00:48:37,990
It got brought back here
by our first order method.
833
00:48:37,990 --> 00:48:41,570
Our second order
method will-- You
834
00:48:41,570 --> 00:48:43,900
see what's likely to happen?
835
00:48:43,900 --> 00:48:48,300
That minus one is
going to show up where?
836
00:48:48,300 --> 00:48:50,780
Over here.
837
00:48:50,780 --> 00:48:52,530
To center it around zero.
838
00:48:52,530 --> 00:48:59,300
So that guy will make
this into a minus two.
839
00:48:59,300 --> 00:49:03,490
Now that matrix is still fine.
840
00:49:03,490 --> 00:49:07,520
It's not one of our
special matrices.
841
00:49:07,520 --> 00:49:10,050
When I say fine, it's
not beautiful is it?
842
00:49:10,050 --> 00:49:17,640
It's got one, like,
flaw, it needs
843
00:49:17,640 --> 00:49:20,470
what do you call it when
you have your face--
844
00:49:20,470 --> 00:49:22,990
cosmetic surgery or something.
845
00:49:22,990 --> 00:49:25,350
It needs a small improvement.
846
00:49:25,350 --> 00:49:27,960
So what's the matter with it?
847
00:49:27,960 --> 00:49:30,770
It's not symmetric.
848
00:49:30,770 --> 00:49:33,060
It's not symmetric
and a person isn't
849
00:49:33,060 --> 00:49:36,630
happy with a un-symmetric
problem, approximation
850
00:49:36,630 --> 00:49:38,810
to a perfectly symmetric thing.
851
00:49:38,810 --> 00:49:41,850
So I could just divide
that row by two.
852
00:49:41,850 --> 00:49:46,020
If I divide that row by 2, which
you won't mind if I do that,
853
00:49:46,020 --> 00:49:50,900
make that one, minus
one and makes this 1/2.
854
00:49:50,900 --> 00:49:55,020
I divided the first
equation by two.
855
00:49:55,020 --> 00:50:02,960
Look in the notes in
the text if you can.
856
00:50:02,960 --> 00:50:05,870
And the result is
now it's right on.
857
00:50:05,870 --> 00:50:07,470
It's exactly on.
858
00:50:07,470 --> 00:50:12,140
Because again, the solution,
the true solution is squares.
859
00:50:12,140 --> 00:50:17,260
This is now second order and
we'll get it exactly right.
860
00:50:17,260 --> 00:50:21,790
And I say all this
for two reasons.
861
00:50:21,790 --> 00:50:25,300
One is to emphasize again that
the boundary conditions are
862
00:50:25,300 --> 00:50:30,090
critical and that they
penetrate into the region.
863
00:50:30,090 --> 00:50:32,880
The second reason
for my saying this
864
00:50:32,880 --> 00:50:37,540
is looking forward
way into October.
865
00:50:37,540 --> 00:50:41,670
So let me just say the
finite element method, which
866
00:50:41,670 --> 00:50:44,790
you may know a little about,
you may have heard about,
867
00:50:44,790 --> 00:50:48,510
it's another-- this
was finite differences.
868
00:50:48,510 --> 00:50:50,510
Courses starting with
finite differences,
869
00:50:50,510 --> 00:50:52,260
because that's the
most direct way.
870
00:50:52,260 --> 00:50:53,330
You just go for it.
871
00:50:53,330 --> 00:50:57,460
You've got derivatives, you
replace them by differences.
872
00:50:57,460 --> 00:51:08,890
But another approach which turns
out to be great for big codes
873
00:51:08,890 --> 00:51:12,170
and also turns out to
be great for making,
874
00:51:12,170 --> 00:51:16,220
for keeping the properties of
the problem, the finite element
875
00:51:16,220 --> 00:51:21,520
method, you'll see it, it's
weeks away, but when it comes,
876
00:51:21,520 --> 00:51:24,780
notice, the finite element
method automatically
877
00:51:24,780 --> 00:51:27,540
produces that first equation.
878
00:51:27,540 --> 00:51:29,880
Automatically gets it right.
879
00:51:29,880 --> 00:51:33,010
So that's pretty special.
880
00:51:33,010 --> 00:51:36,670
And so, the finite
element method just has,
881
00:51:36,670 --> 00:51:39,160
it produces that
second order accuracy
882
00:51:39,160 --> 00:51:48,330
that we didn't get automatically
for finite differences.
883
00:51:48,330 --> 00:51:52,800
Okay, questions on today
or on the homework.
884
00:51:52,800 --> 00:51:55,760
So the homework is
really wide open.
885
00:51:55,760 --> 00:51:59,550
It's really just a
chance to start to see.
886
00:51:59,550 --> 00:52:03,650
I mean, the real homework
is read those two sections
887
00:52:03,650 --> 00:52:09,310
of the book to capture what
these two lectures have done.
888
00:52:09,310 --> 00:52:11,870
So Monday I'll see.
889
00:52:11,870 --> 00:52:13,380
We'll do elimination.
890
00:52:13,380 --> 00:52:17,530
We'll solve these equations
quickly and then move on
891
00:52:17,530 --> 00:52:21,600
to the inverse matrix.
892
00:52:21,600 --> 00:52:25,390
More understanding
of these problems.
893
00:52:25,390 --> 00:52:26,178
Thanks.
894
00:52:26,178 --> 00:52:26,678