Indian Institute of Technology Indore MA 204N: Numerical Methods
Indian Institute of Technology Indore MA 204N: Numerical Methods
where fi = f (xi ), xi = x0 + ih, i = 0, 1, 2. Prove that the error term R has the form
R = kf (n) (ζ), x0 < ζ < x1 , and determine k and n.
Solution.
1
IIT Indore MA 204N – Numerical Methods
1 1
Subtracting the second from the third: 2c = 3
− 2
= − 61 , so
1
c=− .
12
1 1 1 1
Then b = 2
− 2(− 12 )= 2
+ 6
= 23 , so
2
b= .
3
And a = 1 − b − c = 1 − 23 + 1
12
= 5
12
, so
5
a= .
12
(x − x0 )2 ′′ (x − x0 )3 ′′′
f (x) = f0 + (x − x0 )f0′ + f0 + f0 + · · ·
2! 3!
Integrate term by term over [x0 , x0 + h]:
Z x1
h2 h3 h4
f (x) dx = hf0 + f0′ + f0′′ + f0′′′ + · · ·
x0 2 6 24
h2 ′′ h3 ′′′ h4 (4)
f1 = f0 + hf0′ + f + f0 + f0 + · · · ,
2 0 6 24
2 3
4h 8h 16h4 (4)
f2 = f0 + 2hf0′ + f0′′ + f0′′′ + f + ··· .
2 6 24 0
5
Now compute h(af0 + bf1 + cf2 ) with a = 12 , b = 23 , c = − 12
1
:
Coefficient of f0 : h(a + b + c) = h · 1 =h. ✓
Coefficient of f0′ : h · h(b + 2c) = h2 23 − 12 2
= h2 · 12 . ✓
2 3 3 3
Coefficient of f0′′ : h · h2 (b + 4c) = h2 32 − 124
= h2 · 31 = h6 . ✓
3 4 h4
Coefficient of f0′′′ : h · h6 (b + 8c) = h6 23 − 128
= 6 · 0 = 0.
2
IIT Indore MA 204N – Numerical Methods
So the formula is exact through f0′′′ terms as well (degree 3 coefficient vanishes). Check
(4)
f0 :
(4) 4 5 h5 2 5
Coeff of f0 : h · h24 (b + 16c) = h24 23 − 16
12
= 24 − 3 = − h36 .
h5 (4) h5
Exact integral contributes f
120 0
(from 5!
).
Error:
h5 (4)
5
13h5 (4)
h (4) 5 (4) 1 1 (4) 3 + 10
R= f0 − − f0 = h f0 + = h5 f0 · = f (ζ).
120 36 120 36 360 360
Wait — let us redo this carefully. The error is:
Z x1
R= f dx − h(af0 + bf1 + cf2 ).
x0
13h5
Hence n = 4 and k = .
360
3
IIT Indore MA 204N – Numerical Methods
h2 ′′ h3 ′′′ h4 (4)
h h ′
(f0 + f1 ) = 2f0 + hf0 + f0 + f0 + f0 + · · ·
2 2 2 6 24
h2 h3 h4 h5 (4)
= hf0 + f0′ + f0′′ + f0′′′ + f0 + · · ·
2 4 12 48
h2 ′′′ h3 (4)
f0′ − f1′ f0′ ′ ′′
= − f0 + hf0 + f0 + f0 + · · ·
2 6
2 3
h h (4)
= −hf0′′ − f0′′′ − f0 − · · ·
2 6
So:
h2 ′ h3 h4 h5 (4)
(f0 − f1′ ) = − f0′′ − f0′′′ − f0 − · · ·
12 12 24 72
Adding:
h2 ′ h2 ′
h ′ 1 1 3 ′′ 1 1
(f0 + f1 ) + (f0 − f1 ) = hf0 + f0 + − h f0 + − h4 f0′′′
2 12 2 4 12 12 24
1 1 (4)
+ − h5 f0 + · · ·
48 72
h2 h3 h4 h5 (4)
= hf0 + f0′ + f0′′ + f0′′′ + f + ···
2 6 24 144 0
Error:
Z x1
h2 ′
h ′ 1 1 (4)
R= f dx − (f0 + f1 ) + (f0 − f1 ) = − h5 f0 + O(h6 ).
x0 2 12 120 144
1 1 144 − 120 24 1
− = = = .
120 144 120 · 144 17280 720
h5 (4)
R= f (ζ), x0 < ζ < x1 .
720
1
This is the Euler–Maclaurin based generalized trapezoidal rule with p = 12
.
4
IIT Indore MA 204N – Numerical Methods
Summing over i = 1, . . . , n:
Z b " n−1
# n−1
h X h2 ′ ′ h2 X ′
f dx = f0 + 2 fi + fn + (f0 − fn ) + (fi−1 − fi′ )|telescoping + O(h4 ).
a 2 i=1
12 12 i=1
" n−1
#
b
h2
Z
h X
f (x) dx ≈ f0 + 2 fi + fn + (f0′ − fn′ ),
a 2 i=1
12
(b − a) 4 (4)
with composite error E = − h f (η), a < η < b.
720
(b − a)h2
|ET | = max f ′′ (x) , a = 0.1, b = 0.2.
12 x∈[a,b]
5
IIT Indore MA 204N – Numerical Methods
u = 2x cos x + x2 sin x,
u′ = 2 cos x − 2x sin x + 2x sin x + x2 cos x = 2 cos x + x2 cos x,
v = cos2 x, v ′ = −2 cos x sin x = − sin 2x.
2.158
|f ′′ (0.2)| ≈ ≈ 2.294.
0.941
So we take M2 = max |f ′′ | ≈ 2.3 (conservative).
6
IIT Indore MA 204N – Numerical Methods
h = 5 × 10−3
is the largest step length of the given form satisfying the error requirement.
Verification: With h = 5 × 10−3 :
π
µ0 = 2 · = π,
2
π 1 π
µ1 = 2 · · = ,
2 2 2
π 1·3 3π
µ2 = 2 · · = ,
2 2·4 8
π 1·3·5 5π
µ3 = 2 · · = .
2 2·4·6 16
7
IIT Indore MA 204N – Numerical Methods
π π π
α1 = , α2 = , α3 = .
4 2 4
Step 4: Application
1 1 1
Note that √ =p =p . Rewrite:
x − x3 x(1 − x2 ) x(1 − x)(1 + x)
Z 1 Z 1
dx 1 dx
√ = √ ·p .
0 x − x3 0 1+x x(1 − x)
1
So f (x) = √ .
1+x
Apply the formula:
Z 1
dx π π π π π 1 π 1
√ ≈ f (0) + f 12 + f (1) = · 1 + · p + ·√ .
0 x−x 3 4 2 4 4 2 3/2 4 2
r
π π 2 π π π π
= + · + √ = +√ + √ .
4 2 3 4 2 4 6 4 2
Numerically:
π
≈ 0.7854,
4
π 3.14159
√ ≈ ≈ 1.2825,
6 2.44949
π 3.14159
√ ≈ ≈ 0.5554.
4 2 5.65685
8
IIT Indore MA 204N – Numerical Methods
R2
Problem 5. Composite Simpson’s Rule for 1 dx/x
Z 2
dx
Problem. Evaluate using the composite Simpson’s rule accurate up to 10−3 .
1 x
Solution.
(b − a)h4
|ES | = max |f (4) (x)|.
180 x∈[a,b]
For f (x) = 1/x: f (4) (x) = 24/x5 . On [1, 2], max |f (4) | = 24 (at x = 1).
where x1 = x0 + h, x2 = x0 + 2h.
Step 2: Expand f0 , f1 , f2
f0 = f0 ,
h2 ′′ h3 ′′′ h4 (4)
f1 = f0 + hf0′ + f + f0 + f0 + · · · ,
2 0 6 24
3
4h 2h4 (4)
f2 = f0 + 2hf0′ + 2h2 f0′′ + f0′′′ + f + ···
3 3 0
h4 (4)
f0 + 4f1 + f2 = 6f0 + 6hf0′ + 3h2 f0′′ + h3 f0′′′ + f0 + · · ·
4
h2
(Coefficient details: constant: 1 + 4 + 1 = 6; f0′ : 4h + 2h = 6h; f0′′ : 4 · 2
+ 2h2 =
2h + 2h2 = 4h2 ... let me redo carefully.)
2
10
IIT Indore MA 204N – Numerical Methods
h2
f0 + 4f1 + f2 = (1 + 4 + 1)f0 + (0 + 4h + 2h)f0′ + (0 + 4 · 2
+ 2h2 )f0′′
h3 3 4 2h4 (4)
+ (0 + 4 · 6
+ 4h3 )f0′′′ + (0 + 4 · h24 + 3
)f0 + · · ·
3 3 4 2h4 (4)
= 6f0 + 6hf0′ + (2h2 + 2h2 )f0′′ + ( 2h3 + 4h3 )f0′′′ + ( h6 + 3
)f0 + ···
4 (4)
= 6f0 + 6hf0′ + 4h2 f0′′ + 2h3 f0′′′ + 5h6 f0 + · · ·
Hence:
h 2 ′ 4h3 ′′ 2h4 ′′′ 5h5 (4)
(f0 + 4f1 + f2 ) = 2hf0 + 2h f0 + f + f + f + ···
3 3 0 3 0 18 0
11
IIT Indore MA 204N – Numerical Methods
Trapezoidal Rule (n = 1)
Integrate from t = 0 to t = 1, keeping terms up to ∆f0 :
Z 1
1 f1 − f 0 h
h (f0 + t∆f0 ) dt = h f0 · 1 + ∆f0 · = h f0 + = (f0 + f1 ).
0 2 2 2
Z x1
h
f dx ≈ (f0 + f1 ).
x0 2
Simpson’s Rule (n = 2)
Integrate from t = 0 to t = 2, keeping terms up to ∆2 f0 :
Z 2
t(t − 1) 2
h f0 + t∆f0 + ∆ f0 dt.
0 2
Compute each integral:
Z 2
1 dt = 2,
0
Z 2
t dt = 2,
0
Z 2
1 2 2
t(t − 1)
Z
1 8 1 2 1
dt = (t − t) dt = −2 = · = .
0 2 2 0 2 3 2 3 3
So: Z x2
1 2
f dx ≈ h 2f0 + 2∆f0 + ∆ f0 .
x0 3
Now substitute ∆f0 = f1 − f0 , ∆2 f0 = f2 − 2f1 + f0 :
1
= h 2f0 + 2(f1 − f0 ) + (f2 − 2f1 + f0 )
3
f2 2f1 f0
= h 2f0 + 2f1 − 2f0 + − +
3 3 3
f0 4f1 f2
=h + +
3 3 3
h
= (f0 + 4f1 + f2 ).
3
Z x2
h
f dx ≈ (f0 + 4f1 + f2 ).
x0 3
12
IIT Indore MA 204N – Numerical Methods
Step 1: Setup
Volume of solid of revolution about the x-axis:
Z 1
V =π [y(x)]2 dx.
0
The data:
x 0.00 0.25 0.50 0.75 1.00
y 1.0000 0.9896 0.9589 0.9089 0.8415
Compute y 2 :
x 0.00 0.25 0.50 0.75 1.00
y 2 1.00000 0.97929 0.91950 0.82608 0.70812
Let us verify:
y02 = (1.0000)2 = 1.00000,
y12 = (0.9896)2 = 0.97929,
y22 = (0.9589)2 = 0.91950,
y32 = (0.9089)2 = 0.82608,
y42 = (0.8415)2 = 0.70812.
0.25
= [1.00000 + 4(0.97929) + 2(0.91950) + 4(0.82608) + 0.70812]
3
0.25
= [1.00000 + 3.91716 + 1.83900 + 3.30432 + 0.70812]
3
0.25
= × 10.76860
3
0.25 × 10.76860
=
3
2.69215
=
3
= 0.89738.
13