Module IV
Module IV
Module-IV
NUMERICAL METHODS - 1
Introduction
Numerical analysis plays a great role in engineering and in the quantitative parts of
pure and applied science. Interpolation, the computing of values for a tabulated function at
points not in the table, is historically a most important task. Many famous mathematicians
have their names associated with procedures for interpolation: Gauss, Newton, Bessel,
Stirling. The need to interpolate began with the early studies of astronomy when the motion
of heavenly bodies was to be determined from periodic observations. Interpolation methods
demonstrate some important theory about polynomials and the accuracy of numerical
methods. Interpolating with polynomials serves as an excellent introduction to some
techniques for drawing smooth curves. These methods are the basis of many other procedures.
Among these procedures, we will focus on numerical integration in this module.
Examples
(1) 3𝑥 2 − 6𝑥 + 9 = 0
(2) (2𝑥 − 8)(𝑥 + 5) = 0
If 𝑓(𝑥) contains some other functions such as trigonometric, logarithmic, exponential etc.,
then 𝑓(𝑥) = 0 is called a transcendental equation.
Examples
(1) 2𝑒 𝑥 − 4 = 0
(2) 𝑐𝑜𝑠 𝑥 − 𝑥𝑒 𝑥 = 0
Root of an equation: The value ‘a’ of x which satisfies 𝑓(𝑥) = 0 is called a root of
𝑓(𝑥) = 0. Geometrically, a root of 𝑓(𝑥) = 0 is that value of x where the graph of
𝑦 = 𝑓(𝑥) crosses the x-axis.
The process of finding the roots of an equation is called solution of that equation. This is a
problem of great importance in Scientific and Engineering studies. To solve higher order and
transcendental equations no analytical methods exist. Such equations are solved by numerical
methods.
Intermediate value property: If 𝑓(𝑥) is continuous in the interval [a, b] and 𝑓(𝑎),𝑓(𝑏)
have different signs, then the equation 𝑓(𝑥) = 0 has at least one root between x=a and x=b.
Initial approximation
The common method used to obtain the initial approximation to the root is based upon the
intermediate value theorem which states that “If f(x) is a continuous function in the closed
interval [a, b] and if f(a) and f(b) are of opposite signs [i.e. f(a).f(b) < 0] then the equation f(x)
= 0 has atleast one simple root (or odd number of roots) lying between a and b”. By using this
property we take a (or) b as the initial approximation of the root to start the Iterative process.
This is method of finding the real root of an equation𝑓(𝑥) = 0. Here we choose two points
𝑥0 , 𝑥1 such that 𝑓(𝑥0 ) and 𝑓(𝑥1 ) are of opposite signs i.e., the graph of y=f(x) crosses the x-
axis between these points a root lies between 𝑥0 𝑎𝑛𝑑𝑥1 and consequently𝑓(𝑥0 )𝑓(𝑥1 ) < 0.
Consider the equation f(x) = 0, where f(x) may be Algebraic (or) Transcendental which is
known to have a root between [x0, x1] then𝑓(𝑥0 )𝑓(𝑥1 ) < 0.
Approximate the function f(x) by the straight line joining the points [x0, f(x0)] and[x1, f(x1)].
Let this straight line cut the x-axis at x2.
The equation of the chord joining the two points [x0, f(x0)] and [x1, f(x1)] is given by,
𝑦−𝑓(𝑥0 ) 𝑥−𝑥 𝑓(𝑥 )−𝑓(𝑥 )
= 𝑥 −𝑥0 ⇒ 𝑦 − 𝑓0 = 𝑥1 −𝑥 0 (𝑥 − 𝑥0 ) ---------(1)
𝑓(𝑥 )−𝑓(𝑥 )
1 0 1 0 1 0
The method consists in replacing the curve AB by means of the chord AB and taking the point
of intersection of the chord with x-axis as an initial approximation to the root. The point of
intersection is obtained by putting y = 0
𝑓(𝑥 )−𝑓(𝑥 )
∴Equation (1) becomes, 0 − 𝑓(𝑥0 ) = 𝑥1 −𝑥 0 (𝑥2 − 𝑥0 )
1 0
𝑓(𝑥0 )(𝑥1 −𝑥0 )
⇒ 𝑥2 − 𝑥0 = − 𝑓(𝑥1 )−𝑓(𝑥0 )
(𝑥1 −𝑥0 )
⇒ 𝑥2 = 𝑥0 − 𝑓(𝑥 𝑓(𝑥0 )
1 )−𝑓(𝑥0 )
𝑥0 𝑓(𝑥1 )−𝑥1 𝑓(𝑥0 )
𝑥2 = ----(2)
𝑓(𝑥1 )−𝑓(𝑥0 )
Problems
II-Semester: Mathematics- II for Computer Science & Engineering stream (BMATS201)
P a g e 3 | 35
RV Institute of Technology & Management ®
1. Find a real root of the equation 𝑥 3 -2x-5=0 by the method of false position correct to three
decimal places.
Solution: Let f(x) = 𝑥 3 - 2x -5
f(1) = -6(-ve) f(2) = -1(-ve), f(3) = 16(+ve)
A root lies between 2 and 3
therefore 𝑥0 = 2 𝑥1 = 3 𝑓(𝑥0 ) = −1 𝑓(𝑥1 ) = 16
By the method of false position,
𝒙 𝒇(𝒙 )−𝒙𝟏 𝒇(𝒙𝟎 )
𝒙𝟐 = 𝟎 𝒇(𝒙𝟏 )−𝒇(𝒙
𝟏 𝟎 )
1
We get, 𝑥2 = 2 + 17 = 2.0588
Since𝑓(2.0588) = −0.3908(−𝑣𝑒), therefore the root lies between 2.0588 and 3.
Now, 𝑥0 = 2.0588, 𝑥1 = 3, 𝑓(𝑥0 ) = −0.3908, 𝑓(𝑥1 ) = 16
0.9412
𝑥3 = 2.0588 − (−0.3908) = 2.0813
16.3908
Repeating this process, the successive approximations are 𝑥4 =
2.0862,𝑥5 =2.0915,𝑥6 =2.0934, x7 =2.0941,𝑥8 =2.0943
Hence, the root is 2.094 correct to 3 decimal places.
2. Find the root of the equation xe𝑥 =cosx using Regula - falsi method correct to four decimal
places.
Solution: Let 𝑓(𝑥) = 𝑐𝑜𝑠 𝑥 − 𝑥𝑒 𝑥 = 0
f(0) = 1(+ve), f(1) = -2.17798(-ve)
root lies between 0 and 1
therefore, 𝑥0 = 0 , 𝑥1 = 1 , 𝑓(𝑥0 ) = 1 , 𝑓(𝑥1 ) = −2.17798
By the method of false position,
𝑥0 𝑓(𝑥1 ) − 𝑥1 𝑓(𝑥0 )
𝑥2 =
𝑓(𝑥1 ) − 𝑓(𝑥0 )
1
𝑥2 = 0 + 3.17798 = 0.31467
Since f(0.31467) = 0.51987
The root lies between 0.31467 and 1
therefore 𝑥0 = 0.31467 , 𝑥1 = 1 , 𝑓(𝑥0 ) = 0.51987 , 𝑓(𝑥1 ) = −2.17798
0.68533
𝑥3 = 0.31467 − 2.69785 (0.51987) = 0.44673
The successive approximations are
𝑥4 = 0.49402, 𝑥5 =0.50995,𝑥6 =0.51520,
x7 =0.51692,𝑥8 =0.51748, 𝑥9 =0.51767,𝑥10 =0.51775Hence the root is 0.5177.
3. Find a real root of the equation xlog10 𝑥 = 1.2 by Regular - Falsi method correct to four
decimal places.
Solution: Let 𝑓(𝑥) = xlog10 x-1.2
𝑓(1) = −𝑣𝑒, 𝑓(2) = −𝑣𝑒 𝑎𝑛𝑑 𝑓(3) = +𝑣𝑒
Therefore a root lies between 2 and 3
Now, 𝑥0 = 2 , 𝑥1 = 3 , 𝑓(𝑥0 ) = −0.59794 , 𝑓(𝑥1 ) = 0.23136
By Regular-Falsi method
𝒙 𝒇(𝒙 )−𝒙𝟏 𝒇(𝒙𝟎 )
𝒙𝟐 = 𝟎 𝒇(𝒙𝟏 )−𝒇(𝒙
𝟏 𝟎 )
= 2.72102
Newton-Raphson method
Let f(x) = 0 ---------- (1), be the given equation, where f(x) may be Algebraic (or)
Transcendental and x0be the initial approximation to the root.
Let x1= x0+ h ---------- (2) be the exact root of the equation f(x) = 0, where h is very small
quantity.
From (1), we have f(x1) = f(x0+ h) = 0 ---------- (3)
Expanding f(x0+ h) by Taylor’s series expansion we get,
ℎ ℎ2 ℎ3
𝑓(𝑥0 + ℎ) = 𝑓(𝑥0 ) + 1! 𝑓′(𝑥0 ) + 2! 𝑓′′(𝑥0 ) + 3! 𝑓′′′(𝑥0 )+. . .. ------------(4)
Since f(x1) = f(x0+ h) = 0 and h is very small, so higher powers of h can be neglected.
∴Equation (3) becomes,
𝑓(𝑥0 + ℎ) = 𝑓(𝑥0 ) + ℎ𝑓′(𝑥0 )
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − ---------(6)
𝑓 ′ (𝑥𝑛 )
The formula given in (6) is known as Newton-Raphson Iterative formula to find the root of the
equation f(x) = 0.
Problems
1. Find by Newton’s method, the real root of the equation 3x = cos x+1.
Solution: Let 𝑓(𝑥) = 3x-cosx-1
𝑓(0) = -2 = -ve𝑓(1) = 1.4597 = +ve
So a root of 𝑓(𝑥) = 0 lies between 0 and 1.
It is nearer to 1 let us take 𝑥0 = 0.6
𝑓 ′ (𝑥) = 3+sinx
Therefore, Newton’s iteration formula is
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓 ′ (𝑥𝑛 )
3x𝑛 -cosx𝑛 -1
𝑥n+1 = 𝑥𝑛 −
3 + sinx𝑛
𝑥𝑛 sinx𝑛 + cosx𝑛 + 1
𝑥n+1 =
3 + sinx𝑛
Put n = 0 first approximation 𝑥1 is
𝑥0 sinx0 + cosx0 + 1
𝑥1 = = 0.6071
3 + sinx0
Put n = 1 second approximation 𝑥2 is
𝑥1 sinx1 + cosx1 + 1
𝑥2 = = 0.6071
3 + sinx1
clearly 𝑥1 =𝑥2
Hence the desired root is 0.6071 correct to 4 decimal places.
2. Use the Newton-Raphson method to find a root of the equation
𝑥 3 − 0.165𝑥 2 + 3.993 × 10−4 = 0
Solution: Let f (x) = x3 − 0.165x 2 + 3.99310−4
f (x) = 3x 2 − 0.33x
By using Intermediate value property an initial guess of the root of f (x ) = 0 is 𝑥0 = 0.05.
The Newton’s iteration formula is
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓 ′ (𝑥𝑛 )
Put n = 0 first approximation 𝑥1 is
𝑓(𝑥0 )
𝑥1 = 𝑥0 −
𝑓 ′ (𝑥0 )
= 0.05 −
(0.05)3 − 0.165(0.05)2 + 3.993 10−4
3(0.05) − 0.33(0.05)
2
1.11810−4
= 0.05 −
− 9 10−3
= 0.05 − (− 0.01242 )
= 0.06242
Put n = 1 second approximation 𝑥2 is
𝑓(𝑥 )
𝑥2 = 𝑥1 − 𝑓′ (𝑥1 )
1
= 0.06242 −
(0.06242)3 − 0.165(0.06242)2 + 3.993 10−4
3(0.06242) − 0.33(0.06242)
2
− 3.9778110−7
= 0.06242 −
− 8.9097310−3
(
= 0.06242 − 4.464610−5 )
= 0.06238
Put n = 2 third approximation 𝑥3 is
𝑓(𝑥2 )
𝑥3 = 𝑥2 −
𝑓 ′ (𝑥2 )
= 0.06238 −
(0.06238)3 − 0.165(0.06238)2 + 3.993 10−4
3(0.06238) − 0.33(0.06238)
2
4.44 10−11
= 0.06238 −
− 8.9117110−3
(
= 0.06238− − 4.982210−9 ) = 0.06238
Hence the desired root is 0.06238.
3. Using Newton’s iterative method, find the real root of 𝑥log10 𝑥 = 1.2 .
Solution: 𝑓(𝑥) = 𝑥log10 𝑥 − 1.2
𝑓(1) = -1.2,𝑓(2) = 0.59794,𝑓(3) = 0.23136
so 𝑎 root of 𝑓(𝑥) = 0 lies between 2 and 3.
Take 𝑥0 = 2
1
𝑓 ′ (𝑥) = log10 𝑥 + x. 𝑥 .log10 𝑒 = log10 𝑥 + 0.43429.
The Newton’s iteration formula is
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓 ′ (𝑥𝑛 )
Put n = 0 first approximation 𝑥1 is
𝑓(𝑥 )
𝑥1 = 𝑥0 − 𝑓′ (𝑥0 ) = 2.81
0
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓 ′ (𝑥𝑛 )
Put n = 0 first approximation 𝑥1 is
𝑓(𝑥 )
𝑥1 = 𝑥0 − 𝑓′ (𝑥0 ) = 0.65307940
0
𝑥𝑛 2 − 12 1 12
𝑥𝑛+1 = 𝑥𝑛 − = (𝑥𝑛 + )
2𝑥𝑛 2 𝑥𝑛
Since f(3) =-3 , f(4) = 4
Root lies between 3 and 4
x 0 = 3.5
1 12
x1 = x 0 + = 3.4643
2 x0
1 12
x2 = 3.4643+ =3.4641
2 3.4643
x 3 = 3.4641
since 𝑥2 = 𝑥3 up to 4 decimal places, therefore √12 = 3.4641.
Finite Differences
The finite difference deals with the changes in the value of the function (dependent variable)
due to the changes in the values of independent variable. The values of the independent
variable x are called Arguments and the corresponding values of dependent variables y are
called Entries.
If 𝑦0 , 𝑦1 , 𝑦2 ,…… 𝑦𝑛 denote the set of values of the function y=f(x).
Then 𝑦0 =𝑦1 - 𝑦2 , 𝑦1 =𝑦2 - 𝑦1 ........., 𝑦𝑛−1 =𝑦𝑛 -𝑦𝑛−1 are called the First Forward Differences
of the function y=f(x) where ∆ is called the forward difference operator. The differences are
called first forward differences denoted by 𝑦0 , 𝑦1 𝑦𝑛 second forward differences
and are denoted by 𝑦0 , 𝑦1 ,......, 𝑦𝑛−1 .
i.e. 𝑦0 = 𝑦1 - 𝑦0 , 𝑦1 = 𝑦2 - 𝑦1 , ..., 𝑦𝑛−1 = 𝑦𝑛 - 𝑦𝑛−1
Similarly, we can define third, fourth forward differences etc.
In general, the nth forward differences is defined by the equation, ∆𝑛 𝑦𝑖 = ∆𝑛−1 𝑦𝑖+1 − ∆𝑛−1 𝑦𝑖
x y=f(x) ∆𝑦 ∆2 𝑦 ∆3 𝑦 ∆4 𝑦 ∆5 𝑦
𝑥0 𝑦0
Δ𝑦0
𝑥1 = 𝑥0 + ℎ 𝑦1 Δ2 𝑦0
Δ𝑦1 Δ3 𝑦0
𝑥2 = 𝑥0 + 2ℎ 𝑦2 2
Δ 𝑦1 Δ4 𝑦0
Δ𝑦2 Δ3 𝑦1 Δ5 𝑦0
𝑥3 = 𝑥0 + 3ℎ 𝑦3 2
Δ 𝑦2 4
Δ 𝑦1
Δ𝑦3 3
Δ 𝑦2
𝑥4 = 𝑥0 + 4ℎ 𝑦4 Δ2 𝑦3
Δ𝑦4
𝑥5 = 𝑥0 + 5ℎ 𝑦5
Here 𝑦0 is called the First Entry and ∆𝑦0 , ∆2 𝑦0 , ∆3 𝑦0 ,...... ∆5 𝑦0 are called the Leading
Differences.
Example
cos 2x = {cos 2 (𝑥 + ℎ) − cos 2𝑥}
= cos 2 (x + h) − cos 2x
= [cos2(x + 2h) – cos 2 (x + h)] – [cos 2 (x + h) – cos 2x]
= - 2 sin (2x + 3h) sin h + 2 sin (2x + h) sin h
= - 2 sin h [sin (2x + 3h) – sin (2x + h)]
= - 2 sin h [2 cos (2x + 2h) sin h] = -4 sin2 h cos (2x + 2h)
Backward Difference
Consider the function y = f(x). If 𝑦0 , 𝑦1 , 𝑦2 ,...., 𝑦𝑛 denote the set of values of y.
Then ∇𝑦1=𝑦1− 𝑦0, ∇𝑦2 = 𝑦2 − 𝑦1 , .........,∇𝑦𝑛 = 𝑦𝑛 − 𝑦𝑛−1 are called the First Backward
Differences and is called the backward difference operator.
The second backward difference of the function is given by,
∇2 𝑦2 = ∇𝑦2 − ∇𝑦1, ∇2 𝑦3 = ∇𝑦3 − ∇𝑦2 , …….., ∇𝑛 𝑦𝑛 = ∇𝑦𝑛 − ∇𝑦𝑛−1
Similarly, we can define higher order differences.
In general, the nth backward difference is given by ∇𝑛 𝑦𝑖 = ∇𝑛−1 𝑦𝑖 − ∇𝑛−1 𝑦𝑖−1 .
x y=f(x) ∇𝑦 ∇2 𝑦 ∇3 𝑦 ∇4 𝑦 ∇5 𝑦
𝑥0 𝑦0
𝑥1 = 𝑥0 + ℎ ∇𝑦1
𝑦1 ∇2 𝑦2
∇𝑦2 ∇2 𝑦3
𝑥2 = 𝑥0 + 2ℎ 𝑦2 2 ∇4 𝑦4
∇ 𝑦3
∇𝑦3 ∇3 𝑦4 ∇5 𝑦5
𝑥3 = 𝑥0 + 3ℎ 𝑦3
∇2 𝑦4 ∇4 𝑦5
∇𝑦4 3
∇ 𝑦5
𝑥4 = 𝑥0 + 4ℎ
𝑦4
∇𝑦5 ∇2 𝑦5
𝑥5 = 𝑥0 + 5ℎ
𝑦5
Differences of a Polynomial
The nth differences of a polynomial of the nth degree are constant and all higher order
differences are zero.
Let f(x) =𝑎0 𝑥 𝑛 + 𝑎1 𝑥 𝑛−1 +. . . +𝑎𝑛 , then
n f(x) = 𝑎0 n (n - 1) (n - 2) … 1. ℎ𝑛 =𝑎0 n! ℎ𝑛 ........………………….(1)
𝑛+1 𝑛+2
and then for higher orders ∆ 𝑓(𝑥)=∆ 𝑓(𝑥) = . . . = 0. …….……….(2)
Problems
x 5 10 15 20 25 30
y 9962 9848 9659 9397 9063 8660
2. Construct the finite difference table for the function f(x) = 𝑥 3 +x+1 where x takes the values
0,1,2,3,4,5,6. Identify the leading forward and backward differences. Hence find ∆2 𝑦1, ∇3 𝑦5.
Solution:
x y First Second Third Fourth
difference difference difference difference
0 1
1 3
6
2 11
6
3 31
6
4 69
6
5 131
6 223
The leading forward differences are 2, 6, 6 and leading backward differences are 92, 30, 6.
∆2 𝑦1 = 12, ∇3 𝑦5 = 6 .
Note: Third differences are constants and higher order differences are zero as f(x) is a
polynomial of third degree.
Remark
Newton’s Forward Interpolation Formula is used to interpolate the values of y near the
beginning of the set of tabulated values or for extrapolating values of y to the left of the
beginning. Newton’s Backward Interpolation Formula is used to interpolate the values of y
near the end of the set of tabulated values or for extrapolating values of y to the right of the last
tabulated value y.
Problems
1. The following table gives the population of a town during the last six census. Estimate the
increase in the population during the period from 1975 to 2019:
Year 1971 1981 1991 2001 2011 2021
Population (in 12 15 20 27 39 52
thousandth)
Solution: Now the difference table is:
x y y y y y y
1971 12
1981 15 2 0
1991 20 2 −
3
2001 27 5 −
-4
2011 39 1
2021 52
Hence, we have
First differences: 3, 5, 7, 12, 13; Second differences: 2, 2, 5, 1; Third differences: 0, 3, -4;
Fourth differences: 3, -7; fifth differences: -10;
Using Newton’s forward interpolation formula, we get
𝑥−𝑥0 1975−1971
𝑝= = =0.4
ℎ 10
𝑝(𝑝−1) 𝑝(𝑝−1)(𝑝−2)
f(1975) = 𝑦0 + p∆𝑦0 + ∆2 𝑦0 + ∆3 𝑦0 +……. = 12.54=13
2! 3!
Using Newton’s backward interpolation formula we get,
𝑥−𝑥𝑛 2019−2021
𝑝= = = - 0.2
ℎ 10
𝑝(𝑝+1) 𝑝(𝑝+1)(𝑝+2)
f(2019) = 𝑦𝑛 + p∇𝑦𝑛 + ∇2 𝑦𝑛 + ∇3 𝑦𝑛 …….= 50.003=50
2! 3!
the increase in the population during the period from 1975 to 2019:
f(2019)-f(1975)=50-13 = 37.
2. The table gives the distance in nautical miles of the visible horizon for the given heights
in feet above the earth’s surface.
Solution:
f(160)=13.03+0.402+0.0192+0.00384+0.00168
0.2(1.2)
f(410)=21.27+0.2(1.37)+ 2
(-0.11)+…………….
3. From the following table, estimate the number of students who obtained marks between 40 and
45:
No. of students(y): 31 42 51 35 31
x y y y y y
40 31
50 73
−
60 124 −
70 159 −
80 190
To find y(45) i.e. number of students with marks less than 45.
𝑥−𝑥0 5
Taking 𝑥0 = 40, x=45, h=10, p = ℎ
= 10 = 0.5
= 47.87
4. Compute the number of men getting wages between Rs. 10 and 15 from the following data:
Wages in Rs. : 0 - 10 10 - 20 20 - 30 30 - 40
Frequency: 9 30 35 42
To find y(15) i.e. number of men getting wages less than 15.
II-Semester: Mathematics- II for Computer Science & Engineering stream (BMATS201)
P a g e 16 | 35
RV Institute of Technology & Management ®
𝑥−𝑥 5
Taking 𝑥0 = 10, x=15, h=10, p = ℎ 0 = 10 = 0.5
Using Newton’s Forward Interpolation formula, we get,
𝑝(𝑝−1) 𝑝(𝑝−1)(𝑝−2) 3
y(45) = 𝑦0 + 𝑝∆𝑦0 + 2 ∆2 𝑦0 + ∆ 𝑦0 + ⋯ … … … … …
6
0.5(−0.5) 0.5(−0.5)(−1.5)
=9+0.5(30)+ 2 (5)+ (2)
6
= 23.5
The number of men getting wages less than 15 is 23.5 ≅24.
But the number of men getting wages between Rs.10 and Rs.15 = 24-9=15.
x 0 1 2 3
f(x) 1 2 1 10
𝑥−𝑥0 𝑥−0
Here, 𝑥0 = 0, h = 1, p= = = x, ∆𝑦0 =1, ∆2 𝑦0 = -2, ∆3 𝑦0 =12,
ℎ 1
𝑥(𝑥−1) 𝑥(𝑥−1)(𝑥−2)
f(x) = 1+x(1)++ (-2)+ (12) = 2x3 – 7x2 + 6x +1 is the required polynomial.
2! 3!
Exercise
1. Fit a cubic polynomial to the following data using suitable interpolation formula.
x 0 1 2 3
f(x) -2 2 12 34
2. Using Newton-Gregory Interpolation formulae, estimate f (0.12) from the following data.
3. Apply Newton’s backward difference interpolation formula to find f(7.5) from the
following table:
x 1 2 3 4 5 6 7 8
f(x) 1 8 27 64 125 216 343 512
4. Using Newton -Gregory Interpolation formulae, find tan170 from the following data.
x 0 4 8 12 16 20 24
f(x) 0 0.0699 0.1405 0.2126 0.2867 0.3640 0.4452
Problems
1. Apply Lagrange’s formula to find f(5) and f(6) given that f(1) =2, f(2)=4,f(3)=8,f(7)=128
and explain why the results differ from those obtained by f(x) = 2𝑥 .
Solution: 𝑥0 = 1 𝑥1 = 2 𝑥2 = 2 𝑥3 = 7
By Lagrange’s formula, we have
(𝑥−2)(𝑥−3)(𝑥−7) (𝑥−1)(𝑥−3)(𝑥−7)
f (x) = (1−2)(1−3)(1−7)
𝑓(𝑥0 ) + (2−1)(2−3)(2−7) 𝑓(𝑥1 ) +
(𝑥−1)(𝑥−3)(𝑥−17) (𝑥−1)(𝑥−2)(𝑥−3)
(3−1)(3−2)(1−7)
𝑓(𝑥2 ) + (7−1)(7−2)(7−3)
𝑓( 𝑥3 )
(𝑥−2)(𝑥−3)(𝑥−7) (𝑥−1)(𝑥−3)(𝑥−7)
f (x) = (2) + (4) +
−12 5
(𝑥−1)(𝑥−2)(𝑥−17) (𝑥−1)(𝑥−2)(𝑥−3)
(8) + (128)
−8 120
(3)(2)(−2) (4)(2)(−2) (4)(3)(−2) (4)(3)(2)
f (5) = (2) + (4) + (8) + (128)
−12 5 −8 120
= 2-12+20+64 = 74
But actual values of f(5) and f(6) are f(5) = 25 = 32 and f(6) = 26 = 64.
The difference in values of f(5) and f(6) are due to the assumption of f(x) as a polynomial,
when it is an exponential function of the form 2𝑥 .
2. Using Lagrange’s method find the value of y when 𝑥 = 2.5 from the following data:
𝑖 0 1 2 3
𝑥𝑖 0 0.5 1.5 3.0
𝑦𝑖 −6 −1.875 0.375 0
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 )(𝑥 − 𝑥3 )
𝐿0 (𝑥) =
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 )(𝑥0 − 𝑥3 )
(2.5 − 0.5)(2.5 − 1.5)(2.5 − 3.0)
=
(0 − 0.5)(0 − 1.5)(0 − 3.0)
2.0 × 1 × (−0.5)
= = 0.4444
(−0.5) × (−1.5) × (−3.0)
(𝑥 − 𝑥0 )(𝑥 − 𝑥2 )(𝑥 − 𝑥3 )
𝐿1 (𝑥) =
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 )(𝑥1 − 𝑥3 )
(2.5−0)(2.5−1.5)(2.5−3.0) 2.5×1×(−0.5)
= (0.5−0)(0.5−1.5)(0.5−3.0) = 0.5×(−1.0)×(−2.5) = −1.0
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥3 )
𝐿2 (𝑥) =
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )(𝑥2 − 𝑥3 )
(2.5−0)(2.5−0.5)(2.5−3.0) 2.5×2×(−0.5)
= (1.5−0)(1.5−0.5)(1.5−3.0) = 1.5×1×(−1.5) = 1.1111
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 )
𝐿3 (𝑥) =
(𝑥3 − 𝑥0 )(𝑥3 − 𝑥1 )(𝑥3 − 𝑥2 )
(2.5−0)(2.5−0.5)(2.5−1.5) 2.5×2.0×1
= (3.0−0)(3.0−0.5)(3.0−1.5) = 3.0×2.5×1.5 = 0.4444
Therefore,
𝑦(2.5) = 0.4444 × (−6) + (−1.0) × (−1.875) + (1.1111)(0.375) + (0.4444) × 0
= − 0.375
3. By using the Lagrange’s interpolation formula to fit a polynomial to the data given
x 0 1 3 4
y -12 0 6 12
Hence, find y when x = 2
Solution:
𝑥0 = 0 𝑥1 = 1 𝑥2 = 3 𝑥3 = 4
𝑦0 = −12 𝑦1 = 0 𝑦2 = 6 𝑦2 = 12
By Lagrange’s formula
(𝑥−1)(𝑥−3)(𝑥−4) (𝑥−0)(𝑥−3)(𝑥−4) (𝑥−0)(𝑥−1)(𝑥−4)
y= (0−1)(0−3)(0−4)
(−12) + (1−0)(1−3)(1−4) (0) + (3−0)(3−1)(3−4) (6) +
(𝑥−0)(𝑥−1)(𝑥−3)
(12)
(4−0)(4−1)(4−3)
4. Find the polynomial 𝑓(𝑥) by using Lagrange’s interpolation formula and hence find𝑓(3)
for
x 0 1 2 5
f (x) 2 3 12 147
Solution:
By Lagrange’s formula
(𝑥−1)(𝑥−2)(𝑥−5) (𝑥−0)(𝑥−2)(𝑥−5) (𝑥−0)(𝑥−1)(𝑥−5)
y= (0−1)(0−2)(0−5)
(2) + (1−0)(1−2)(1−5) (3) + (2−0)(2−1)(2−5) (12) +
(𝑥−0)(𝑥−1)(𝑥−2)
(147)
(5−0)(5−1)(5−2)
y = 𝑥 3 +𝑥 2 – x+2
Hence, f(3) = 5
Newton’s General Interpolation Formula (Divided – difference)
The Lagrange’s interpolation formula, derived earlier has the disadvantage that if another
interpolation point were added, then we have to change the Lagrange’s interpolation formula
completely. Therefore, we seek an interpolation polynomial which has the property that a
polynomial of higher degree may be derived from it by simply adding new terms. Newton’s
general interpolation formula is one such formula for which we need divided differences.
Let (𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), . . . . . . . . . , (𝑥𝑛 , 𝑦𝑛 ) be the given (𝑛 + 1) points. Then the divided
differences of orders 1,2, . . . . . . . . . . . ., 𝑛 are defined as
2. Using Newton’s divided difference formula, find 𝑓(8)&𝑓(15) from the following data:
𝑥: 4 5 7 10 11 13
𝑓(𝑥): 48 100 294 900 1210 2028
Solution: The divided difference table is
𝑥 𝑦 1𝑠𝑡 divided 2𝑛𝑑 divided 3𝑟𝑑 divided 4𝑡ℎ divided
differences differences differences differences
4 48
52
5 100 15
97 1
7 294 21 0
202 1
10 900 27 0
310 1
11 1210 33
409
13 2028
3. Given that 𝑓(0) = 8, 𝑓(1) = 68, & 𝑓(5) = 123. Construct a divided difference table.
Using the table determine the value of 𝑓(2).
Solution: The divided difference table is
𝑥 -4 -1 0 2 5
𝑓(𝑥) 1245 33 5 9 1335
Exercises
1. Using Newton’s formula for divided differences find an interpolating polynomial for the
following data:
𝑥: 0.0 0.5 1.0 2.0
𝑓(𝑥): 0.00 0.57 1.46 5.05
Hence find 𝑓(0.3)&𝑓(1.6).
2. Given the data:
𝑥: 5 7 11 13 17
𝑓(𝑥): 150 392 1452 2366 5202
Find 𝑓(9) using the Newton’s divided difference formula.
3. For the data given in the following table, find the polynomial approximation of 𝑓(𝑥) using
Newton’s divided difference formula:
𝑥: 2 4 5 6 8 10
𝑓(𝑥): 10 96 196 350 868 1746
4. Given 𝑢20 = 24.37, u 22 = 49 .28, 𝑢29 = 162.86&𝑢32 = 240.5, find 𝑢28 by using the
Newton’s divided difference formula.
5. Given 𝑙𝑜𝑔10 3 00 = 2.4771, log10 304 = 2.4829, 𝑙𝑜𝑔10 3 05 = 2.4843, &
𝑙𝑜𝑔10 3 07 = 2.4871, find by divide difference formula the value of 𝑙𝑜𝑔10 3 06.
6. Given 𝑓(0) = −18, 𝑓(1) = 0, 𝑓(3) = 0, 𝑓(5) = −248, 𝑓(6) = 0, 𝑓(9) = 13104, find
𝑓(𝑥).
7. Applying the method of divided differences for interpolation, find the value of 𝑦 when
𝑥 = 5, given
𝑥: 4.50 4.55 4.70 4.90 5.15
𝑦: 1345 1470 2010 3815 10965
8. If 𝑦(1) = −3, 𝑦(3) = 9, 𝑦(4) = 30, & 𝑦(6) = 132, find the interpolating polynomial that
takes these values.
Answers
1. 0.2834𝑥 3 + 0.2149𝑥 2 + 0.9617𝑥. 𝑓(0.3) = 0.3155&𝑓(1.6) = 3.2497
2. 810 3. 2𝑥 3 − 3𝑥 2 + 5𝑥 − 4 4. 141.938 5. 2.4857
5 4 3 2
6. 𝑥 − 9𝑥 + 18𝑥 − 𝑥 + 9𝑥 − 18 7. 5745 8. 𝑥 3 − 3𝑥 2 + 5𝑥 − 6
Numerical Integration
Numerical integration is a process of evaluating a definite integral from a set of tabulated values
of the integrand f(x). If the integrand is a function of a single-valued, then the numerical
integration is known as Quadrature.
Newton – Cote’s Quadrature formula
𝑏
𝐿𝑒𝑡 𝐼 = ∫𝑎 𝑓(𝑥)dx,
where f (x) takes the value 𝑦0, 𝑦1 , 𝑦2 ……..,𝑦𝑛 for x = 𝑥0 ,𝑥1 ,𝑥2 ….,𝑥𝑛 .Divide the interval (a, b)
into n sub-intervals of width h i.e. h = (b-a)/n, so that
𝑥0 = a, 𝑥1 =𝑥0 +h , 𝑥2 = 𝑥0 +2h,…..,𝑥𝑛 = 𝑥0 + nh = b
𝑥 +𝑛ℎ
Now, I = ∫𝑥 0 𝑓(𝑥) dx.
0
Let x=𝑥0 +rh then dx = h dr. Also when x = 𝑥0 , r = 0 and when
x = 𝑥0 + nh, r = n,
𝑛
I=∫0 𝑓( 𝑥0 +rh) h dr.
Now by Newton’s forward interpolation formula, we have
𝑛 𝑟(𝑟−1) 𝑟(𝑟−1)(𝑟−2)
I = h∫0 [ 𝑦0 + r 𝛥 𝑦0 + 𝛥2 𝑦0 + 𝛥3 𝑦0 +……] dr
2! 3!
Integrating terms by terms, we get
𝑟2 1 𝑟3 𝑟2 1 𝑟4
I = h[𝑦0 r + 𝛥𝑦0 + (3 - ) 𝛥2 𝑦0 + 3! ( - 𝑟 3 + 𝑟 2 ) 𝛥3 𝑦0 +……]𝑛0
2 2! 2 4
𝑛 1 𝑛2 𝑛 1 𝑛2
I = nh [𝑦0 +2(𝛥𝑦0 ) + 2!( - 2 ) (𝛥2 𝑦0) + 3! ( 4 − 𝑛2 + 𝑛 ) (𝛥3 𝑦0 ) +….].
3
3(0.2)
= [(1.38629 + 1.64865) + 3(1.43508 + 1.48160 + 1.56861 + 1.60943)
8
+ 2(1.52605)]
0.6
= [3.034953 + 18.28416 + 3.052]
8
0.6
= [24.371213]=1.82784
8
6 𝑑𝑥
2. Evaluate ∫0 using (a) Simpsons 1/3rd rule (b) Simpsons 3/8th rule
1+𝑥 2
Solution:
Dividing the interval (0, 6) into six equal parts of width h = 6−0
6
=1
x 0 1 2 3 4 5 6
f(x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027
0.6 2
3. Evaluate ∫0 𝑒 −𝑥 𝑑𝑥 by taking 6 intervals using (a) Simpsons 1/3rd rule (b) Simpsons
3/8th rule
Solution: Dividing the interval (0, 0.6) into six equal parts of width h = 0.6−0
6
=0.1
4. A solid of revolution is formed by rotating about the x-axis, the area between the x-axis,
the line x=0 and x=1 and a curve through the points with the following coordinates.
x 0.00 0.25 0.50 0.75 1.00
y 1.0000 0.9896 0.9589 0.9089 0.8415
Solution:
1
The volume of the solid generated is given by ∫0 𝜋 𝑦 2 dx
1
By Simpson’s 3 rule, we have (here h = 0.25)
1 ℎ
∫0 𝜋 𝑦 2 dx = 𝜋 3 [(𝑦0 2 + 𝑦4 2 ) + 4( 𝑦1 + 𝑦3 2 ) + 2(𝑦2 2 )]
0.25
= 𝜋 {1+ (0.8415)2 + 4[ (0.9896)2 + (0.9089)2 ] + 2(0.9589)2 }
3
(0.25)(3.1416)
= [1.7081 + 4(0.9793 + 0.8261) + 1.8389]
3
= (0.2618) [1.7081 + 7.2216 + 1.8389]
= (0.2618) (10.7686) = 2.8192.
Self-Study
Bisection method
One of the first numerical methods developed to find the root of a nonlinear equation
𝑓(𝑥) = 0 was the bisection method (also called Binary-Search method). The method is based
on the following theorem:
Theorem: An equation𝑓(𝑥) = 0, where 𝑓(𝑥) is a real continuous function, has at least one root
between 𝑥ℓ and 𝑥𝑢 if 𝑓(𝑥ℓ )𝑓(𝑥𝑢 ) < 0 (Fig. 4.4).
Note that if 𝑓(𝑥ℓ )𝑓(𝑥𝑢 ) > 0, there may or may not be any root between 𝑥ℓ and 𝑥𝑢 .
If𝑓(𝑥ℓ )𝑓(𝑥𝑢 ) < 0, then there may be more than one root between 𝑥ℓ and 𝑥𝑢 . So, the theorem
only guarantees one root between 𝑥ℓ and 𝑥𝑢 .
Since the method is based on finding the root between two points, the method falls under the
category of bracketing methods.
f(x)
xl
x
xu
Fig. 4.4. At least one root exists between two points if the function is real, continuous,
and changes sign.
Since the root is bracketed between two points, 𝑥ℓ and 𝑥𝑢 , one can find the mid-point,
𝑥𝑚 between 𝑥ℓ and 𝑥𝑢 . This gives us two new intervals 𝑥ℓ and 𝑥𝑚 , and 𝑥𝑚 and 𝑥𝑢 .
One can find the sign of 𝑓(𝑥ℓ )𝑓(𝑥𝑚 ), and if 𝑓(𝑥ℓ )𝑓(𝑥𝑚 ) < 0 then the new bracket is between
𝑥ℓ and 𝑥𝑚 , otherwise, it is between 𝑥𝑚 and 𝑥𝑢 . So, you can see that you are literally halving
the interval. As one repeats this process, the width of the interval [𝑥ℓ , 𝑥𝑢 ] becomes smaller and
smaller, and you can “zero” in to the root of the equation 𝑓(𝑥) = 0. The algorithm for the
bisection method is given as follows.
The steps to apply the bisection method to find the root of the equation 𝑓(𝑥) = 0 are:
1. Choose 𝑥ℓ and 𝑥𝑢 as two guesses for the root such that𝑓(𝑥ℓ )𝑓(𝑥𝑢 ) < 0, or in other
words, 𝑓(𝑥) changes sign between 𝑥ℓ and 𝑥𝑢 .
2. Estimate the root, 𝑥𝑚 of the equation 𝑓(𝑥) = 0 as the mid-point between 𝑥ℓ and 𝑥𝑢 as
𝑥 +𝑥
𝑥𝑚 = ℓ 2 𝑢.
5. Compare the absolute relative approximate error |𝜀𝑎 | with the pre-specified relative
error tolerance𝜀𝑠 . If|𝜀𝑎 | > 𝜀𝑠 , then go to Step 3, else stop the algorithm.
Note: One should also check whether the number of iterations is more than the
maximum number of iterations allowed. If so, one needs to terminate the algorithm and
notify the user about it.
Problems
x 0 1 2 >2
f(x) − 10 −5 14
Sign f(x) − − + +
There is only one + ive root and it lies between 1 and 2. Let x1 = 1 and x2 = 2; at x = 1,
𝑥 +𝑥
f(x) is – ive and at x = 2, f(x) is + ive. We examine the sign of f(x) at 𝑥 = 1 2 2 = 1.5
and check whether the root lies in the interval (1, 1.5) or (1.5, 2). Let us show the
computations in the table below :
2. You are working for ‘DOWN THE TOILET COMPANY’ that makes floats for ABC
commodes. The floating ball has a specific gravity of 0.6 and has a radius of 5.5 cm. You
are asked to find the depth to which the ball is submerged when floating in water.
The equation that gives the depth 𝑥 to which the ball is submerged under water is given by
𝑥 3 − 0.165𝑥 2 + 3.993 × 10−4 = 0
Use the bisection method of finding roots of equations to find the depth 𝑥 to which the ball
is submerged under water. Conduct three iterations to estimate the root of the above equation.
Find the absolute relative approximate error at the end of each iteration.
Solution:
From the physics of the problem, the ball would be submerged between 𝑥 = 0 and𝑥 = 2𝑅,
where
𝑅 = radius of the ball,
that is
0 ≤ 𝑥 ≤ 2𝑅
0 ≤ 𝑥 ≤ 2(0.055)
0 ≤ 𝑥 ≤ 0.11
Let us assume
𝑥ℓ = 0, 𝑥𝑢 = 0.11
Check if the function changes sign between 𝑥ℓ and 𝑥𝑢 .
𝑓(𝑥ℓ ) = 𝑓(0) = (0)3 − 0.165(0)2 + 3.993 × 10−4 = 3.993 × 10−4
𝑓(𝑥𝑢 ) = 𝑓(0.11) = (0.11)3 − 0.165(0.11)2 + 3.993 × 10−4 = −2.662 × 10−4
Hence
𝑓(𝑥ℓ )𝑓(𝑥𝑢 ) = 𝑓(0)𝑓(0.11) = (3.993 × 10−4 )(−2.662 × 10−4 ) < 0
So there is at least one root between 𝑥ℓ and 𝑥𝑢 , that is between 0 and 0.11.
Iteration 1:
Iteration 2:
Iteration 3:
𝑥ℓ +𝑥𝑢 0.055+0.0825
𝑥𝑚 = = = 0.06875
2 2
𝑓(𝑥𝑚 ) = 𝑓(0.06875) = (0.06875)3 − 0.165(0.06875)2 + 3.993 × 10−4
= −5.563 × 10−5
𝑓(𝑥ℓ )𝑓(𝑥𝑚 ) = 𝑓(0.055)𝑓(0.06875) = (6.655 × 105 ) × (−5.563 × 10−5 ) < 0
Hence, the root is bracketed between 𝑥ℓ and 𝑥𝑚 , that is, between 0.055 and 0.06875. So the
lower and upper limit of the new bracket is
𝑥ℓ = 0.055, 𝑥𝑢 = 0.06875
The absolute relative approximate error |∈𝑎 | at the ends of Iteration 3 is
new −𝑥 old
𝑥𝑚 0.06875−0.0825
𝑚
|∈𝑎 | = | new | × 100 =| | × 100 = 20%
𝑥𝑚 0.06875
Problems
1. For the following data, find x for y = 7.
x 1 3 4
y 4 12 19
Solution:
𝑥0 =1 𝑥1 =3 𝑥2 =4
𝑦0 = 4 𝑦1 = 12 𝑦2 = 14
(𝑦−𝑦1 )(𝑦−𝑦2 ) (𝑦−𝑦0 )(𝑦−𝑦2 ) (𝑦−𝑦0 )(𝑦−𝑦1 )
x = (𝑦 𝑥0 + (𝑦 𝑥1 + 𝑥2
0 −𝑦1 )(𝑦0 −𝑦2 ) 1 −𝑦0 )(𝑦1 −𝑦2 ) (𝑦2 −𝑦0 )(𝑦2 −𝑦1 )
(𝑦−12)(𝑦−19) (𝑦−4)(𝑦−19) (𝑦−4)(𝑦−12)
= (4−12)(4−19)
(1) + (12−4)(12−19) (3) + (19−4)(19−12) (4)
at y=7
60 108 60
x= + -
120 56 105
= 1.85714
x 4 7 10 12
y –1 1 2 4
Solution: The Lagrange’s interpolation polynomial of x is given by
Weddle’s rule
Weddle's rule is a method of integration used for computing definite integral. The integral is
calculated from a set of numerical values of the integrand. This method of integration is also
known as mechanical quadrature.
By taking n = 6 in the general Quadrature formula, we obtain
𝑥 +𝑛ℎ
0 3ℎ
∫𝑥0 𝑓(𝑥) 𝑑𝑥 = 10 [(𝑦0 + 𝑦𝑛 ) + 5(𝑦1 + 𝑦5 + ⋯ + 𝑦𝑛−5 + 𝑦𝑛−1 ) + (𝑦2 + 𝑦4 + ⋯ +
𝑦𝑛−4 + 𝑦𝑛−2 ) + 2(𝑦6 + 𝑦12 + ⋯ + 𝑦𝑛−6 ) + 6(𝑦3 + 𝑦9 + ⋯ + 𝑦𝑛−3 )]
Problems
5.2
1. Calculate ∫4 logx dx using Weddle’s rule.
5.2−4 1.2
Solution: h = = = 0.2
6 6
6 𝑑𝑥
2. Evaluate ∫0 using Weddle’s rule.
1+𝑥 2
Solution: Dividing the interval (0, 6) into six equal parts of width h = 6−0
6
=1
x 0 1 2 3 4 5 6
f(x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027
6
1 3ℎ
∫ 𝑑𝑥 = [(𝑦 + 5𝑦1 + 𝑦2 + 6𝑦3 + 𝑦4 + 5𝑦5 + 𝑦6 ))]
0 1+𝑥 2 10 0
3(1)
= [(1 + 5(0.5) + 0.2 + 6(0.1) + 0.0588 + 5(0.385) + 6.027] = 1.3735
10
0.6 2
3. Evaluate ∫0 𝑒 −𝑥 𝑑𝑥 by taking 6 intervals using Weddle’s rule
II-Semester: Mathematics- II for Computer Science & Engineering stream (BMATS201)
P a g e 34 | 35
RV Institute of Technology & Management ®
Solution: Dividing the interval (0, 0.6) into six equal parts of width h = 0.6−0
6
=0.1
6
1 3ℎ
∫ 𝑑𝑥 = [(𝑦 + 5𝑦1 + 𝑦2 + 6𝑦3 + 𝑦4 + 5𝑦5 + 𝑦6 ))]
0 1+𝑥
2 10 0
= 0.5351.
Youtube links:
2 Newton's Forward Interpolation & Backward Interpolation Formula - Concepts & Solved
Problems - YouTube
4 Numerical Integration : Newton Cotes Formula, Trapezium Rule, Simpson's 1/3rd and 3/8th
Rule - YouTube
Disclaimer: The content provided is prepared by department of Mathematics for the specified
syllabus by using reference books mentioned in the syllabus. This material is specifically for
the use of RVITM students and for education purpose only.