Professional Documents
Culture Documents
MA 214: Introduction To Numerical Analysis: Shripad M. Garge. IIT Bombay (Shripad@math - Iitb.ac - In)
MA 214: Introduction To Numerical Analysis: Shripad M. Garge. IIT Bombay (Shripad@math - Iitb.ac - In)
Lecture 28
Shripad M. Garge.
IIT Bombay
( shripad@math.iitb.ac.in )
2021-2022
1/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
2/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
3/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
4/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
g pxq
If f pxq “ where 0 ă p ă 1 and g : ra, bs Ñ R is
px ´ aqp
continuous then the improper integral
żb
f pxqdx
a
exists.
5/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
We write
żb żb żb
g pxq ´ P4 pxq P4 pxq
f pxqdx “ dx ` dx.
a a px ´ aqp a px ´ aqp
6/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
żb
g pxq ´ P4 pxq
We now need to determine dx. We define
a px ´ aqp
#
g pxq´P4 pxq
px´aqp if a ă x ď b
G pxq “
0 if x “ a.
pkq
Since 0 ă p ă 1 and P4 paq agrees with g pkq paq for k “ 0, . . . , 4,
G is 4-times continuously differentiable on ra, bs.
7/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
An example
ż1
ex
Compute ? dx.
0 x
x2 x3 x4
Here P4 pxq “ 1 ` x ` ` ` , so
2 6 24
ż1 ż1ˆ ˙
P4 pxq ´1{2 1{2 1 3{2 1 5{2 1 7{2
? dx “ x `x ` x ` x ` x dx
0 x 0 2 6 24
„ 1
2 1 1 1 9{2
“ lim 2x ` x 3{2 ` x 5{2 ` x 7{2 `
1{2
x
MÑ0` 3 5 21 108 M
2 1 1 1
“ 2` ` ` `
3 5 21 108
« 2.92354497354.
8/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
The example, continued
ż1
Now we need to approximate G pxqdx where
0
#
?1 pe x ´ P4 pxqq if 0 ă x ď 1
G pxq “ x
0 if x “ 0.
Hence
ż1
ex
? dx « 2.9235450 ` 0.0017691 “ 2.9253141.
0 x
9/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Singularity at b
10/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
11/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
t “ x ´1 , dt “ ´x ´2 dx, so dx “ ´x 2 dt “ ´t ´2 dt.
12/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
Improper integrals
Then ż0 ż 1{a
tp
ż8
1 1
dx “ ´ 2 dt “ dt.
a xp 1{a t 0 t 2´p
Similarly, if f is defined on ra, 8q then we use the substitution
t “ x ´1 to obtain
ż8 ż 1{a ˆ ˙
´2 1
f pxqdx “ t f dt.
a 0 t
14/2
shripad@math.iitb.ac.in MA214 (2021-2022) L28
MA 214: Introduction to numerical analysis
Lecture 29
Shripad M. Garge.
IIT Bombay
( shripad@math.iitb.ac.in )
2021-2022
15/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Ordinary differential equations
16/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Ordinary differential equations
The other approach, which we will examine here, uses methods for
approximating the solution of the original problem.
17/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Some basic material
18/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Well-posed problems
19/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Well-posed problem
21/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Condition ensuring well-posed property
Theorem
Suppose D “ tpt, y q|a ď t ď b, ´8 ă y ă 8u. If f is continuous
and satisfies a Lipschitz condition in the variable y on the set D,
then the initial-value problem
dy
“ f pt, y q, a ď t ď b, y paq “ α
dt
is well-posed.
22/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Euler’s method
23/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Euler’s method
h “ pb ´ aq{N “ ti`1 ´ ti
24/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
Euler’s method
Suppose that y ptq, the unique solution to the problem, has two
continuous derivatives on ra, bs, so that for each i “ 0, . . . , N ´ 1,
pti`1 ´ ti q2 2
y pti`1 q “ y pti q ` pti`1 ´ ti qy 1 pti q ` y pξi q
2
h2 2
“ y pti q ` hy 1 pti q ` y pξi q
2
for some ξi P pti , ti`1 q. This then gives
h2 2
y pti`1 q “ y pti q ` h f pti , y pti qq ` y pξi q.
2
Euler’s method constructs wi « y pti q, for each i by deleting the
remainder term.
y 1 “ y ´ t 2 ` 1, 0 ď t ď 2, y p0q “ 0.5.
26/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
The example, continued
27/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
The example, continued
28/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
The example, continued
When we had h “ 0.5, the approximate value for y p2q was 4.4375
whereas for h “ 0.2 it is 4.8657845, much closer to the actual
value.
29/2
shripad@math.iitb.ac.in MA214 (2021-2022) L29
MA 214: Introduction to numerical analysis
Lecture 30
Shripad M. Garge.
IIT Bombay
( shripad@math.iitb.ac.in )
2021-2022
30/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Euler’s method
31/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Error in Euler’s method
Theorem
Suppose f is continuous and satisfies a Lipschitz condition with
the constant L on D “ ra, bs ˆ R.
Assume that the unique solution, y ptq, to the initial-value problem
dy
“ f pt, y q, a ď t ď b, y paq “ α
dt
satisfies |y 2 ptq| ď M.
If wi for i “ 0, . . . , N, are the Euler approximations to y pti q then
hM ” Lpti ´aq ı
|y pti q ´ wi | ď e ´1 .
2L
32/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Error in Euler’s method
h2 2
yi`1 ´ wi`1 “ pyi ´ wi q ` hrf pti , yi q ´ f pti , wi qs ` y pξi q
2
and
h2 M
|yi`1 ´ wi`1 | ď p1 ` hLq|yi ´ wi | `
2
h2 M h2 M
ˆ ˙
ď p1 ` hLq p1 ` hLq|yi´1 ´ wi´1 | ` `
2 2
2 2
ˆ ˙
h M h M
ď e pi`1qhL |y0 ´ w0 | ` ´
2hL 2hL
hM ` pti`1 ´aqL ˘
ď e ´1 .
2L
33/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Error in Euler’s method
dy 1 df Bf Bf
y 2 ptq “ ptq “ pt, y ptqq “ pt, y ptqq` pt, y ptqq¨f pt, y ptqq.
dt dt Bt By
34/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Error in Euler’s method
We did not consider the round-off error while deriving the above
formula.
w0 “ α, wi`1 “ wi ` hf pti , wi q
but
u0 “ α ` δ 0 , ui`1 “ ui ` hf pti , ui q ` δi`1
where δ0 , . . . are the round-off errors.
35/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Error in Euler’s method
Then
ˆ ˙
1 hM δ
|y pti q ´ ui | ď ` re Lpti ´aq ´ 1s ` |δ0 |e Lpti ´aq
L 2 h
Note that this error bound is not linear in h. In fact, the error will
be expected to be large for small step size.
36/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Local truncation error
The local truncation serves quite well to determine not only the
local error of a method but also the actual approximation error.
y 1 “ f pt, y q, a ď t ď b, y paq “ α.
38/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
Local truncation error
y 1 “ f pt, y q, a ď t ď b, y paq “ α
By Taylor’s theorem
y 1 ptq “ f pt, y ptqq, y 2 ptq “ f 1 pt, y ptqq, ¨ ¨ ¨ , y pn`1q ptq “ f pnq pt, y ptqq.
41/2
shripad@math.iitb.ac.in MA214 (2021-2022) L30
MA 214: Introduction to numerical analysis
Lecture 31
Shripad M. Garge.
IIT Bombay
( shripad@math.iitb.ac.in )
2021-2022
42/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
Taylor method of order n
h hn´1 pn´1q
T pti , wi q “ f pti , wi q ` f 1 pti , wi q ` ¨ ¨ ¨ ` f pti , wi q.
2 n!
43/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
An example
y 1 “ y ´ t 2 ` 1, 0 ď t ď 2, y p0q “ 0.5.
d
f 1 pt, y ptqq “ py ´t 2 `1q “ y 1 ´2t “ py ´t 2 `1q´2t “ y ´t 2 ´2t`1.
dt
Then
h
T pti , wi q “ f pti , wi q ` f 1 pti , wi q
2
h
“ wi ´ ti ` 1 ` pwi ´ ti2 ´ 2ti ` 1q
2
ˆ ˙ 2
h
“ 1` pwi ´ ti2 ` 1q ´ hti .
2
44/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
We have
y p0.2q « 0.83 and y p0.4q « 1.2158.
We now list the values and the errors in the following table.
45/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
46/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
Another example
y 1 “ y ´ t 2 ` 1, 0 ď t ď 2, y p0q “ 0.5.
We compute
f 1 pt, y ptqq “ y ´ t 2 ´ 2t ` 1,
d
f 2 pt, y ptqq “ py ´ t 2 ´ 2t ` 1q “ y 1 ´ 2t ´ 2
dt
“ py ´ t 2 ` 1q ´ 2t ´ 2 “ y ´ t 2 ´ 2t ´ 1,
d
f 3 pt, y ptqq “ py ´ t 2 ´ 2t ´ 1q “ y 1 ´ 2t ´ 2
dt
“ y ´ t 2 ´ 2t ´ 1.
47/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
Then
h h2 h3
T pti , wi q “ f pti , wi q ` f 1 pti , wi q ` f 2 pti , wi q ` f 3 pti , wi q
2 6 24
2 h 2
“ pwi ´ ti ` 1q ` pwi ´ ti ´ 2ti ` 1q
2
h2 h3
` pwi ´ ti2 ´ 2ti ´ 1q ` pwi ´ ti2 ´ 2ti ´ 1q
ˆ6 24
h h2 h3 h h2
˙ ˆ ˙
2
“ 1` ` ` pwi ´ ti q ´ 1 ` ` phti q
2 6 24 3 12
h h2 h3
`1 ` ´ ´ .
2 6 24
48/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
wi`1 “ wi ` hT pti , wi q
h h2 h3
„ˆ ˙
“ wi ` h 1 ` ` ` pwi ´ ti2 q
2 6 24
h h2 h h2 h3
ˆ ˙
´ 1` ` phti q ` 1 ` ´ ´
3 12 2 6 24
49/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
50/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
Order 2 Order 4
51/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
If we use linear interpolation on the nodes 1.2 and 1.4 then we get
ˆ ˙ ˆ ˙
1.25 ´ 1.4 1.25 ´ 1.2
y p1.25q « 3.1799640 ` 3.7324321
1.2 ´ 1.4 1.4 ´ 1.2
“ 3.3180810.
53/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
The example, continued
54/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
Error in Taylor’s method
Theorem
If Taylor’s method of order n is used to approximate the solution to
y 1 “ f pt, y q, a ď t ď b, y paq “ α
55/2
shripad@math.iitb.ac.in MA214 (2021-2022) L31
MA 214: Introduction to numerical analysis
Lecture 32
Shripad M. Garge.
IIT Bombay
( shripad@math.iitb.ac.in )
2021-2022
56/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Taylor method of order n
57/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Taylor’s theorem in two variables
Theorem
Suppose that f pt, y q and all its partial derivatives of order less
than or equal to n ` 1 are continuous on
D “ tpt, y q : a ď t ď b, c ď y ď du,
and
n`1
1 ÿ ˆn ` 1˙ B n`1 f
Rn pt, y q “ pt´t0 qn`1´j py ´y0 qj n`1´j j pξ, µq.
pn ` 1q! j“0 j Bt By
59/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Runge-Kutta Methods of Order Two
df Bf Bf
f 1 pt, y q “ pt, y q “ pt, y q ` pt, y q ¨ y 1 ptq
dt Bt By
Bf Bf
“ pt, y q ` pt, y q ¨ f pt, y q
Bt By
we get
h Bf h Bf
T pt, y q “ f pt, y q ` pt, y q ` pt, y q ¨ f pt, y q.
2 Bt 2 By
60/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Runge-Kutta Methods of Order Two
a1 f pt ` α1 , y ` β1 q “ a1 f pt, y q
Bf Bf
`a1 α1 pt, y q ` a1 β1 pt, y q
Bt By
`a1 R1 pt ` α1 , y ` β1 q
where
α12 B 2 f B2f β12 B 2 f
R1 pt ` α1 , y ` β1 q “ pξ, µq ` α 1 β1 pξ, µq ` pξ, µq
2 Bt 2 BtBy 2 By 2
for some ξ between t and t ` α1 and µ between y and y ` β1 .
61/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Runge-Kutta Methods of Order Two
62/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Runge-Kutta Methods of Order Two
h2 B 2 f
ˆ ˙
h h
R1 t ` , y ` f pt, y q “ pξ, µq
2 2 8 Bt 2
h2 B2f
` f pt, y q pξ, µq
4 BtBy
h2 B 2 f
` pξ, µq
8 By 2
If all the second-order partial derivatives of f are bounded, then
ˆ ˙
h h
R1 t ` , y ` f pt, y q
2 2
63/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
Runge-Kutta Methods of Order Two
It gives w0 “ α and
ˆ ˙
h h
wi`1 “ wi ` hf ti ` , wi ` f pti , wi q
2 2
for i “ 0, . . . , N ´ 1.
We do an example now.
64/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
An example
y 1 “ y ´ t 2 ` 1, 0 ď t ď 2, y p0q “ 0.5.
for each i “ 0, . . . , 9.
65/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32
The example, continued
66/2
shripad@math.iitb.ac.in MA214 (2021-2022) L32