1
00:00:01,718 --> 00:00:04,908
I'll conclude this sub unit on computational methods
2
00:00:04,908 --> 00:00:09,618
for solving differential equations, with some more general remarks.
3
00:00:09,618 --> 00:00:11,289
So, we've been discussing Euler's method,
4
00:00:12,960 --> 00:00:14,632
- Euler's method is known as a numerical
5
00:00:14,632 --> 00:00:18,209
or computational method for solving the differential equation.
6
00:00:18,209 --> 00:00:21,730
It's computational because it involves doing computations
7
00:00:21,730 --> 00:00:23,745
using, almost always, a computer,
8
00:00:23,745 --> 00:00:27,207
and it's called numerical - that's its may be more traditional term,
9
00:00:27,207 --> 00:00:31,096
because the result of Euler's method is not a formula for a function
10
00:00:31,096 --> 00:00:35,901
but it's a list of numbers, so we call it a numerical method.
11
00:00:35,901 --> 00:00:38,652
Euler's method is quite simple conceptually,
12
00:00:38,652 --> 00:00:42,044
and it gets at the heart of what difference equations are:
13
00:00:42,044 --> 00:00:44,426
- a rule for how something changes,
14
00:00:44,426 --> 00:00:47,877
and that rule is written in terms of the derivative,
15
00:00:47,877 --> 00:00:51,388
- the rate of change, not the function itself.
16
00:00:51,388 --> 00:00:53,465
So, I think if you understand Euler's method,
17
00:00:53,465 --> 00:00:55,452
and may be code it up yourself,
18
00:00:55,452 --> 00:00:57,209
then you really have a good understanding
19
00:00:57,209 --> 00:00:59,262
of what differential equations mean,
20
00:00:59,262 --> 00:01:02,288
so, I definitely recommend if you have some programming skills,
21
00:01:02,288 --> 00:01:03,659
- the language doesn't matter at all,
22
00:01:03,659 --> 00:01:05,269
and you can use a spreadsheet,
23
00:01:05,269 --> 00:01:08,413
to try coding up Euler's method yourself.
24
00:01:08,413 --> 00:01:12,117
I'll list this in the homework for this unit.
25
00:01:12,117 --> 00:01:14,818
So, Euler's method is very nice conceptually,
26
00:01:14,818 --> 00:01:17,898
however it's not very efficient computationally,
27
00:01:17,898 --> 00:01:20,328
so, it's not used much in practice.
28
00:01:20,328 --> 00:01:24,077
Let me say a little bit about how one can improve on Euler's method.
29
00:01:25,658 --> 00:01:27,820
So, to improve on Euler's method,
30
00:01:27,820 --> 00:01:29,958
there are two things one might like to do:
31
00:01:29,958 --> 00:01:32,978
first, there's a family of techniques,
32
00:01:32,978 --> 00:01:36,008
a group of techniques, known as Runge-Kutta methods,
33
00:01:36,008 --> 00:01:37,808
and here's the idea behind them:
34
00:01:37,808 --> 00:01:39,059
I'm not going to go into this in details,
35
00:01:39,059 --> 00:01:42,288
but It's worth mentioning.
36
00:01:42,288 --> 00:01:43,873
So, in Euler's method,
37
00:01:43,873 --> 00:01:50,042
we pretend that the rate of change is constant, over an interval delta t,
38
00:01:50,042 --> 00:01:52,203
and then we have to choose what rate of change
39
00:01:52,203 --> 00:01:55,819
we're going to use, and we just choose the rate of change
40
00:01:55,819 --> 00:01:58,622
at the left part of that interval.
41
00:01:58,622 --> 00:02:02,896
We just take the starting rate of change in that interval
42
00:02:02,896 --> 00:02:05,289
and pretend that it's constant for all of delta t.
43
00:02:05,289 --> 00:02:07,414
Runge-Kutta methods say,
44
00:02:07,414 --> 00:02:12,010
well, rather than using the rate of change at the start of the interval,
45
00:02:12,010 --> 00:02:14,872
what if we use the rate of change at the start of the interval,
46
00:02:14,872 --> 00:02:18,624
and at the end of the interval, and average those two.
47
00:02:18,624 --> 00:02:22,332
That would probably be a more fairer representation
48
00:02:22,332 --> 00:02:24,201
of what's happening in that interval,
49
00:02:24,201 --> 00:02:26,730
or better still, maybe we could sample the rate of change
50
00:02:26,730 --> 00:02:29,123
at three different points along that interval,
51
00:02:29,123 --> 00:02:31,423
and there are different schemes for doing that sampling
52
00:02:31,423 --> 00:02:37,203
and different ways of averaging the different derivatives
53
00:02:37,203 --> 00:02:40,369
that one estimates, but that's the general idea.
54
00:02:40,369 --> 00:02:43,701
Rather than just use one derivative,
55
00:02:43,701 --> 00:02:47,790
sample a couple derivatives, and average those.
56
00:02:48,482 --> 00:02:50,661
So, that's one way to improve on Euler's method.
57
00:02:50,661 --> 00:02:52,894
It's not immediately obvious, but this turns out to be
58
00:02:52,894 --> 00:02:56,043
more efficient, in the sense that, with less computational effort
59
00:02:56,043 --> 00:02:59,619
you can get an equally accurate answer.
60
00:02:59,619 --> 00:03:02,413
The other thing that one typically does
61
00:03:02,413 --> 00:03:04,819
is something called adaptive step size,
62
00:03:04,819 --> 00:03:08,818
and this is: we have the program automatically adjust delta t
63
00:03:08,818 --> 00:03:12,091
on the fly - as it's doing, as it's trying to find a solution.
64
00:03:12,091 --> 00:03:15,901
So, delta t needs to be small
65
00:03:15,901 --> 00:03:18,374
when the derivative is changing rapidly.
66
00:03:18,374 --> 00:03:20,898
We get into trouble with these methods
67
00:03:20,898 --> 00:03:22,942
when we pretend the derivative is
68
00:03:22,942 --> 00:03:25,652
constant over delta t, but it actually changes a lot.
69
00:03:25,652 --> 00:03:29,779
So, if we have a situation where, sometimes,
70
00:03:29,779 --> 00:03:33,059
as time goes on, the derivative is changing rapidly,
71
00:03:33,059 --> 00:03:35,899
and other times, it's not changing rapidly,
72
00:03:35,899 --> 00:03:39,118
then we don't need to use the same delta t.
73
00:03:39,118 --> 00:03:42,619
If the change in derivative is slow,
74
00:03:42,619 --> 00:03:45,742
we can use a large delta t,
75
00:03:45,742 --> 00:03:48,254
when it's fast we need to use a small delta t,
76
00:03:48,254 --> 00:03:51,459
and so these adaptive step-size methods
77
00:03:51,459 --> 00:03:54,059
figure that out on the fly.
78
00:03:54,059 --> 00:03:57,251
I sort of think about it - adaptive step size - as this way,
79
00:03:57,251 --> 00:04:00,959
and this is a rough analogy but it may be gives the right idea,
80
00:04:00,959 --> 00:04:04,000
- imagine you're walking across a landscape,
81
00:04:04,000 --> 00:04:06,505
and you're blindfolded - you can't see.
82
00:04:06,505 --> 00:04:11,012
If the landscape is flat, you can take very big steps,
83
00:04:11,012 --> 00:04:12,539
and you're not going to miss anything,
84
00:04:12,539 --> 00:04:14,294
but if the landscape is very bumpy,
85
00:04:14,294 --> 00:04:15,585
then you'll need to take small steps
86
00:04:15,585 --> 00:04:18,664
to make sure you don't trip or miss something.
87
00:04:18,664 --> 00:04:23,060
So, if you're blindfolded, you might adjust your step size
88
00:04:23,060 --> 00:04:25,742
depending on what you sense the terrain to be.
89
00:04:25,742 --> 00:04:30,488
OK, in any event, the standard way to improve on Euler's method
90
00:04:30,488 --> 00:04:31,940
is to do these two things:
91
00:04:31,940 --> 00:04:33,542
some type of Runge-Kutta method,
92
00:04:33,542 --> 00:04:35,689
and some type of adaptive step size.
93
00:04:35,689 --> 00:04:38,663
Almost all numerical programming environments, that I'm familiar with:
94
00:04:38,663 --> 00:04:42,179
MATLAB, Octave, Maple, Mathematica, Python
95
00:04:42,179 --> 00:04:45,981
- have some sort of built-in Runge-Kutta, adaptive step size solver.
96
00:04:45,981 --> 00:04:50,208
So, perhaps in the form, some of you who have experience
97
00:04:50,208 --> 00:04:51,452
with these different things,
98
00:04:51,452 --> 00:04:53,408
and maybe have solved differential equations before
99
00:04:53,408 --> 00:04:55,503
can post some examples
100
00:04:55,503 --> 00:04:59,979
for how to use these different built-in functions.
101
00:04:59,979 --> 00:05:03,253
OK, lastly, may be just take a look ahead.
102
00:05:03,253 --> 00:05:07,042
So, in the next units, I'll be frequently presenting
103
00:05:07,042 --> 00:05:08,849
solutions to differential equations,
104
00:05:08,849 --> 00:05:12,368
and almost always, the solutions that I present
105
00:05:12,368 --> 00:05:15,200
and show you and discuss will be numerical solutions.
106
00:05:16,184 --> 00:05:18,105
In order to do this course you don't need to
107
00:05:18,105 --> 00:05:20,126
solve differential equations on your own,
108
00:05:20,126 --> 00:05:23,293
you don't need to code up your own algorithms,
109
00:05:23,293 --> 00:05:25,579
you don't need to use other peoples' algorithms,
110
00:05:25,579 --> 00:05:28,101
however, I think it's important that you have
111
00:05:28,101 --> 00:05:30,978
a sense of where these numerical solutions come from.
112
00:05:30,978 --> 00:05:33,412
So, if I show you a solution to a differential equation
113
00:05:33,412 --> 00:05:36,409
you have some idea where that solution came from,
114
00:05:36,409 --> 00:05:39,209
- it's not magic, it's just from using something like
115
00:05:39,209 --> 00:05:42,650
Euler's method - a very simple, but repetitive way
116
00:05:42,650 --> 00:05:46,731
of solving differential equations.