class notes Numerical Analysis
class notes Numerical Analysis
ERROR:
1.1 introduction
Numerical analysis dealt with finding value of a function,
its derivative, integration where function is not known,
instead value of the function at some point is known,
also to solve equation and differential which we want to
manage. In fact two component are there numerical
method and numerical analysis. Second part deals with
error management along with method.
1.2 Source of ERROR:
In mathematics we often take approximation ,say √2 =
1.414 or sin x = x. This contribute some error. Source of
error may be of two type Round off error and Truncation
error. First one is round off error whereas second one is
truncation error.
Decimal places and Significant figure : in the number
23.765 number of significant figure is 5 where decimal
places is 3 .
.002354 has 6 DP whereas it has 4 s.f
.12300 has 5 DP but at least 3 SF (we will explain latter)
2
2
of 65
3
3
of 65
4
4
𝟏
less than 𝟐 × 𝟏𝟎−𝒎 then discard it and if discarded
𝟏
part is exactly × 𝟏𝟎−𝒎 then add 1 to last decimal
𝟐
place or last significant figure if it is odd otherwise keep
unchanged “ . That makes the upper bound of error for
1 −m
rounding off is × 10 or half a unit at last
2
significant digit. Now the most relevant question is what
is the reason behind this rounding off technique ?
Obvious answer is to make absolute error minimum. But
why that odd even principle ? First of all alternatively we
can always increase or decrease last digit by 1 ,then final
answer of a sum will attract more error , so in 50% cases
we will increase it and other 50% cases not . Again by this
principle we make the last digit of a number even. A
number whose last digit is even is divisible by 2 and may
be divisible by some other number, on the contrary it
may not be divisible by any even number .So ultimately
probability of attracting error will be less.
Example : If x=19.9995 round it off upto 5,4,3,2,1
significant figures.
x* =20.000 correct to 5 s.f
x* =20.00 correct to 4 s.f
4 of 65
of 65
5
5
of 65
6
6
2
Relative error 𝐸𝑟 = |54762| = 3.652 × 10−5
Relative percentage error = 𝐸p = 𝐸𝑟 × 100
6 of 65
of 65
7
7
𝑥∗ 𝑒𝑥 𝑒𝑦 𝑥∗ 𝑒𝑥 𝑒𝑦 𝑒𝑥 𝑒𝑦
= ∗ (1 + ∗ ) (1 − ∗ ) = ∗ (1 + ∗ − ∗ − ∗ ∗ )
𝑦 𝑥 𝑦 𝑦 𝑥 𝑦 𝑥 𝑦
𝑥 𝑥∗ 𝑥∗ 𝑒 𝑒
∴ |𝑦 − | ÷ |𝑦 ∗ | ≤ |𝑥𝑥∗ | + |𝑦𝑦∗ |
𝑦∗
7 of 65
of 65
8
8
8 of 65
of 65
9
9
22
Example: If 𝜋 = is approximated as 3.14, find the
7
absolute error, relative error and relative percentage
error.
22
Solution: Absolute error 𝐸𝑎 = | 7 − 3.14|
22−21.98
=| |
7
0.02
= | 7 | = 0.002857
0.002857
Relative error 𝐸𝑟 = | 22/7 |
= 0.0009
Relative percentage error = 𝐸p = 𝐸𝑟 × 100
= 0.0009 × 100
= 0.09 %
Example: Compute the percentage error in the time
period 𝑇 = 2𝜋√𝑙/𝑔 for 𝑙 = 1 𝑚 if the error in the
measurement of 𝑙 is 0.01.
𝑙
Solution: Given the 𝑇 = 2𝜋 √𝑔.
Taking 𝑙𝑜𝑔 of both sides we have,
1 1
𝑙𝑜𝑔𝑇 = 𝑙𝑜𝑔2𝜋 + log 𝑙 − log 𝑔
2 2
9 of 65
of 65
10
10
𝑑𝑇 1 𝑑𝑙
∴ =
𝑇 2 𝑙
𝑑𝑇 1 𝑑𝑙 0.01
× 100 = × 100 = = 0.05%.
𝑇 2 𝑙 2×1
10 of 65
of 65
11
11
𝑥𝑛
Where 𝑅𝑛 (𝑥 ) = 𝑒 𝜃 , 0 < 𝜃 < 𝑥.
𝑛!
𝑥𝑛
Maximum absolute error (at 𝜃 = 𝑥) = 𝑒𝑥
𝑛!
𝑥𝑛
and maximum relative error is .
𝑛!
1
Hence (𝑒 𝑥 )𝑚𝑎𝑥 at 𝑥 = 1 is .
𝑛!
For a six decimal accuracy at 𝑥 = 1, we have
1 1
< × 10−6
𝑛! 2
or, 𝑛! > 2 × 106
which gives 𝑛 = 10.
Here we have two important theorem on error.(PDF)
INTRERPOLATION
2.1 Introduction
11 of 65
of 65
12
12
12 of 65
of 65
13
13
of 65
14
14
of 65
15
15
15 of 65
of 65
16
16
16 of 65
of 65
17
17
𝑓 𝑛+1 ( 𝜉)
K= (𝑛+1)! .Hence at a interpolating point t=x we get
0=F(x)=f(x)-Ln(x)-kω(x) imply
𝑓 𝑛+1( 𝜉)
f(x)-Ln(x)= (𝑛+1)!
ω(x) = Rn+1(x) , 𝜉𝜖(𝑎, 𝑏)
17 of 65
of 65
18
18
(𝑥−𝑥𝑘 ) 𝜔(𝑥)
Ln(x) = ∑𝑛𝑖=0 ∏𝑛𝑘=0 𝑦
(𝑥𝑖 −𝑥𝑘 ) 𝑖
= ∑𝑛𝑖=0 𝑦
(𝑥−𝑥𝑖 )𝜔′(𝑥𝑖 ) 𝑖
𝑘≠𝑖
18 of 65
of 65
19
19
𝑓 𝑛+1( 𝜉)
𝑓(𝑥 ) = ∑𝑛𝑖=0 𝜔𝑖 (𝑥)𝑦𝑖 + ω(x) ; remember 𝜔𝑖 (𝑥 )
(𝑛+1)!
are independent of function value yi of f(x) . so if we take
f(x) =1 then yi =1 and we get ∑𝑛𝑖=0 𝜔𝑖 (𝑥 ) = 1 .
19 of 65
of 65
20
20
20 of 65
of 65
21
21
𝑘
∆𝑘 𝑦0 = ∑𝑘𝑖=0(−1)𝑖 ( ) 𝑦𝑘−𝑖 . Note that coefficients are
𝑖
binomial. Question is why?
Exercise: i) Prove that first order difference of a
constant is 0.
ii) The first order difference of a polynomial of
degree 𝑛 is a polynomial of degree 𝑛 − 1.
Backward difference operator 𝛁: The first order
backward difference operator is defined by
∇𝑓(𝑥 ) = 𝑓(𝑥 ) − 𝑓(𝑥 − ℎ)
The central difference operator 𝛅 ∶ The central
difference operator δ is defined by
1 1
𝛿𝑓(𝑥 ) = 𝑓 (𝑥 + ℎ) − 𝑓 (𝑥 − ℎ)
2 2
1 1
−2
= (𝐸 2 − 𝐸 ) 𝑓(𝑥)
1
𝛿𝑓 (𝑥 + 2 ℎ) = 𝑓(𝑥 + ℎ) − 𝑓(𝑥 ) = ∆𝑓(𝑥)
1 1 1
𝛿𝑓(𝑥 ) = 𝑓 (𝑥 + 2 ℎ) − 𝑓 (𝑥 − 2 ℎ) = ∆𝑓(𝑥 − ℎ)
2
1 1
−2
Thus we have the result 𝛿 ≡ 𝐸 − 𝐸 2
of 65
22
22
of 65
23
23
𝑥 𝑦 ∆𝑦 ∆2 𝑦 ∆3 𝑦 ∆𝑛 𝑦
𝑥0 𝑦𝑜
23 of 65
of 65
24
24
∆𝑦0
𝑥1 𝑦1 ∆2 𝑦0
∆𝑦1 ∆3 𝑦0
𝑥2 𝑦2 ∆2 𝑦1
…. ….
….. ∆𝑛 𝑦0
…… ∆2 𝑦𝑛−2
∆𝑦𝑛−1
𝑥𝑛 𝑦𝑛
24 of 65
of 65
25
25
25 of 65
of 65
26
26
∆𝑦0
𝐿𝑛 (𝑥 ) = 𝑦0 + (𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 )(𝑥 −
ℎ
∆2 𝑦0 ∆𝑛 𝑦0
𝑥1 ) 2!ℎ2 + ⋯ + (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) … . (𝑥 − 𝑥𝑛−1 ) 𝑛!ℎ𝑛
𝑥−𝑥0
Setting 𝑢 = , equation become
ℎ
𝑢(𝑢−1) 2 𝑢(𝑢−1)(𝑢−2) 3
𝐿𝑛 (𝑥 ) = 𝑦0 + 𝑢 ∆𝑦0 + ∆ 𝑦0 + ∆ 𝑦0 +
2! 3!
𝑢(𝑢−1)(𝑢−2)….(𝑢−𝑛+1) 𝑛
⋯+ ∆ 𝑦0
𝑛!
26 of 65
of 65
27
27
𝐿𝑛 (𝑥 ) = 𝑎0 + 𝑎1 (𝑥 − 𝑥𝑛 ) + 𝑎2 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 ) +
⋯ + 𝑎𝑛 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 ) … . (𝑥 − 𝑥1 )
We now determine the coefficient 𝑎0 , 𝑎1 , 𝑎2, … , 𝑎𝑛 using
the notation 𝐿𝑛 (𝑥𝑖 ) = 𝑦𝑖 (𝑖 = 0, 1, 2, … . . , 𝑛)
We have 𝐿𝑛 (𝑥𝑛 ) = 𝑦𝑛 = 𝑎0 ;
𝐿𝑛 (𝑥𝑛−1 ) = 𝑦𝑛−1 = 𝑎0 + 𝑎1 (𝑥𝑛−1 − 𝑥𝑛 )
𝑦𝑛 − 𝑦𝑛−1 ∇𝑦𝑛 Δ𝑦𝑛−1
𝑎1 = = = ;
𝑥𝑛 − 𝑥𝑛−1 ℎ h
𝐿𝑛 (𝑥𝑛−2 ) = 𝑦𝑛−2
= 𝑎0 + 𝑎1 (𝑥𝑛−2 − 𝑥𝑛 )
+ 𝑎2 (𝑥𝑛−2 − 𝑥𝑛 )(𝑥𝑛−2 − 𝑥𝑛−1 )
𝑦𝑛 − 2𝑦𝑛−1+ 𝑦𝑛−2 ∇2 𝑦𝑛 Δ2 𝑦𝑛−2
𝑎2 = 2
= 2
=
2ℎ 2! ℎ 2! ℎ2
27 of 65
of 65
28
28
𝑥−𝑥𝑛
Setting 𝑣 = , we get
ℎ
28 of 65
of 65
29
29
𝑣 (𝑣+1) 2 𝑣(𝑣+1)(𝑣+2) 3
𝐿𝑛 (𝑥 ) = 𝑦𝑛 + 𝑣 ∇𝑦𝑛 + ∇ 𝑦𝑛 + ∇ 𝑦𝑛 +
2! 3!
𝑣(𝑣+1)(𝑣+2)….(𝑣+𝑛−1) 𝑛
…..+ ∇ 𝑦𝑛 ; or
𝑛!
𝐿𝑛 (𝑥 ) = 𝑦𝑛 + 𝑣Δ𝑦𝑛−1
𝑣(𝑣 + 1) 2 𝑣 (𝑣 + 1)(𝑣 + 2) 3
+ Δ 𝑦𝑛−2 Δ 𝑦𝑛−3
2! 3!
𝑣 (𝑣 + 1)(𝑣 + 2) … . (𝑣 + 𝑛 − 1) 𝑛
+ ⋯+ Δ 𝑦0
𝑛!
Equation (4.3.3) is Newton’s backward interpolation
formula.
The error term is given by
𝑣(𝑣 + 1)(𝑣 + 2) … . (𝑣 + 𝑛) 𝑛+1 (𝑛+1)
𝑅𝑛+1 (𝑥 ) = ℎ 𝑓 (𝜉 )
(𝑛 + 1)!
Where 𝑚𝑖𝑛{𝑥, 𝑥0 , . . , 𝑥𝑛 } < 𝜉 < 𝑚𝑎𝑥 {𝑥, 𝑥0 , . . , 𝑥𝑛 }
Note: Newton’s forward interpolation formula is used to
interpolate the values of 𝑦 near the beginning of a set of
tabulator values. And Newton’s backward interpolation
formula is used to interpolate the values of 𝑦 near the
end of a set of tabulator values.
Again question is why it is so?
2.9 effect of accidental error:
29 of 65
of 65
30
30
𝒙 𝒚 ∆𝒚 ∆𝟐 𝒚 ∆𝟑 𝒚 ∆𝒏 𝒚
𝒙𝟎 𝑦𝟎
∆𝑦𝟎
𝒙𝟏 𝑦1 ∆2 𝑦𝟎
∆𝑦1 ∆3 𝑦𝟎
+𝛿
𝒙𝟐 𝑦2 ∆2 𝑦1
+𝛿
∆𝑦2 ∆3 𝑦1
+𝛿 − 3𝛿
𝒙𝟑 𝑦3 + 𝛿 ∆2 𝑦2
− 2𝛿
∆𝑦3 ∆3 𝑦2
−𝛿 + 3𝛿
30 of 65
of 65
31
31
𝒙𝟒 𝑦4 ∆2 𝑦3
+𝛿
∆𝑦4
∆𝑦𝑛−2 ∆3 𝑦𝑛−3
𝒙𝒏−𝟏 𝑦𝑛−1 ∆2 𝑦𝑛−2
∆𝑦𝑛−1
𝒙𝒏 𝑦𝑛
So for a difference table where these type of situation
occur i.e. entries are with opposite sign , means errors are
more than actual entries ,we should not proceed or
truncate the table ,and use the truncated formula.
2.10 Effect of round off error and noise level:
𝒙 𝒚 ∆𝒚 ∆𝟐 𝒚 ∆𝟑 𝒚 ∆𝒏 𝒚
𝒙𝟎 𝑦𝟎
+ 𝜀0
∆𝑦𝟎 + 𝜀1
− 𝜀0
31 of 65
of 65
32
32
𝒙𝟏 𝑦1 ∆2 𝑦𝟎 +𝜀2
+ 𝜀1
−2𝜀1
+ 𝜀0
∆𝑦1 + 𝜀2 ∆𝟑 𝑦𝟎 + 𝜀3
− 𝜀1
−3𝜀2 + 3𝜀1
+ 𝜀0
𝒙𝟐 𝑦2 ∆2 𝑦𝟏 +𝜀3
+ 𝜀2
−2𝜀2
+ 𝜀1
∆𝑦2 + 𝜀3 ∆𝟑 𝑦𝟏 + 𝜀4
− 𝜀2
−3𝜀3 + 3𝜀2
− 𝜀1
𝒙𝟑 𝑦3 ∆2 𝑦2 +𝜀4
+ 𝜀3
−2𝜀3
+ 𝜀2
∆𝑦3 + 𝜀4 ∆3 𝑦2 + ⋯
− 𝜀3
𝒙𝟒 𝑦4 ∆2 𝑦3
+ 𝜀4 +⋯
32 of 65
of 65
33
33
∆𝑦4 + 𝜀5
− 𝜀4
∆𝑦𝑛−2 + ∆3 𝑦𝑛−3 +…
𝜀𝑛−1 −
𝜀𝑛−2
𝒙𝒏−𝟏 𝑦𝑛−1 ∆2 𝑦𝑛−2
+ 𝜀𝑛−1 +⋯
∆𝑦𝑛−1
+ 𝜀𝑛
− 𝜀𝑛−1
𝒙𝒏 𝑦𝑛
+ 𝜀𝑛
of 65
34
34
𝑘 𝑘 1
|∆𝑘 𝜀𝑖 | = |∑𝑘𝑗=0(−1)𝑗 ( ) 𝜀𝑘+𝑖−𝑗 | ≤ ∑𝑘𝑗=0 ( )x2 × 10−𝑚
𝑖 𝑖
1
≤ 2𝑘 . × 10−𝑚 = 2𝑘−1 × 10−𝑚
2
So error term is 2𝑘−1 at m DP.Now if
∆𝑘 𝑦𝑖 ≤ 2𝑘−1 × 10−𝑚 means noise level arise at k-th
order difference.
From 2.9 and 2.10 it is clear that we should not take
the complete formula but a truncated version of the
formula. So depending on the position of interpolating
34 of 65
of 65
35
35
35 of 65
of 65
36
36
𝑦𝑖 = 𝑓(𝑥𝑖 ) (∀ 𝑖 = 0, 1, 2, … . . , 𝑛) we define
divided difference for nodes 𝑥𝑖 as follows :
𝑓(𝑥0 ) − 𝑓 (𝑥1 ) 𝑦0 −𝑦1 𝑦1 −𝑦0
𝑓[𝑥0 , 𝑥1 ] = = =
𝑥0 −𝑥1 𝑥0 − 𝑥1 𝑥1 − 𝑥0
= 𝑓[𝑥1 , 𝑥0 ] ; similarly
𝑓(𝑥1 )−𝑓(𝑥2 ) 𝑦 −𝑦 𝑦 −𝑦
𝑓[𝑥1 , 𝑥2 ] = = 𝑥1 −𝑥2 = 𝑥2 −𝑥1 jk
𝑥1 −𝑥2 1 2 2 1
= 𝑓[𝑥2 , 𝑥1 ] ad so on. Also
𝑓 [𝑥0 , 𝑥1 ] − 𝑓[𝑥1 , 𝑥2 ]
𝑓[𝑥0 , 𝑥1 , 𝑥2 ] =
𝑥0 −𝑥2
= 𝑓[𝑥0 , 𝑥1 , 𝑥2 ]
And in general
𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 , … , 𝑥𝑛 ]
𝑓[𝑥0 , 𝑥1 … 𝑥𝑛−1 ] − 𝑓 [𝑥1 , 𝑥2 … 𝑥𝑛 ]
=
𝑥0 −𝑥𝑛
x y 1st 2nd order 3rd order 4th order
order difference difference difference
differ
X 0 Y0
f[x0,x1]
X 1 Y1 f[x0,x1,x2]
f[x1,x2] f[x0,x1,x2,x3]
X 2 Y2 f[x1,x2,x3] f[x0,x1,x2,x3,x4]
36 of 65
of 65
37
37
f[x2,x3] f[x1,x2,x3,x4]
X 3 Y3 f[x2,x3,x4] f[x1,x2,x3,x4,x5]
f[x3,x4] f[x2,x3,x4,x5]
X 4 Y4 f[x3,x4,x5]
… f[xn-4,xn-3,xn-
2,xn-1,xn]
f[xn-2,xn- f[xn-3,xn-2,xn-
1] 1,xn]
Xn- Yn- f[xn-2,xn-
1 1 1,xn]
f[xn-
1,xn]
X n Yn
Divided difference table
2.13 Properties of divided difference (try)
1) Divided differences are symmetric w.r.t. their
arguments.
𝑓(𝑥𝑖 )
Prove this 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 , … , 𝑥𝑛 ] = ∑𝑛𝑖=0 ∏𝑛
𝑗=0(𝑥𝑖 −𝑥𝑗 )
𝑗≠𝑖
of 65
38
38
= ∑ 𝑥0 𝑘0 . 𝑥1 𝑘1 . 𝑥2 𝑘2 … . . 𝑥𝑚 𝑘𝑚
𝑘0 +𝑘1 +𝑘2 +⋯+𝑘𝑚 =𝑛−𝑚
38 of 65
of 65
39
39
of 65
40
40
of 65
41
41
of 65
42
42
2.16 Differentiation
Just like interpolation where we are approximating f(x)
by Ln(x),f’(x) can be approximated by Ln’(x) and f’’(x) by
Ln’’(x).So using Newton forward interpolation we get :
1 2𝑢−1 2
𝑓 ′ (𝑥 ) ≈ 𝐿′𝑛 (𝑥 ) = ℎ (∆𝑦0 + ∆ 𝑦0 +
2
3𝑢2 −6𝑢+2 3 1
∆ 𝑦0 + ⋯ ) 𝑓 ′′ (𝑥 ) ≈ 𝐿′′𝑛 (𝑥 ) = ℎ2 (∆2 𝑦0 +
3!
(12𝑢2−36𝑢+22)
(𝑢 − 1)∆3 𝑦0 + ∆4 𝑦0 +. . . )
24
42 of 65
of 65
43
43
Numerical Integration
3.1 Introduction
The well-known method of evaluating a definite
𝑏
integral ∫𝑎 𝑓(𝑥 )𝑑𝑥 is to find an indefinite integral or
43 of 65
of 65
44
44
44 of 65
of 65
45
45
45 of 65
of 65
46
46
𝑛
𝑓(𝑥𝑖 )
𝑓(𝑥 ) ≈ 𝐿𝑛 (𝑥 ) = 𝜔(𝑥) ∑
(𝑥 − 𝑥𝑖 )𝜔 ′ (𝑥𝑖 )
𝑖=0
46 of 65
of 65
47
47
∴ 𝐻𝑖𝑛 = (𝑏 − 𝑎 )𝐾𝑖𝑛 ; (𝑖 = 0, 1, 2, … … . , 𝑛)
(−1)𝑛−𝑖 𝑛 𝑢(𝑢−1)(𝑢−2)….(𝑢−𝑛)
where 𝐾𝑖𝑛 = ∫0 𝑑𝑢
𝑛.𝑖!(𝑛−𝑖)! (𝑢−𝑖)
(𝑖 = 0, 1, 2, … … . , 𝑛) .
Thus we have
𝐼 (𝑓) = (𝑏 − 𝑎) ∑𝑛𝑖=𝑜 𝐾𝑖𝑛 𝑦𝑖 ; 𝑦𝑖 = 𝑓(𝑥𝑖 )
Where 𝐾𝑖𝑛 is given above. This is called the
(𝑛 + 1) – points Newton- Cotes Numerical
Integration formula of the closed type.
Note 𝐼 (𝑓) = ∑𝑛𝑖=𝑜 𝐻𝑖𝑛 𝑓 (𝑥𝑖 ) is not Newton Cotes
formula, rather this can be used for unequally spaced
nodes.
3.3: Trapezoidal Rule
For 𝑛 = 1, we have from Newton-Cotes Formula
𝐼 (𝑓 ) = 𝐼𝑇 ≈ (𝑏 − 𝑎) ∑1𝑖=𝑜 𝐾𝑖𝑛 𝑦𝑖 = (𝑏 − 𝑎)[𝐾01 𝑦0 + 𝐾11 𝑦1 ]
(−1)1−0 1 1
where 𝐾01 = ∫0 (𝑢 − 1)𝑑𝑢 = 2
1.0!(1−0)!
(−1)1−1 1 1
and 𝐾11 = ∫0 𝑢𝑑𝑢 =2
1.1!(1−1)!
(𝑏−𝑎) ℎ
𝐼 (𝑓) = 𝐼𝑇 ≈ 2
[𝑦0 + 𝑦1 ] = 2 [𝑦0 + 𝑦1 ]
47 of 65
of 65
48
48
48 of 65
of 65
49
49
(−1)2−0 2 1
where 𝐾02 = ∫0 (𝑢 − 1)(𝑢 − 2)𝑑𝑢 = 6
2.0!(2−0)!
(−1)2−1 2 2
𝐾12 = ∫0 𝑢(𝑢 − 2)𝑑𝑢 =
2.1!(2−1)! 3
(−1)2−2 2 1
𝐾22 = ∫0 𝑢(𝑢 − 1)𝑑𝑢 = 6
2.2!(2−2)!
(𝑏−𝑎) ℎ
𝐼 (𝑓) = 𝐼𝑠 ≈ [𝑦0 + 4 𝑦1 + 𝑦2 ] = 3[𝑦0 + 4 𝑦1 + 𝑦2 ]
6
49 of 65
of 65
50
50
𝑥2𝑗
ℎ
∫ 𝑓 (𝑥 )𝑑𝑥 = [𝑦2𝑗−2 + 4 𝑦2𝑗−1 + 𝑦2𝑗 ]
𝑥2𝑗−2 3
𝑥
𝐼 (𝑓) = ∑𝑚
𝑗=1 ∫𝑥
2𝑗
𝑓(𝑥 )𝑑𝑥
2𝑗−2
ℎ
= 3 ∑𝑚
𝑗=1[ 𝑦2𝑗−2 + 4 𝑦2𝑗−1 + 𝑦2𝑗 ]
𝑐 ℎ
𝐼𝑠 = [{𝑦0 + 4𝑦1 + 𝑦2 } + {𝑦2 + 4𝑦3 + 𝑦4 }
3
+ ⋯ . . +{𝑦𝑛−2 + 4𝑦𝑛−1 + 𝑦𝑛 }]
ℎ
= 3 [𝑦0 + 4(𝑦1 + 𝑦3 + 𝑦5 + ⋯ . . +𝑦𝑛−1 ) +
2(𝑦2 + 𝑦4 + 𝑦6 +. . . +𝑦𝑛−2 ) + 𝑦𝑛 ]
1
Note for Simpson’s 3 rd rule n must be even.
For 𝑛 = 1, 2, 3, 4, 5, 6 the calculated values of 𝐾𝑖𝑛
are given in table
i 0 1 2 3 4 5 6
n
1 1 1
2 2
2 1 4 1
6 6 6
50 of 65
of 65
51
51
3 1 3 3 1
8 8 8 8
4 7 32 12 32 7
90 90 90 90 90
5 19 75 50 50 75 19
288 288 288 288 288 288
6 41 216 27 272 27 216 41
840 840 840 840 840 840 840
51 of 65
of 65
52
52
52 of 65
of 65
53
53
𝑐 3ℎ
where 𝐼𝑊 = [𝑦 + 𝑦𝑛 + 5 {𝑦1 + 𝑦5 + 𝑦7 + 𝑦11 + ⋯ +
10 0
𝑦𝑛−5 + 𝑦𝑛−1 } + 2{𝑦2 + 𝑦4 + 𝑦6 +. . +𝑦𝑛−2 } + 6{𝑦3 +
𝑦9 +. . . +𝑦𝑛−3 }]
53 of 65
of 65
54
54
𝑏 𝑏 𝑏
𝑓 𝑛+1 ( 𝜉)
∫ 𝑓(𝑥 )𝑑𝑥 = ∫ 𝐿𝑛 (𝑥 )𝑑𝑥 + ∫ ω(x)𝑑𝑥
𝑎 𝑎 𝑎 (𝑛 + 1)!
𝑏 𝑓 𝑛+1 ( 𝜉)
=(𝑏 − 𝑎) ∑𝑛𝑖=𝑜 𝐾𝑖 𝑦𝑖 +∫𝑎 (𝑛+1)! ω(x)𝑑𝑥 ;
Taking f(x) =1 we get ∑𝑛𝑖=𝑜 𝐾𝑖 = 1
Using above : for n=1 we get 𝐾0 = 𝐾1 ; 𝐾0 + 𝐾1 =
1
1 ; so 𝐾0 = 𝐾1 =
2
Which give trapezoidal rule. Also taking n=2 we get
𝐾0 = 𝐾2 ; 𝐾0 + 𝐾1 + 𝐾2 = 1 finding one value is
enough
1 1 1 𝑢3 𝑢2 2 1 8 4 1
𝐾2 =2.2! ∫0 𝑢(𝑢 − 1)𝑑𝑢=4 ( 3 ) | 0= 4 (3 − 2) = 6=𝐾0 ;
2
1 1 2
𝐾1 = 1 − − =
6 6 3
1
Which gives Simpson’s rd rule.
3
3.7 Deduction from Newton’s interpolation formula:
Since all the interpolation formula as same as
interpolating polynomial is unique, it should be
deduced also from any other interpolation formula.
Also remembering that here we are using equispaced
nodes so it can be done from Newton’s interpolation
formula also.
54 of 65
of 65
55
55
𝑥−𝑥0
For n=1; 𝐿1 (𝑥 ) = 𝑦0 + 𝑢∆𝑦0 where 𝑢 = ℎ
𝑏 1
∫𝑎 𝐿1 (𝑥 )𝑑𝑥 = ℎ ∫0 (𝑦0 + 𝑢∆𝑦0 )𝑑𝑢 ; 𝑎 = 𝑥0 , 𝑏 =
𝑥1
1 ℎ
= ℎ (𝑦0 + 2 ∆𝑦0 ) = 2 (𝑦0 + 𝑦1 ):Trapezoidal rule.
𝑢(𝑢−1) 2
For n=2 ; 𝐿2 (𝑥 ) = 𝑦0 + 𝑢∆𝑦0 + ∆ 𝑦0
2!
𝑏
∫𝑎 𝐿2 (𝑥 )𝑑𝑥 ; 𝑎 = 𝑥0 , 𝑏 = 𝑥2
2 𝑢(𝑢−1) 2
= ℎ ∫0 (𝑦0 + 𝑢∆𝑦0 + ∆ 𝑦0 )𝑑𝑢 ;
2!
1 1
− ℎ
=ℎ (2𝑦0 + ∆𝑦0 + 3 2
∆2 𝑦0 ) = 3 (𝑦0 + 4𝑦1 + 𝑦2 ) :
2!
1
Simpson’s rd rule.
3
55 of 65
of 65
56
56
ℎ ℎ2 ℎ3
− 2 {𝑓(𝑥0 ) + 𝑓(𝑥0 ) + ℎ𝑓 ′ (𝑥0 ) + 𝑓 ′′ (𝑥0 ) + 𝑓 ′′′ (𝑥0 ) + ⋯ }
2! 3!
ℎ2 ℎ 3 ′′ ℎ
= ′
{ℎ𝑓(𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓 (𝑥0 ) + ⋯ }
2 6
− 2 {2𝑓(𝑥0 ) + ℎ𝑓 ′ (𝑥0 ) +
ℎ 2 ′′ ℎ 3 ′′′
𝑓 (𝑥0 ) + 6 𝑓 (𝑥0 ) + ⋯ }
2
1 1 ℎ3
=ℎ3 (6 − 4) 𝑓 ′′ (
𝑥0 ) = − 12 𝑓 ′′ (𝑥0 ) + ⋯ …
ℎ3 ′′
𝐸𝑇 = − 12 𝑓 (𝜉 ) .where = 𝑥0 < 𝜉 < 𝑥1 = 𝑏 .
Clearly degree of precision of Trapezoidal rule is 1.
1
For Simpson’s rd rule: n=2
3
𝑥2
𝐸𝑠 = ∫ 𝑓(𝑥 ) 𝑑𝑥 − 𝐼𝑠
𝑥0
ℎ
𝐸𝑠 = 𝜑(𝑥2 ) − 𝜑(𝑥0 ) − 3 (𝑦0 + 4𝑦1 + 𝑦2 ), ‘
ℎ
= 𝜑(𝑥0 + 2ℎ) − 𝜑(𝑥0 ) − 3 {𝑓(𝑥0 ) + 4𝑓(𝑥0 + ℎ) + 𝑓(𝑥0 + 2ℎ)}
4ℎ ′
ℎ2 ′′ ℎ3 ′′′ ℎ4 𝑖𝑣
− {𝑓(𝑥0 ) + ℎ𝑓 (𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓 (𝑥0 ) + ⋯ }
3 2! 3! 4!
56 of 65
of 65
57
57
ℎ ′
4ℎ2 ′′ 8ℎ3 ′′′ 16ℎ4 𝑖𝑣
− {𝑓(𝑥0 ) + 2ℎ𝑓 (𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓 (𝑥0 )
3 2! 3! 4!
+⋯}
1 4 1 2 ′
4 2
( )
= ℎ𝑓(𝑥0 ){2 − − − } + ℎ 𝑓 𝑥0 {2 − − }
3 3 3 3 3
8 4 4 16 4 8
+ℎ3 𝑓 ′′ (𝑥0 ) {6 − 6 − 6} + ℎ4 𝑓 ′′′ (𝑥0 ) {24 − 18 − 18} +
32 4 16
ℎ5 𝑓 𝑖𝑣 (𝑥0 ){ − − }+……
120 72 72
1
=− 90 ℎ5 𝑓 𝑖𝑣 (𝑥0 )+……
ℎ5
𝐸𝑠 = − 𝑓 𝑖𝑣 (𝜉 ) .where = 𝑥0 < 𝜉 < 𝑥2 = 𝑏 .
90
1
Clearly degree of precision of Simpson’s rd rule is 3.
3
of 65
58
58
58 of 65
of 65
59
59
6 1
Example: Evaluate 𝐼 = ∫0 𝑑𝑥 using (i) Trapezoidal
1+𝑥
rule, (ii) Simpson’s 1/3rd rule, (iii) Weddle’s rule. Also
check by direct integration.
1
Solution: Here, we have 𝑦 = 𝑓(𝑥 ) = , 0 ≤ 𝑥 ≤ 6.
1+𝑥
6−0
Divide the interval into six parts. So ℎ = =1
6
1
Therefore, the values of 𝑦 = 1+𝑥
are:
59 of 65
of 65
60
60
𝑥 0 1 2 3 4 5 6
𝑦 = 𝑓 (𝑥 ) 1 0.5 1/3 1/4 1/5 1/6 1/7
1 1 1 1 1 1
= 2 [(1 + 7) + 2(0.5 + 3 + 4 + 5 + 6)]
= 2.021429
(ii) By Simpson’s 1/3rd rule:
6
1
∫ 𝑑𝑥
0 1+𝑥
ℎ
= [(𝑦0 + 𝑦6 ) + 4(𝑦1 + 𝑦3 + 𝑦5 )
3
+ 2(𝑦2 + 𝑦4 )]
1 1 1 1 1 1 1
= [(1 + ) + 4( + + ) + 2( + )]
3 7 2 4 6 3 5
= 1.9538730
(iii) By Weddle’s rule
60 of 65
of 65
61
61
6
1
∫ 𝑑𝑥
0 1+𝑥
3ℎ
= [(𝑦 + 𝑦6 ) + 3(𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 )
10 0
+ 2𝑦3 ]
3 1 1 1 1 1 1
= [(1 + ) + 3( + + + ) + 2( )]
8 7 2 3 5 6 4
= 1.952857
By actual integration,
6
1
∫ 𝑑𝑥 = [log(1 + 𝑥 )]60
0 1+𝑥
= log 7 − log 1
= 1.945910
𝑠 in meter 0 10 20 30 40 50 60
𝑣 in m/sec 47 58 64 65 61 52 38
61 of 65
of 65
62
62
of 65
63
63
10
= [(0.0213 + 0.0263) + 4(0.0172 + 0.0154
3
+ 0.0192)
+2(0.0156 + 0.0164)]
= 1.0627
∴ Time taken to travel 60 meters is 1.0627 seconds.
6.6 Summary
In this unit the numerical integration by using
Newton-Cotes formula(closed type), Trapezoidal rule,
Simpson’s1/3rd rule and Weddle’s rule have been
discussed and also the corresponding error terms are also
studied.
6.7 Exercises
1. Define the degree of precision of mechanical
quadrature formula. Show that the d.p. of
trapezoidal is 1.
63 of 65
of 65
64
64
𝑡𝑖𝑚𝑒 (𝑡) 0 5 10 15 20 25 30 35 40
𝑠𝑝𝑒𝑒𝑑 (𝑣) 30 24 19.5 16 13.6 11.7 10.0 8.5 7.0
Using Simpson’s rule, determine the distance
moved by the train in 40 sec.
(Ans: 606.66 m.)
64 of 65
of 65
65
65
65 of 65
of 65