Numerical Analysis: (MA214) : Instructor: Prof. Tony J. Puthenpurakal
Numerical Analysis: (MA214) : Instructor: Prof. Tony J. Puthenpurakal
Lecture 1
Department of Mathematics
Indian Institute of Technology Bombay
[email protected]
Instructions:
80% Attendance Required.
2 Quizes (10% each) : 20%.
Midsem : 30%.
EndSem : 50%
Passing approximately 40% of Max. score.
Note: Last time max score was above 90%. So passing marks ≈ 36%
Examples:-
R1 2
1 I =
1 0 sin(x )dx
R 1 −x 2
2 I =
2 0 e dx
R 41 1
3 I = √ dx
3 0 1−x 3
dy
= f (x, y ), where y (x0 ) = y0 . (1)
dx
Example:
dy
= sin(x + y 2 ), where y (0) = 1
dx
Let A be a n × n matrix.
Ax = λx
p(t) = |tI − A|
n = ±(.d1 d2 . . . dn )β β e
(.d1 d2 . . . dn )β → mantissa
e → exponent
|x − x ∗ | = Absolute error
|x − x ∗ |
:= relative error, ( provided x 6= 0)
|x|
Problem: We do not know x. So how to find relative error?
x − x∗
α =
x∗
x − x∗ α
= ≈ α, if α is small
x 1+α
=⇒
x +y ∼ x∗ + y∗ in 4 sig digits
x −y ∼ x∗ − y∗ in 4 sig digits
xy ∼ x ∗y ∗ in 4 sig digits
x x∗
∼ y∗ in 4 sig digits
y
f (x) = 1 − cosx
cos(0.01) = 1 in 4 sig digits
f (0.01) = 1 − 1 = 0
Actual answer is 5E −5, ( i.e. 5 × 10−5 )
Loss of sig digits arises since cos(0.01) = 1 in 4 sig digits
To avoid this
f (x) = 1 − cosx
1 − cos 2 x
=
1 + cosx
sin2 x
=
1 + cosx
1E −4
f (0.01) = = 5E −5
1+1
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1
Example 2
x 2 + 111.11x + 1.2121 = 0
b 2 = 1.235E 4
b 2 − 4ac = 1.234E 4
p
b 2 − 4ac = 1.111E 2 = b in 4 sig digits
therefore √
b 2 − 4ac
−b +
x1 = =0
2a
Again loss of sig digits occur because we are subtracting nearly equal
quantities.
√ √
−b + b 2 − 4ac −b − b 2 − 4ac
x1 = × √
2a −b − b 2 − 4ac
−2c 1.212
= √ =
2
b + b − 4ac 222.1
= 1.091E −2 correct upto 4 sig digits
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1
Example 3
x − sinx 0.01 − 1E −2
f (x) = , so f (0.01) = =0
tanx 1E −2
x − sinx x + sinx
Rewrite f (x) = ×
tanx x + sinx
2 2
x − sin x
=
tanx(x + sinx)
1(E −4) − 1E (−4)
f (0.01) = =0
1(E −2)(0.01 + 1(E −2))
Actual value f (0.01) ≈ 1.667E −5 4 sig digits. So one has to use Taylor
series
x3 x3
sinx ≈ x − and tanx ≈ x −
6 3
x 3 /6 x 2 /6
f (x) ≈ ≈
x − x 3 /3 1 − x 2 /3
f (0.01) = 1.667E −5
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1
Error Propagation
Once an error is committed it contaminates subsequent results
2 instability
1. condition:
The larger the condition, the more ill-conditioned the function is said to be.
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1
Examples
√
Example 1 : f (x) = x, f 0 (x) = √1
2x
1
f (x)x √2x x 1
0
f (x) = √x = 2
What to do:
put x = 1 − y , then y ∼ 0 if x ∼ 1
10 10 10 5
f (x) = 2
= 2
≈ = , since y 2 ∼ 0
1 − (1 − y ) 2y − y 2y y
5
g (y ) = y 0
g (y )y
g (y ) = 1
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1
Example of instability
du1 1
= 9u1 + 24u2 + 5cost − sint
dt 3
du2 1
= −24u1 − 51u2 − 9cost + sint
dt 3
4 2
u1 (0) = and u2 (0) =
3 3
exact solution
1
u1 (t) = 2e −3t − e −39t + cost
3
1
u2 (t) = −e −3t + 2e −39t − cost
3
RK method of order 4 with step size 0.1
u˜1 approximate to u1
u˜2 approximate to u2
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1
t u1 (t) ũ1 (t)
0.1 1.793061 -2.645169
0.2 1.423901 -18.45158
.. .. ..
. . .
0.9 0.3416143 -695332
1.0 0.2796748 -3099671
What to do
√ √ 1
f (x) = x +1− x=√ √
x +1+ x
1
f (12345) =
1.111E 2 + 1.111E 2
≈ 4.502E −3 correct up to 3 sig digits
Corollary
Let f : [a, b] −→ R be a continuous function. Let x1 , x2 , · · · , xn ∈ [a, b]
and let g1 , g2 , · · · , gn be real numbers all of one sign. Then
n
X n
X
f (xi )gi = f (ξ) gi , for some ξ ∈ [a, b]
i=1 i=1
Corollary
Let g : [a, b] −→ R be non-negative ( or non-positive ) integrable function.
Let f : [a, b] −→ R be continuous. Then
Z b Z b
f (x)g (x)dx = f (ξ) g (x)dx for some ξ ∈ [a, b]
a a
Theorem
Let f : [a, b] −→ R be continuous. Then there exists α, β ∈ [a, b] such that
Let us recall:-
Theorem (Rolle’s Theorem)
Let f : [a, b] −→ R be a continuous function and assume f : (a, b) −→ R
is differentiable. If f (a) = f (b), then there exists ξ ∈ (a, b) such that
f 0 (ξ) = 0
Theorem (M.V.T.)
Let f : [a, b] −→ R be a continuous function and assume f : (a, b) −→ R
is differentiable. Then
f (b) − f (a)
= f 0 (ξ) for some ξ ∈ (a, b)
b−a
Proof.
Apply Rolle’s Theorem to
f (b) − f (a)
F (x) = f (x) − f (a) − (x − a)
b−a
f 00 (c)
f (x) = f (c) + f 0 (c)(x − c) + (x − c)2 + · · ·
2
f (n) (c)
··· + (x − c)n + Rn+1 (x)
n!
1 x
Z
where Rn+1 (x) = (x − s)n f n+1 (s)ds
n! c
1
Note np −→ 0 for any p ≥ 0
1 1
Intuitively, n −→ 0 more slowly than n2
and so on.
Definition
Let {αn }n≥1 and {βn }n≥1 be two sequences. We say αn is big − oh of βn
and we write
αn = O(βn )
If |αn | ≤ k|βn |, for some constant k and for all n >> 0
Examples:-
{ n1 }, { 100 10
n }, { n −
40
n2
+ e −n }, { n1p } (here p ≥ 1) are all O( n1 ).
Example:
1 { n12 }
1
2 { n log n}
both are o( n1 )
Important Remark:-
1
A convergence order rate of n is much too slow to be useful in calculations.
∞ ∞
π X (−1)i X 2
= =1− 2
4 2i + 1 16j − 1
i=0 j=1
n
P 2
Set αn = 1 − 16j 2 −1
.
j=1
The sequence {αn } is monotonically decreasing. Moreover
π 1
0 ≤ αn − ≤ , n = 1, 2, · · ·
4 4n + 3
to calculate π4 correctly to within 10−6 we would need 106 ≤ 4n + 3 or
roughly n = 250, 000 calculations.
However round of errors in calculation α250,000 will be usually greater that
10−6 . Here
π 1
αn = +O
4 n
π 1
αn 6= +o
4 n
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 1