Numerical Analysis Lecture Notes
Numerical Analysis Lecture Notes
LECTURE NOTE
PREPARED BY:
KEDIR ALIYI ([Link])
MAY, 2020
AMBO, ETHIOPIA
Contents
1 Basic Concepts in Error Estimation 4
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Theory of Errors or Error Analysis . . . . . . . . . . . . . . . . . . 4
1.3 Common types of errors: . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Basic sources of Errors . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Approximations of Errors . . . . . . . . . . . . . . . . . . . . . . . 6
1.6 Propagation of Errors and Instability . . . . . . . . . . . . . . . . . 9
3 System of equation 35
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.2 Direct Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2.1 Gauss Elimination Method . . . . . . . . . . . . . . . . . 38
3.2.2 Gauss-Jordan Method . . . . . . . . . . . . . . . . . . . . 45
3.2.3 Matrix Decomposition . . . . . . . . . . . . . . . . . . . . 48
3.3 Iterative Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.3.1 Gauss-Jacobi Iteration Method . . . . . . . . . . . . . . . . 56
3.3.2 Gauss-Seidel Iteration Method . . . . . . . . . . . . . . . . 61
3.4 Solving System of non-linear Equations using Newton’s Method . . 66
4 FINITE DIFFERENCES 70
4.1 SHIFT OPERATOR . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.2 FORWARD DIFFERENCE OPERATOR . . . . . . . . . . . . . . 71
4.3 BACKWARD DIFFERENCES . . . . . . . . . . . . . . . . . . . . 75
2
5 Interpolation 77
5.1 Linear Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.2 Lagrange’s Interpolation formula . . . . . . . . . . . . . . . . . . . 78
5.3 Newton Interpolation Formula(forward and backward difference for-
mulas) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
5.3.1 NEWTON’S FORWARD INTERPOLATION FORMULA . 83
5.3.2 NEWTON– BACKWARD INTERPOLATION FORMULA . . . 87
5.4 Application of interpolation . . . . . . . . . . . . . . . . . . . . . . 90
5.4.1 Derivatives Using Newton’s Forward Difference Formula . . 90
5.4.2 Derivatives using Newton’s Backward Interpolation Formula 92
5.4.3 Numerical Integration . . . . . . . . . . . . . . . . . . . . 94
3
Chapter 1
• Errors which are already present in the statement of a problem before its use.
4
• Arise either due to the given data being approximate or due to the limitations
of mathematical tables, calculators, or the digital computers.
Rounding errors:
• Arise from the process of rounding off the numbers during the computation.
• Are unavoidable in most of the calculations due to the limitations of the com-
puting aids. However, rounding errors can be reduced.
Truncation errors:
Example 1.3.1 If we use a decimal computer having a fixed word length of four
digitals, then
Hence,
Rounding error=13.66-13.658=0.002;and
Truncation error=13.658-13.65=0.008.
Ea |X−X|
• Relative error, Er = |X| = |X| ; and
5
If X be such a number that |X − X| ≤ X, then Xis an upper limit on the magnitude
of absolute error and measures the absolute accuracy.
Remarks:
1. The relative and percentage errors are independent of the units used.
1
2. If a number is correct to n decimal places, then the error(absolute) = 2 ×
10−n .
3 5
• Consider the function sinx = x − x3! + x5! · · ·
In this function, one has to consider a few terms to make computational prac-
tice. Hence, we are forced to stop at some term of the sequence and consider
it to be an approximation. Such a termination of the process gives rise to an
error. This error is called residual error or truncation error.
6
error δ y in y is given by
y + δ y = f (x1 + δ x1 , x2 + δ x2 ).
∂f ∂f
y + δ y = f (x1 , x2 ) + δ x1 + δ x2 +
∂ x1 ∂ x2
terms involving higher powers of
δ x1 andδ x2 · · · (i).
∂y ∂y ∂y
δy ≈ δ x1 + δ x2 + · · · + δ xn
∂ x1 ∂ x2 ∂ xn
and the relative error in y is given by:
δy ∂ y δ x1 ∂ y δ x2 ∂ y δ xn
Er = ≈ + +···+
y ∂ x1 y ∂ x2 y ∂ xn y
2 3
Example 1.5.1 : Let u = 4xz4y and errors in x, y, z be 0.001. Then compute the
maximum relative error in u when x = y = z = 1.
8xy3 ∂ u 12x2 y2 ∂ u 2 3
Solution: Since ∂u
∂x = ,
z4 ∂ y
= z4
, ∂z = − 16xz5 y , we have
Since the errors δ x, δ y and δ z may be positive or negative, we take the absolute
values of the terms on the right hand side, giving
7
Hence, the maximum relative error in u is
Example 1.5.2 Find the maximum relative error in the function y = ax1m1 x2m2 · · · xnmn ,
where a, m1 , m2 , · · · , mn are constants.
1 ∂y m1 1 ∂ y
Therefore, y ∂ x1 = x1 , y ∂ x2 = m2
x2 · · · , 1y ∂∂xyn = mn
xn .
∂ y δ x1
Hence, Er ≈ ∂ x1 y + ∂∂xy δ x2
y + · · · + ∂∂xyn δyxn .
2
δ x1 δ x2 δ xn
= m1 + m2 + · · · + mn .
x1 x2 xn
Since the errors δ x1 , δ x2 , · · · , δ xn may be positive or negative, we take the absolute
values of the terms on the right side. This gives:
δ x1 δ x2 δ xn
(Er )max = |m1 | + |m2 | + · · · + |mn |.
x1 x2 xn
Remark: Taking a = 1, m1 = m2 == mn = 1, we have y = x1 x2 · · · xn . Then
δ x1 δ x2 δ xn
Er = + +···+ .
x1 x2 xn
n
where Rn (x) = (x−a) n
n! f (θ ), a < θ < x.
If the series is convergent, then Rn (x) → 0 as n → ∞ and hence if f (x) is approxi-
mated by the first n terms of this series, then the maximum error will be given by
the remainder term Rn (x). Moreover, if the accuracy required in a series approxi-
8
mation is pre-assigned, then we can find n, the number of terms which would yield
the desired accuracy.
Example 1.5.3 : Find the number of terms of the exponential series such that their
sum gives the value of ex correct to six decimal places at x = 1.
x2 x3 xn−1
ex = 1 + x + + +···+ + Rn (x) · · · (i)
2! 3! (n − 1)!
n
where Rn (x) = xn eθ , 0 < θ < x. Therefore, the maximum absolute error (at θ =
n n
x) = xn! ex ; and the maximum relative error = xn!
Hence, (Er )maxatx=1 = n!1 .
For a six decimal place accuracy at x=1, we have
1 1
< × 10−6
n! 2
⇒ n! > 2 × 106
which gives n=10. Thus we need 10 terms of the series (i) in order that its sum is
correct to 6 decimal places.
Propagated error:
• If the error E0 is introduced at initial stage of the algorithm and after ’n’
subsequent operation of the algorithm, En is the error resulted, then this is the
9
propagated error.
Stability:
• If errors made at initial step die out (decrease) as the algorithm continuous,
the algorithm is said to be stable.
10
Chapter 2
f (x) = 0
11
a factor of f (x) = x3 + x − 2 = 0 we can write f (x) = (x − 1)(x2 + x + 2) = (x −
1)g(x), g(1) = 4 6= 0 Alternatively, we find f (1) = 0,and f 0 (1) = 4 6= 0 .Hence
,x = 1 is a simple root of f (x) = x3 + x − 2 = 0 .
Multiple Root : A number α is a multiple root, of multiplicity m , of f (x) = 0
if f (α) = 0, f 0 (α) = 0 , f 00 (α) = 0 · · · f m−1 (α) = 0 and f m (α) 6= 0. Then we can
write f (x) as f (x) = (x − α)m g(x), g(α) 6= 0.
For example: consider the equation f (x) = x3 − 3x2 + 4 = 0 .
we find f (2) = 8 − 12 + 4 = 0 f 0 (x) = 3x2 − 6x, f 0 (2) = 12 − 12 = 0
1 p
x= [−b ± b2 − 4ac]
2a
For this method we can give the count of total number of operations. There are
direct methods for finding the roots of a cubic and fourth degree polynomial. How-
ever these methods are difficult to use. Direct methods for finding the roots of
polynomial equations of degree greater than 4 or transcendental equations are not
available in literature Iterative Methods: These methods are based on the idea of
12
successive approximatios. We start with one or two initial approximations to the
root and obtain a sequence of approximations x0 , x1 , x2 , · · · , xk , · · · which in the limit
as k → ∞ , converge to the exact root α. An iterative method for finding a root of
the equation f (x) = 0 can be obtained as
xk+1 = ϕ(xk ), k = 0, 1, 2, . . .
This method uses one initial approximation to the root x0 . The sequence of approx-
imations is given by
The function ϕ is called the iteration function and x0 is called the initial an approxi-
mation. If the method uses two initial approximations x0 , x1 to the root , then we can
write the method as xk+1 = (xk−1 , xk ) k = 1, 2, · · · Convergence of iterative methods
: The sequence of iterates ,xk , is said to converge to the exact root α , if
Remark 2. Given one or two initial approximations to the root, we require a
suitable iteration function α for a given function f (x) , such that the sequence of
iterates,{xk } , converge to the exact root α. Further , we also require a suitable
criterion to terminate the iteration. Criterion to terminate iteration procedure; Since
we cannot perform infinite number of iterations, we need a criterion to stop the
iterations. We use one or both of the following criterion: The equation f (x) = 0 is
satisfied to a given accuracy or f (xk ) is bounded by an error tolerance ε. | f (xk )| ≤ ε.
The magnitude of the difference between two successive iterates is smaller than a
given accuracy or an error bound ε.
|xk+1 − xk | ≤ ε.
Generally, we use the second criterion. In some very special problems, we re-
quire to use both the criteria.
For example , if we require two decimal place accuracy , then we iterate until
|xk+1 − xk | ≤ 0.005.
If we require three decimal place accuracy, then we iterate until
13
|xk+1 − xk | ≤ 0.0005.
As we have seen earlier , we require a suitable iteration function and suitable
initial approximation(s) to start the iteration procedure. Initial approximation for an
iterative procedure
Descarte’s Rule of iterative procedure : This gives the bound for the number of
positive and negative real root for polynomial equations f (x) = 0;
i) We count the number of changes of signs is the coefficients of pn (x) for the
equation f (x) = pn (x) = 0 . The number of positive roots can not exceed the
number of changes of signs.
For example , If there are 4 changes of signs, then the equation may have 4
positive roots or two(2) positive roots or no positive roots.
If there are 3 changes of signs , then the equation may have 3 positive roots
or definitely one positive root.
ii) We write the equation f (−x) = pn (−x) = 0 and count the number of changes
of signs in the coefficients of pn (−x). The number of negative roots can not
exceed the number of changes of signs. For example , if there are 4 changes
of signs, then the equation may have 4 negative roots or 2. If there are 3
changes of signs , then the equation may have 3 negative roots or definitely
one negative root.
Theorem 2.1.1 If f (x) is continuous on some interval [a, b] and f (a) f (b) < 0, then
the equation f (x) = 0 has at least one real root or an odd number of real roots in
the interval (a, b).
Example 2.1.1 Determine the maximum number of positive and negative roots and
intervals of length one unit in which the real roots lie for the following equations.
i. 8x3 − 12x2 − 2x + 3 = 0
14
Solutions: Let f (x) = 8x3 − 12x2 − 2x + 3 = 0 the number of changes in signs of
the coefficients (8, −12, −2, 3) is 2 . Therefore , the equation has 2 positive roots
or no positive roots.
x -2 -1 0 1 2 3
f (x) -105 -15 3 -3 15 105
ii. Let f (x) = 3x3 − 2x2 − x − 5 = 0 ,The number of changes in signs of the
coefficients (3, −2, −1, −5) is 1 . Therefore the equation has 2 negative roots
or no negative root the table of values for f(x).
x -3 -2 0 1 2 3
f (x) -101 -35 -5 -5 9 55
From the table there is 1 positive real root in the interval (1, 2). The equation has
no negative real root .
Example 2.1.2 Locate the smallest positive real root of the equations
i. xex = cosx
ii. tanx = 2x
Solution
15
i. Let f (x) = xex − cosx = 0 since f (0) = −1 and
ii. Let f (x) = tanx − 2x = 0 Then we have the following function values f (0) =
0 , f (0.1) = −0.0997 , f (0.5) = −0.4537 f (1) = −0.4426 f (1.1) = −0.2352
, f (1.2) = 0.1722, since f (1.1) f (1.2) < 0 ,the root lies in the interval (1.1, 1.2)
a+b
x1 =
2
If f (x1 ) = 0 , then x1 is a root of f (x) = 0 .Otherwise, the root lies in (a, x1 ) or
(x1 , b) according as f (x1 ) is positive or negative. Then we bisect the interval as
before and continue the process until the root is found to desired accuracy. In the
figure below, f (x1 ) > 0, so that the root lies in the interval (a, x1 ) . Then the second
approximation to the root is
a + x1
x2 =
2
If f (x1 ) < 0) , then the root lies in (x2 , x1 ) .Then the third approximation to the root
is
x1 + x2
x3 =
2
and so on
Remark Since the new interval containing the root is exactly half the length
of the previous one , the interval width is reduced by a factor of 12 at each step.
Therefore at the end of the nth step , the interval will be of length
b−a
2n
16
Figure 2.2: Bisection method
If on repeating this process n times , the latest interval is as small as given ε ,then
b−a ln( b−a
ε )
2 n ≤ ε or n ≥ ln2
This gives the number of iterations required for achieving an accuracy ε . In par-
ticular , the minimum number of iterations required for converging to a root in the
interval (0, 1) for a given ε are as under;
Solution: Let f (x) = x3 − 4x − 9 = 0. Since f (2) f (3) < 0, the root lies in the in-
terval (2, 3). Therefore, the first approximation to the root is x1 = 2+3 2 = 2.5 and
f (x1 ) = f (2.5) = −3.375.
Since f (2.5) f (3) < 0, the root lies in the interval (2.5, 3). Therefore, the 2nd ap-
proximation to the root is x2 = 2.5+3 2 = 2.75 and f (x2 ) = f (2.75) = 0.7969. Since
f (2.5) f (2.75) < 0, the root lies in the interval (2.5, 2.75). Therefore, the 3rd ap-
proximation to the root is x3 = 2.5+2.75
2 = 2.625 and f (x3 ) = f (2.625) = −1.4121.
Since f (2.625) f (2.75) < 0, the root lies in the interval (2.625, 2.75). Therefore,
the 4th approximation to the root is x4 = 2.625+2.75
2 = 2.6875.
Repeating this process, the successive approximations are
x5 = 2.71875 , x6 = 2.70313
x7 = 2.71094 , x8 = 2.70703
x9 = 2.70508 , x10 = 2.70605
x11 = 2.70654
Since |x11 − x10 | = 0.00012 < 0.0005, the required root is x ≈ x11 = 2.70654.
17
2.3 Method of False Position
The method is also called linear interpolation method or regula-falsi method. At the
start of all iterations of the method, we require the interval in which the root lies.
Let the root of the equation f (x) = 0 lie in the interval (xk−1 , xk ), that is, fk−1 fk < 0,
where f (xk−1 ) = fk−1 , and f (xk ) = fk . Then P(xk−1 , fk−1 ), Q(xk , fk ) are points on
the curve f (x) = 0. Draw a straight line joining the points P and Q From figure
(2.3). The line PQ is taken
as an approximation of the curve in the interval [xk−1 , xk ]. The equation of the line
fk − fk−1
PQ is given by y− fk
x−xk = xk −xk−1 . The point of intersection of this line PQ with the
x-axis is taken as the next approximation to the root. Setting y = 0, and solving for
x, we get
xk − xk−1
x = xk − ( ) fk .
fk − fk−1
The next approximation to the root is
xk − xk−1
xk+1 = xk − ( ) fk .
fk − fk−1
Therefore, starting with the initial interval (x0 , x1 ) in which the root lies, we com-
pute
x0 f1 − x1 f0
x2 = .
f1 − f0
Now, if f (x0 ) f (x2 ) < 0 , then the root lies in the interval (x0 , x2 ). Otherwise, the
root lies in the interval (x2 , x1 ). The iteration is continued using the interval in which
18
the root lies, until the required accuracy criterion is satisfied. Remark: At the start
of each iteration, the required root lies in an interval, whose length is decreasing.
Hence, the method always converges.
Remark: The method of false position has a disadvantage. If the root lies initially
in the interval (x0 , x1 ), then one of the end points is fixed for all iterations. For
example, in Fig.1.2a, the left end point x0 is fixed and the right end point moves
towards the required root. Therefore, in actual computations, the method behaves
like
x0 fk − xk f0
xk+1 = , k = 1, 2, . . .
fk − f0
In Fig.1.2b, the right end point x1 is fixed and the left end point moves towards the
required root. Therefore, in this case, in actual computations, the method behaves
like
x1 fk − xk f1
xk+1 = , k = 2, 3, . . .
fk − f1
Example 2.3.1 Locate the intervals which contain the positive real roots of the
equation x3 − 3x + 1 = 0.
Obtain these roots correct to three decimal places, using the method of false posi-
tion.
Solution: We form the following table of values for the function f(x).
x 0 1 2 3
f (x) 1 -1 3 19
There is one positive real root in the interval (0, 1) and another in the interval (1, 2).
There is no real root for x > 2 as f (x) > 0 for all x > 2. First, we find the root in
(0, 1). We have
x0 f1 − x1 f0 0(−1) − 1
x2 = = = 0.5, f2 = f (x2 ) = f (0.5) = −0.375 < 0.
f1 − f0 −1 − 1
Since f (0) f (0.5) < 0 ,the root lies in the interval (0, 0.5)
x0 f2 − x2 f0 0 − 0.5
x3 = = = 0.36364.
f2 − f0 −0.375 − 1
19
and
f3 = f (x3 ) = f (0.36364) = −0.04283 < 0
x0 f3 − x3 f0 0 − 0.36364
x4 = = = 0.34870
f3 − f0 −0.04283 − 1
and f4 = f (x4 ) = f (0.34870) = −0.00370 < 0
Since f (0) f (0.34870) < 0 the root lies in (0, 0.34870).
x0 f4 − x4 f0 0 − 0.34870(1)
x5 = = = 0.34741
f4 − f0 −0.00370 − 0
x0 f5 − x5 f0 0 − 0.34741
x6 = = = 0.347306
f5 − f0 −0.00030 − 1
x2 f1 − x1 f2 1.25(3) − 2(−0.796875)
x3 = = = 1.407407
f1 − f2 3 − (−0.796875)
20
f3 = f (x3 ) = f (1.407407) = −0.434437 Since f (1.407407) f (2) < 0, the root lies
in (1.407407, 2)
x3 f1 − x1 f3 1.407407(3) − 2(−0.434437)
x4 = = = 1.482367
f1 − f3 3 − (−0.434437)
x4 f1 − x1 f4 1.482367(3) − 2(−0.189730)
x5 = = = 1.513156
f1 − f4 3 − (−0.189730)
and
f5 = f (x5 ) = f (1.513156) = −0.074884
Since f (1.513156) f (2) < 0 , the root lies in the interval (1.513156, 2)
x5 f1 − x1 f5 1.513156(3) − 2(−0.074884)
x6 = = = 1.525012
f1 − f5 3 − (−0.074884)
and
f6 = f (x6 ) = f (1.525012) = −0.028374
Since f (1.525012) f (2) < 0 ,the root lies in the interval (1.525012, 5)
x6 f1 − x1 f6 1.525012(3) − 2(−0.028374)
x7 = = = 1.529462
f1 − f6 3 − (−0.028374)
Since, f (1.529462) f (2) < 0, the root lies in the interval (1.529462, 2).
x7 f1 − x1 f7 1.529462(3) − 2(−0.010586)
x8 = = = 1.531116
f1 − f7 3 − (−0.010586)
Since, f (1.531116) f (2) < 0, the root lies in the interval (1.531116, 2).
x8 f1 − x1 f8 1.531116(3) − 2(−0.003928)
x9 = = = 1.531729
f1 − f8 3 − (−0.003928)
21
f (x9 ) = f (1.531729) = −0.001454.
Since, f (1.531729) f (2) < 0, the root lies in the interval (1.531729, 2).
x9 f1 − x1 f9 1.531729(3) − 2(−0.001454)
x10 = = = 1.531956
f1 − f9 3 − (−0.001454)
Example 2.3.2 Find the root correct to two decimal places of the equation xex =
cosx, using the method of false position.
Solution Define f (x) = cosx − xex = 0. There is no negative root for the equation.
We have f (0) = 1, f (1) = cos1 − e = −2.17798.
A root of the equation lies in the interval (0, 1). Let x0 = 0, x1 = 1. Using the method
of false position, we obtain the following results.
x0 f1 − x1 f0 0 − 1(1)
x2 = = = 0.31467
f1 − f0 −2.17798 − 1
and
f (x2 ) = f (0.31467) = 0.51986
Since, f (0.31467) f (1) < 0, the root lies in the interval (0.31467, 1).
x2 f1 − x1 f2 0.31467(−2.17798) − 1(0.51986)
x3 = = = 0.44673
f1 − f2 −2.17798 − 0.51986
Since, f (0.44673) f (1) < 0, the root lies in the interval (0.44673, 1).
x3 f1 − x1 f3 0.44673(2.17798) − 1(0.20354)
x4 = = = 0.49402
f1 − f3 −2.17798 − 0.20354
22
Since, f (0.49402) f (1) < 0, the root lies in the interval (0.49402, 1).
x4 f1 − x1 f4 0.49402(−2.17798) − 1(0.07079)
x5 = = = 0.50995
f1 − f4 −2.17798 − 0.07079
Since, f (0.50995) f (1) < 0, the root lies in the interval (0.50995, 1).
x5 f1 − x1 f5 0.50995(−2.17798) − 1(0.0236)
x6 = = = 0.51520
f1 − f5 −2.17798 − 0.0236
Since, f (0.51520) f (1) < 0, the root lies in the interval (0.51520, 1).
x6 f1 − x1 f6 0.5152(−2.17798) − 1(0.00776)
x7 = = = 0.51692.
f1 − f6 −2.17798 − 0.00776
Exercises 2.3.1 Find a root of the equation x3 −4x−9 = 0 using regula-falsi method
correct to 3 decimal places.
23
Figure 2.4: Secant method
Then the abscissa of the point where it crosses the x-axis (y=0) is given by
x1 − x0
x2 = x1 − ( ) f (x1 )
f (x1 ) − f (x0 )
xk − xk−1
xk+1 = xk − ( ) f (xk ) , k = 1, 2, 3, . . .
f (xk ) − f (xk−1 )
Remark: If f (x) = f (xn−1 ) ,then this method fails and shows that it does not con-
verge necessarily. This is a drowback of secant method over the method of false
positon which always converges. But if the secant method once converges,its rate
of convergence is faster than that of the method of false position.
Example 2.4.1 Find the root of the equation cosx = xex using the secant method
correct to 4 decimal places .
x1 − x0
x2 = x1 − ( ) f (x1 ) = 0.31467
f (x1 ) − f (x0 )
24
Repeating the process the successive approximations are
This method is also called Newton’s method. This method is also a chord method
in which we approximate the curve near a root, by a straight line. Let x0 be an initial
approximation to the root of f (x) = 0. Then, P(x0 , f0 ), where f0 = f (x0 ), is a point
on the curve. Draw the tangent to the curve at P, (Fig. 1.3). We approximate the
curve in the neighborhood of the root by the tangent to the curve at the point P. The
point of intersection of the tangent with the x-axis is taken as the next approximation
to the root. The process is repeated until the required accuracy is obtained. The
equation of the tangent to the curve y = f (x) at the point P(x0 , f0 ) is given by
y − f (x0 ) = (x − x0 ) f 0 (x0 )
y − f (x0 ) = (x − x0 ) f (x0 )
where f (x0 ) is the slope of the tangent to the curve at P. Setting y = 0 and solving
for x, we get
f (x0 ) 0
x = x0 − 0 , f (x0 ) 6= 0
f (x0 )
25
The next approximation to the root is given by
f (x0 )
x1 = x0 − , f 0 (x0 ) 6= 0
f 0 (x0 )
f (xk )
xk+1 = xk − , f 0 (xk ) 6= 0
f 0 (xk )
This method is called the Newton-Raphson method or simply the Newton’s method.
The method is also called the tangent method. Alternate derivation of the method
Let xk be an approximation to the root of the equation f (x) = 0. Let ∆x be an
increment in x such that xk + ∆x is the exact root, that is f (xk + ∆x) = 0. Expanding
in Taylor’s series about the point xk , we get
(∆x)2 00
f (xk ) + ∆x f 0 (xk ) + f (xk ) + . . . = 0
2!
f (xk ) + ∆x f 0 (xk ) ≈ 0,
or
f (xk )
∆x = −
f 0 (xk )
Hence, we obtain the iteration method
f (xk )
xk+1 = xk + ∆x = xk − , f 0 (xk ) 6= 0 , k = 0, 1, 2, . . .
f 0 (xk )
which is same as the method derived earlier.
Remark Convergence of the Newton’s method depends on the initial approxima-
tion to the root. If the approximation is far away from the exact root, the method
diverges (see Example 2.5.1). However, if a root lies in a small interval (a, b) and
x0 ∈ (a, b), then the method converges.
Remark : From Eq.(1.14), we observe that the method may fail when f 0 (x) is close
to zero in the neighborhood of the root. Later, in this section, we shall give the
condition for convergence of the method.
26
Remark : The computational cost of the method is one evaluation of the function
f (x) and one evaluation of the derivative f 0 (x), for each iteration.
Example 2.5.1 Derive the Newton’s method for finding N1 , where N > 0. Hence,
1
find 17 ,using the initial approximation as (i) 0.05, (ii) 0.15. Do the iterations con-
verge ?
1
f (xk ) xk − N
xk+1 = xk – = xk − = xk + (xk − Nxk2 ) = 2xk − Nxk2
f 0 (xk ) 1
− x2
k
27
Example 2.5.2 Derive the Newton’s method for finding the qth root of a positive
number N, N 1/q , where N > 0, q > 0.
Hence, compute 171/3 correct to four decimal places, assuming the initial approxi-
mation as x0 = 2.
1
For computing 17 3 , we have q = 3 and N = 17. Hence, the method becomes
(3 − 1)xk3 + 17 2xk3 + 17
xk+1 = = k = 0, 1, 2, 3, ...
3xk3−1 3xk2
2x03 + 17 2(23 ) + 17
x1 = = = 2.75
3x02 3(2)2
2x13 + 17 2(2.75)3 + 17
x2 = = = 2.582645
3x12 3(2.75)2
2x23 + 17 2(2.582645)3 + 17
x3 = = = 2.571332
3x22 3(2.582645)2
2x33 + 17 2(2.571332)3 + 17
x4 = = = 2.571282.
3x32 3(2.571332)2
Now,
|x4 − x3 | = |2.571282 − 2.571332| = 0.00005.
We may take x ≈ 2.571282 as the required root correct to four decimal places
Example 2.5.3 Perform four iterations of the Newton’s method to find the smallest
positive root of the equation f (x) = x3 − 5x + 1 = 0.
Solution We have f (0) = 1, f (1) = –3. Since, f (0) f (1) < 0 , the smallest positive
28
root lies in the interval (0, 1). Applying the Newton’s method, we obtain
2x03 − 1 2(0.5)3 − 1
x1 = 2 = = 0.176471,
3x0 − 5 3(0.5)2 − 5
2x13 − 1 2(0.176471)3 − 1
x2 = = = 0.201568,
3x12 − 5 3(0.176471)2 − 5
2x23 − 1 2(0.201568)3 − 1
x3 = = = 0.201640,
3x22 − 5 3(0.201568)2 − 5
2x33 − 1 2(0.201640)3 − 1
x4 = 2 = = 0.201640.
3x3 − 5 3(0.201640)2 − 5
Therefore, the root correct to six decimal places is x ≈ 0.201640.
ans:x ≈ 11.594854
x = ϕ(x). (1)
There are many ways of rewriting f (x) = 0 in this form. For example, f (x) =
x3 − 5x + 1 = 0, can be rewritten in the following forms.
r
x3 + 1 1 5x − 1
x= , x = (5x − 1) 3 , x = , etc. (2)
5 x
29
Now, finding a root of f (x) = 0 is same as finding a number α such that α = ϕ(α),
that is, a fixed point of ϕ(x). A fixed point of a function ϕ is a point α such that
α = ϕ(α). This result is also called the fixed point theorem. Using Eq.(1), the
iteration method is written as
The function ϕ(x) is called the iteration function. Starting with the initial approxi-
mation x0 , we compute the next approximations as
The stopping criterion is same as used earlier. Since, there are many ways of writ-
ing f (x) = 0 as x = ϕ(x), it is important to know whether all or at least one of these
iteration methods converges.
30
which does not converge to the root in (0, 1).
s
5xk − 1
xk+1 = , k = 0, 1, 2, ... (6)
kk
which does not converge to the root in (0, 1). Now, we derive the condition that the
iteration function ϕ(x) should satisfy in order that the method converges.
Condition of convergence
Theorem 2.6.1 If
proof
The iteration method for finding a root of f (x) = 0, is written as
α = ϕ(α) (2.2)
εk = xk –,
31
k = 0, 1, 2,... Subtracting (2.2) from (2.1), we obtain
Setting k = k − 1, we get
Hence,
εk+1 = ϕ 0 (tk )ϕ 0 (tk−1 )εk−1 .
|ϕ(xk )| ≤ c < 1, k = 0, 1, 2, . . .
or |ϕ 0 (x)| ≤ c < 1, for all x in the interval (a, b). (2.4) We can test this condition
using x0 , the initial approximation, before the computations are done.
Let us now check whether the methods (4), (5), (6) converge to a root in (0, 1) of
the equation f (x) = x3 − 5x + 1 = 0.
x3 +1 3x2 3x2
i. We have ϕ(x) = 5 , ϕ 0 (x) = 5 and |ϕ 0 (x)| = 5 ≤ 1, for all x in 0 < x <
32
1. Hence, the method converges to a root in (0, 1).
1
ii. We have ϕ(x) = 5x − 1) 3 , ϕ 0 (x) = 5
3(5x−1)2/3
Now |ϕ 0 (x)| < 1, when x is close to 1 and |ϕ(x)| > 1 in the other part of the
interval. Convergence is not guaranteed.
q
iii. We have ϕ(x) = 5x−1 0 1
x , ϕ (x) = 3 1 .
2x 2 (5x−1) 2
Again, |ϕ 0 (x)| < 1, when x is close to 1 and |ϕ 0 (x)| > 1 in the other part of
the interval. Convergence is not guaranteed.
Example 2.6.1 Find the smallest positive root of the equation x3 −x−10 = 0, using
the general iteration method.
Solution We have
Since, f (2) f (3) < 0, the smallest positive root lies in the interval (2, 3). Write
1
x3 = x + 10, and x = (x + 10) 3 = ϕ(x). We define the iteration method as
1
xk+1 = (xk + 10) 3 .
We obtain
1
ϕ 0 (x) = 2
3(x + 10) 3
We find |ϕ 0 (x)| < 1 for all x in the interval (2, 3). Hence, the iteration converges.
Let x0 = 2.5. We obtain the following results.
1 1
x1 = (12.5) 3 = 2.3208, x2 = (12.3208) 3 = 2.3097,
1 1
x3 = (12.3097) 3 = 2.3090, x4 = (12.3090) 3 = 2.3089.
33
Example 2.6.2 Find the smallest negative root in magnitude of the equation 3x4 +
x3 + 12x + 4 = 0, using the method of successive approximations.
Solution We have
Since, f (−1) f (0) < 0, the smallest negative root in magnitude lies in the interval
(−1, 0). Write the given equation as
x(3x3 + x2 + 12) + 4 = 0,
and
4
x=− = ϕ(x)
3x3 + x2 + 12
The iteration method is written as
4
xk+1 = −
3xk3 + xk2 + 12
We obtain
0 4(9x2 + 2x)
ϕ (x) =
(3x3 + x2 + 12)2
We find |ϕ 0 (x)| < 1 for all x in the interval (−1, 0). Hence, the iteration converges.
Let x0 = −0.25. We obtain the following results.
4 4
x1 = − =− = −0.33290,
3x03 + x02 + 12 3(−0.25)3 + (−0.25)2 + 12
4 4
x2 = − =− = −0.33333,
3x13 + x12 + 12 3(−0.33290)3 + (−0.33290)2 + 12
4 4
x3 = − =− = −0.33333.
3x23 + x22 + 12 3(−0.33333)3 + (−0.33333)2 + 12
The required approximation to the root is x ≈ −0.33333.
We conclude that both fixed point iteration and regula-falsi methods converge slowly
as they have only linear rate of convergence. FUrther, Newton’s method converges
at least twice as fast as the fixed point iteration.
34
Chapter 3
System of equation
3.1 Introduction
Consider a system of n linear algebraic equations in n unknowns
Ax = b (3.1)
a11 a12 a13 . . . a1n x1 b1
a21 a22 a23 . . . a2n
x2 b2
Where A =
.. .. .. , x = .. and b = ..
..
. . . . . .
an1 an2 an3 . . . ann xn bn
The matrix [A|b], obtained by appending the column b to the matrix A is called
the augmented matrix. That is
a11 a12 . . . a1n b1
a21 a22 . . . a2n b2
[A|b] = .. .. .. .. ..
. . . . .
an1 an2 . . . ann bn
We define the following.
35
i. The system of equations (3.1) is consistent (has at least one solution), if
rank(A) = rank[A|b] = r. If r = n, then the system has unique solution. If
r < n, then the system has (n − r) parameter family of infinite number of
solutions.
We assume that the given system is consistent. The methods of solution of the
linear algebraic system of equations (3.1) may be classified as direct and iterative
methods.
(a) Direct methods produce the exact solution after a finite number of steps (dis-
regarding the round-off errors). In these methods, we can determine the total
number of operations (additions, subtractions, divisions and multiplications).
This number is called the operational count of the method.
(a) Let A be a diagonal matrix, A = D. That is, we consider the system of equa-
tions Dx = b as
a11 x1 = b1
a22 x2 = b2
.. ..
. .
ann xn = bn
36
This system is called a diagonal system of equations. Solving directly, we
obtain
bi
xi = , aii 6= 0, i = 1, 2, ..., n.
aii
(b) Let A be an upper triangular matrix, A = U. That is, we consider the system
of equations Ux = b as
bn
xn = ann
bn−1 −an−1,n xn
xn−1 = an−1 ,n−1
··· ···
(b1 −∑nj=2 a1 j x j )
x1 = a11
The unknowns are obtained by back substitution and this procedure is called the
back substitution method. Therefore, when the given system of equations is one of
the above two forms, the solution is obtained directly.
(i) Interchange of any two rows. If we interchange the ith row with the jth row,
then we usually denote the operation as Ri ↔ R j .
(iii) Adding/subtracting a scalar multiple of any row to any other row. If all the
elements of the jth row are multiplied by a scalar p and added to the corre-
37
sponding elements of the ith row, then, we usually denote this operation as
Ri + pR j → Ri .
These row operations change the form of A, but do not change the row-rank of A.
The matrix B obtained after the elementary row operations is said to be row equiv-
alent with A. In the context of the solution of the system of algebraic equations, the
solution of the new system is identical with the solution of the original system. The
above elementary operations performed on the columns of A (column C in place of
row R) are called elementary column transformations (operations). However, we
shall be using only the elementary row operations.
First stage of elimination We assume a11 6= 0. This element a11 in the 1 × 1 position
is called the first pivot. We use this pivot to reduce all the elements below this
pivot in the first column as zeros. Multiply the first row in (3.3) by aa2111
and aa11
31
respectively and subtract from the second and third rows. That is, we are performing
38
the elementary row operations R2 − aa21
11
R1 and R3 − aa31
11
R1 respectively. We obtain
the new augmented matrix as
a11 a12 a13 b1
(1) (1) (1)
0 a22 a23 b2 (3.4)
(1) (1) (1)
0 a32 a33 b3
where
(1) (1)
We assume a22 6= 0 . This element a22 in the 2 × 2 position is called the second
pivot. We use this pivot to reduce the element below this pivot in the second column
(1)
a32
as zero. Multiply the second row in (3.4) by (1) and subtract from the third row.
a22
(1)
a
That is, we are performing the elementary row operation R3 − ( a32
22
)R2 . We obtain
the new augmented matrix as
a11 a12 a13 b1
(1) (1) (1)
0 a22 a23 b2 (3.5)
(2) (2)
0 0 a33 b3
Where
(1) (1)
(2) (1) a32 (1) (2) (1) a32 (1)
a33 = a33 − a , b3 = b3 −
(1) 23
b
(1) 2
a22 a22
(2)
The element a33 6= 0 is called the third pivot. This system is in the required upper
triangular form [U|z]. The solution vector x is now obtained by back substitution.
From the third row, we get x3 = b(2)
3
a33
(1) (2)
(b2 −a13 x3 )
From the second row, we get x2 = (2) .
a(12)
(b1 −a12 x2 −a13 x3 )
From the first row, we get x1 = a11 .
39
In general, using a pivot, all the elements below that pivot in that column are
made zeros. Alternately, at each stage of elimination, we may also make the pivot
as 1, by dividing that particular row by the pivot.
Remark : When does the Gauss elimination method as described above fail? It
fails when any one of the pivots is zero or it is a very small number, as the elimi-
nation progresses. If a pivot is zero, then division by it gives over flow error, since
division by zero is not defined. If a pivot is a very small number, then division by it
introduces large round-off errors and the solution may contain large errors.
40
2
of computer time) is n( n +3n−1
3 ). The total number of additions and subtractions
(addition and subtraction take the same amount of computer time) is n( (n−1)(2n+5)
6 ).
0 0 0 0
x1 + 10x2 –x3 = 3
10x1 − x2 + 2x3 = 4
41
Solution: We have the augmented matrix as
1 10 −1 3
2 3 20 7
10 −1 2 4
1 10 1 3
R2 ↔ R3 :
10 1 2 4
0 10.1 −1.2 2.6
0 0 19.98020 537624
1 1
x2 = (2.6 + 1.2x3) = (2.6 + 1.2(0.26908)) = 0.28940
10.1 10.1
42
First equation gives
1 1
x1 = (4 + x2 − 2x3 ) = (4 + 0.2894 − 2(0.26908)) = 0.37512.
10 10
4x1 + 2x3 + x4 = 8
x1 + 3x2 + 2x3 − x4 = −5
4 0 2 1 8
1 0 − 52 −14
0
R2 − (1/2)R1 , R3 − (3/4)R1 , R4 − (1/4)R1 :
0 2 12 − 43 1
3 5
0 3 2 − 4 −7
43
4
0 2 1 8
3 5
3 0 2 − 4 −7
R2 ↔ R4 :
2 21 − 34
0 1
5
1 0 − 2 −14
0
4 0 2 1 8
3 5
0 3 2 − 4 −7
R3 − (2/3)R2 , R4 − (1/3)R2 :
0 0 −1 1 17
2 12 3
0 0 − 12 − 25 2 − 35
3
4 0 2 1 8
3 5
0 3 2 − 4 −7
R4 − R3 , : 0 0 −1 1 17
2 12 3
0 0 0 − 6 − 52 13
3
52 6 17 1 17 1
x4 = (− )(− ) = 8 , x3 = −2( − )x4 = −2( − ( )8) = −10
3 13 3 12 3 12
1 3 5 1 3 5
x2 = [−7 − ( )x3 + ( )x4 ] = [−7 − ( )(−10) + ( )8] = 6
3 2 4 3 2 4
1 1
x1 = [8 − 2x3 − x4 ] = [8 − 2(−10) − 8] = 5.
4 4
2x1 + x2 + 3x3 = 13
x1 + x2 + 3x3 = 6
x1 + 10x2 –x3 = 3
44
9x1 + 22x2 + 79x3 = 45
9 22 79 45
0 68 88 18
.
1 10 1 3
R3 − 4R2 : 0 17 22 1
0 0 0 14
Now, rank [A] = 2, and rank[A|b] = 3. Therefore, the system is inconsistent and has
no solution.
In this case, after the eliminations are completed, we obtain the augmented ma-
trix for a 3 × 3 system as
1 0 0 d1
0 1 0 d2 (3.6)
0 0 1 d3
45
and the solution is xi = di , i = 1, 2, 3.
Elimination procedure
The first step is same as in Gauss elimination method, that is, we make the elements
below the first pivot as zeros, using the elementary row transformations. From the
second step onwards, we make the elements below and above the pivots as zeros
using the elementary row transformations. Lastly, we divide each row by its pivot
so that the final augmented matrix is of the form (3.6). Partial pivoting can also
be used in the solution. We may also make the pivots as 1 before performing the
elimination.
x1 + x2 + x3 = 1
4x1 + 3x2 − x3 = 6
using the Gauss-Jordan method (i) without partial pivoting, (ii) with partial pivot-
ing.
3 5 3 4
(i) We perform the following elementary row transformations and do the elimi-
nations.
1 1 1 1
R2 − 4R1 , R3 − 3R1 : 0 1 5 2
0 2 0 1
1 0 4 3
R1 + R2 , R3 + 2R2 : 0 1 5 2
0 0 10 5
46
1 0 0 1
4 5
R1 − R3 , R2 − R3 : 0 −1 0 − 12
10 10
0 0 −10 5
R3
Now, making the pivots as 1, ((−R2 ), −10 ) we get
1 0 0 1
0 1 0 12
0 0 1 − 21
3 5 3 4
1 43 − 41 32
R1
: 1 1 1 1
4
3 5 3 4
1 34 − 14 32
R2 − R1 , R3 − 3R1 : 0 41 5
− 12
4
0 114
15
4 − 12
1 43 − 14 3
2
4R2 15 2
: 0 1 11 − 11
11
1 5 1
0 4 4 −2
14 18
1 0 − 11 11
3 1
R1 − R2 , R3 − R2 : 0 1 15 − 112
4 4 11
10 5
0 0 11 − 11
1 0 − 14 18
11 11
R3 /(10/11) : 0 1 15 − 2
11 11
0 0 1 − 12
47
1 0 0 1
R1 + (14/11)R3 , R2 − (15/11)R3 : 0 1 0 12
0 0 1 − 21
We start with the augmented matrix of A with the identity matrix I of the same
order. When the Gauss-Jordan procedure is completed, we obtain
since, AA−1 = I.
Remark Partial pivoting can also be done using the augmented matrix [A—I].
However, we cannot first interchange the rows of A and then find the inverse. Then,
we would be finding the inverse of a different matrix.
3 5 3
using the Gauss-Jordan method (i) without partial pivoting, and (ii) with partial
pivoting.
AX = B.
48
Definition: An LU decomposition of a matrix A is the product of a lower triangular
matrix and an upper triangular matrix that is equal to A.
It turns out that we need only consider lower triangular matrices L that have 1’s
down the diagonal. Here is an example, let
1 2 4
A = 3 8 14 = LU
2 6 13
1 0 0 U11 U12 U13
where L = L21 1 0 and U = 0 U22 U23 Multiplying out LU and
Now we have to use this to find the entries in L and U. Fortunately this is not nearly
as hard as it might at first seem. We begin by running along the top row to see that
Notice how, at each step, the equation in hand has only one unknown in it, and other
quantities that we have already found. This pattern continues on the last row
49
L31U12 + L32U22 = 6 ⇒ 2 × 2 + L32 × 2 = 6 ⇒ L32 = 1,
2 6 13 2 1 1 0 0 3
The benefit of this approach is that we only ever need to solve triangular systems.
The cost is that we have to solve two of them.
50
x1 1 2 4 x1 3
Example 3.2.5 Find the solution of X = x2 of 3 8 14 x2 = 13
x3 2 6 13 x3 4
Solution
• The first step is to calculate the LU decomposition of the coefficient matrix on the
lefthand side. In this case that job has already been done since this is the matrix we
considered earlier. We found that
1 0 0 1 2 4
L= 3 1 0 , U = 0 2 2
2 1 1 0 0 3
d1
The next step is to solve LD = B for the vector D = d2 That is we consider
d3
1 0 0 d1 3
LD = 3 1 0 d2 = 13 = B
2 1 1 d3 4
which can be solved by forward substitution. From the top equation we see that
d1 = 3. The middle equation states that 3d1 + d2 = 13 and hence d2 = 4. Finally
the bottom line says that 2d1 + d2 + d3 = 4 from which we see that d3 = 6. Now
that we have found D we finish the procedure by solving UX = D for X. That is we
solve
1 2 4 x1 3
UX = 0 2 2 x2 = 4 = D
0 0 3 x3 6
by using back substitution. Starting with the bottom equation we see that 3x3 = −6
so clearly x3 = −2. The middle equation implies that 2x2 + 2x3 = 4 and it follows
that x2 = 4. The top equation states that x1 + 2x2 + 4x3 = 3 and consequently x1 = 3.
51
Therefore we have found that the solution to the system of simultaneous equations
1 2 4 x1 3 3
3 8 14 x2 = 13 is X = 4
2 6 13 x3 4 −2
QR Decomposition
If A is a m × n matrix with linearly independent columns, then A can be decom-
posed as A = QR, where Q is a m × n matrix whose columns form an orthonormal
basis for the column space of A and R is an nonsingular upper triangular matrix.
u1 = kv1 kq1
52
..
.
Step 1
√
r11 = ka1 k = 3
1
√
3
√1
1
3
q1 = a1 =
ka1 k √1
3
0
step 2
2
r12 = qT1 a2 = − √
3
53
step 3
√1
−1 3 − 13
√1
2
0 2
qb2 = a2 − q1 qT1 a2
3
= a2 − q1 r12 = − (− √ ) 3
=
−1 3 √1
−1
3
3
0 0 0
r
2
r22 = kqb2 k =
3
− √16
q
2
1
3
q2 = qb2 =
kqb2 k
1
− √6
0
step 4
1
r13 = qT1 a3 = − √
3
step 5
1
r23 = qT2 a3 = √
6
step 6
− 12
−1
√
6
r33 = kqb3 k =
2
− √16
1 0
q3 = qb3 =
√1
kqb3
6
− √26
54
Therefore, A = QR
√1 − √16 − √16
1 −1 −1 √
3 √2 √1
3 − 3 − 3
√1 √2 0
1 0 0
= 3 6
0 √2 √1
1 −1 0
√1 − √16 √1 6 √6
3 6 6
0 0
0 0 −1 0 0 − √26 2
general linear iterative method for the solution of the system of equations Ax = b,
can be written in matrix form as
x(k+1) = Hx(k) + c, k = 0, 1, 2, . . .
Now, we derive two iterative methods for the solution of the system of algebraic
equations
a11 x1 + a12 x2 + a13 x3 = b1
a21 x1 + a22 x2 + a23 x3 = b2 (3.9)
a31 x1 + a32 x2 + a33 x3 = b3
55
3.3.1 Gauss-Jacobi Iteration Method
Sometimes, the method is called Jacobi method. We assume that the pivots aii 6= 0,
for all i. Write the equations as
Since, we replace the complete vector x(k) in the right hand side of (3.10) at the end
of each iteration, this method is also called the method of simultaneous displace-
ment.
Remark A sufficient condition for convergence of the Jacobi method is that the
system of equations is diagonally dominant, that is, the coefficient matrix A is di-
agonally dominant. We can verify that
n
|aii | ≥ ∑ |ai j |.
j=1,i6= j
If the system is not diagonally dominant, we may exchange the equations, if pos-
sible, such that the new system is diagonally dominant and convergence is guar-
anteed. This implies that convergence may be obtained even if the system is not
diagonally dominant.
Remark If the system is diagonally dominant, then the iteration converges for any
initial solution vector. If no suitable approximation is available, we can choose
x = 0, that is xi = 0 for all i. Then, the initial approximation becomes xi = abiii , for
all i.
56
Example 3.3.1 Solve the system of equations
4x1 + x2 + x3 = 2
x1 + 5x2 + 2x3 = −6
x1 + 2x2 + 3x3 = −4
Solution: Note that the given system is diagonally dominant. Jacobi method gives
the iterations as
(k+1) (k) (k)
x1 = 0.25[2 − (x2 + x3 )]
(k+1) (k) (k)
x2 = 0.2[−6 − (x1 + 2x3 )]
(k+1) (k) (k)
x3 = 0.33333[−4 − (x1 + 2x2 )], k = 0, 1, ...
(0) (0) (0)
We have the following results. (i) x1 = 0, x2 = 0, x3 = 0 First iteration
Second iteration
Third iteration
57
Fourth iteration
Fifth iteration
It is interesting to note that the iterations oscillate and converge to the exact solution
First iteration
Second iteration
Third iteration
58
(3) (2) (2)
x2 = 0.2[−6 − (x1 + 2x3 )] = 0.2[−6 − (1.06667 + 2(−0.84999))] = −1.07334,
(3) (2) (2)
x3 = 0.33333[−4−(x1 +2x2 )] = 0.33333[−4−(1.06667+2(−0.88333))] = −1.09999.
Fourth iteration
(3) (3)
x1 (4) = 0.25[2 − (x2 + x3 )] = 0.25[2 − (−1.07334 − 1.09999)] = 1.04333,
Fifth iteration
using the Jacobi iteration method. Obtain the result correct to three decimal places.
59
We obtain the following First iteration
Fourth iteration
60
(4) (3)
|x3 − x3 | = |0.39989 − 0.39960| = 0.00029.
Three decimal places of accuracy have not been obtained at this iteration. Fifth
iteration
Since, all the errors in magnitude are less than 0.0005, the required solution is
61
If both the Gauss-Jacobi and Gauss-Seidel methods converge, then Gauss-Seidel
method converges at least two times faster than the Gauss-Jacobi method.
5x1 + x2 + 20x3 = 67
First iteration
Since, all the errors in magnitude are less than 0.0005, the required solution is
−4x1 + x2 − x3 = −8
x1 − 3x2 + 7x3 = 17
63
diverges. Take the initial approximations as x1 = 0.9, x2 = −3.1, x3 = 0.9. Inter-
change the first and second equations and solve the resulting system by the Gauss-
Seidel method. Again take the initial approximations as x1 = 0.9, x2 = –3.1, x3 =
0.9, and obtain the result correct to two decimal places. The exact solution is
x1 = 1.0, x2 = –3.0, x3 = 1.0.
Solution: Note that the system of equations is not diagonally dominant. Gauss-
Seidel method gives the iteration
First iteration
64
(3) (3) (2)
x2 = [−8 + 4x1 + x3 ] = [−8 + 4(−7.0676) − 0.8339] = −37.1043,
(3) 1 (3) (3) 1
x3 = [17 − x1 + 3x2 ] = [17 + 7.0676 + 3(−37.1043)] = −12.4636.
7 7
It can be observed that the iterations are diverging very fast.
Now, we exchange the first and second equations to obtain the system
−4x1 + x2 − x3 = −8
65
Third iteration
Since, all the errors in magnitude are less than 0.005, the required solution is x1 =
0.9998, x2 = −3.0002, x3 = 0.9999. Rounding to two decimal places, we get
x1 = 1.0, x2 = −3.0, x3 = 1.0.
66
involving two non-linear equations. Let (x0 , y0 ) be an initial approximation to the
root of the system, and (x0 + h, y0 + k) be the root of the system given by (3.12).
Then we must have
f (x0 + h, y0 + k) = 0
(3.13)
g(x0 + h, y0 + k) = 0
Let us assume that f and g are differentiable expanding (3.13) by Taylor’s series, we
obtain
f (x0 + h, y0 + k) = f0 + h ∂∂xf + k ∂∂yf + . . . = 0
∂g
0
∂g
0 (3.14)
g(x0 + h, y0 + k) = g0 + h ∂ x + k ∂ y + . . . = 0
0 0
neglecting, the second and higher order terms and retaining only the linear terms of
(3.14), we obtain
h ∂∂xf + k ∂∂yf = − f0
∂g
0
∂g
0 (3.15)
h ∂ x + k ∂ y = −g0
0 0
where f0 = f (x0 , y0 ), ∂∂xf = ( ∂∂ xf )x=x0 ; ∂∂yf = ( ∂∂ yf )y=y0 solving (3.14) for h and k,
0 0
the next approximation of the root is given by
x1 = x0 + h
and
y1 = y0 + k
and
x2 + y2 = 16
By Newton–Raphson Method
Solution: To obtain the initial approximation we replace the first equation by its
asymptote y = x, which gives
√
2x2 = 16 ⇒ x = 2 2
√ √
let x0 = 2 2, y0 = 2 2, and (x0 , y0 ) be the initial approximation to the root of the
67
system.
∂g √ ∂g √
= 2x0 = 4 2 , = 2y0 = 4 2
∂ x0 ∂ y0
∂f ∂f √ √
h +k = − f0 ⇒ h(4 2) − k(4 2) = −(−4)
∂ x0 ∂ y0
⇒ h − k = 0.7072
and
∂g ∂g √ √
h +k = −g0 ⇒ h(4 2) + k(4 2) = 0
∂ x0 ∂ y0
⇒ h+k = 0
so that
h–k = 0.7072 (i)
h+k = 0 (ii)
68
Example 3.4.2 Solve
f (x, y) = x2 + y − 20x + 40 = 0
g(x, y) = x + y2 − 20y + 20 = 0
∂f ∂f
f = x2 + y − 20x + 40 ⇒ = 2x − 20 , =1
∂x ∂y
∂g ∂g
g = x + y2 − 20y + 20 ⇒ =1 , = 2y − 20
∂x ∂y
and f0 = 40, g0 = 20
So that
∂f ∂f
= −20, =1
∂ x0 ∂ y0
∂g ∂g
=1 , = −20
∂ x0 ∂ y0
the linear equations are
∂f ∂f
h +k = − f0 ⇒ 20h + k = −40
∂ x0 ∂ y0
∂g ∂g
h +k = −g0 ⇒ h − 20k = −20
∂ x0 ∂ y0
Solving, we get
h = 2.055, k = 1.103
The next approximation is given by
x1 = x0 + h = 2.055
y1 = y0 + k = 1.103.
69
Chapter 4
FINITE DIFFERENCES
Introduction
E f (x) = f (x + h),
= E f (x + h)
= f (x + 2h)
Similarly
E n f (x) = f (x + nh)
and
E −n f (x) = f (x − nh).
70
2. E(c f (x)) = cE f (x) (where c is constant)
Ey1 = y2
...
E 2 y0 = y2
...
and in general E n y0 = yn .
∆y0 = y1 − y0
∆y1 = y2 − y1
...
∆yn−1 = yn − yn−1
The symbol ∆ is called the difference operator. The differences of the first differ-
ences denoted by ∆y and ∆2 y0 , ∆2 y1 , . . . , ∆2 yn are called second differences, where
∆2 y0 = ∆[∆y0 ]
71
= ∆[y1 − y0 ]
= ∆y1 − ∆y0
= y2 − 2y1 + y0
Similarly
∆r yk = ∆r−1 yk+1 − ∆r−1 yk
Alternative Notation
Let the functions y = f (x) be given at equal spaces of the independent variable x,
say at x = a, a + h, a + 2h, . . . , etc., and the corresponding values of f (a), f (a +
h), f (a + 2h), . . . , etc. The independent variable x is often called the argument and
the corresponding value of the dependent variable is of the function at x = a, and is
denoted by ∆ f (a). Thus we have
∆ f (a) = f (a + h) − f (a),
∆ f (a + h) = f (a + h + h) − f (a + h) = f (a + 2h) − f (a + h)
Similarly
Note: The operator ∆ is called forward difference operator and in general it is de-
fined as
∆ f (x) = f (x + h) − f (x),
72
The following table is an example to show how the differences are formed.
x y ∆y ∆2 y ∆3 y ∆4 y ∆5 y
x0 y0
∆y0
x1 y1 ∆2 y0
∆y1 ∆3 y0
x2 y2 ∆2 y1 ∆4 y
∆y2 ∆3 y1 ∆5 y0
x3 y3 ∆2 y2 ∆4 y1
∆y3 ∆3 y1
x4 y4 ∆2 y3
∆y4
x5 y5
The above table is called a diagonal difference table. The first term in the table is
y0 . It is called the leading term. The differences ∆y0 , ∆2 y0 , ∆3 y0 , . . . ∆n y, are called
the leading differences. The differences ∆n yn with a fixed subscript are called for-
ward differences. In forming such a difference table care must be taken to maintain
correct sign.
Properties of the Operator
1. If c is a constant then ∆c = 0.
73
Solution:
x y ∆y ∆2 y ∆3 y
1 4
9
2 13 12
21 6
3 34 18
39 6
4 73 24
63
5 136
Theorem 4.2.1 : The nth forward differences of a polynomial of the nth degree
are constant when the values of independent variable are at equal intervals. i.e
∆ f (x) = n!hn where f (x) is nth degree polynomial.
Proof Exercise
Example 4.2.2 By constructing a forward difference table and taking the second
order forward differences as constant find the sixth term of the series 8, 12, 19, 29, 42, . . . .
Solution: Let K be the sixth term of the series. The difference table is
x y ∆ ∆2
1 8
4
1 12 3
7
3 19 3
10
4 29 3
13
5 42 k − 55
k−4
6 k
74
The second differences are constant.
⇒ K − 55 = 3
⇒ K = 58.
Let y = f (x) be a function given by the values y0 , y1 , . . . yn which it takes for the
equally spaced values x0 , x1 , . . . , xn of the independent variable x. Then y1 − y0 , y2 −
y1 , . . . , yn − yn−1 are called the first backward differences of y = f (x). They are
denoted by 5y0 , 5y1 , . . . , 5yn respectively. Thus we have
y1 − y0 = 5y1
y2 − y1 = 5y2
..
.
yn − yn−1 = 5yn
x y 5 52 y 53 y 54 y
x0 y0
5y0
x1 y1 52 y0
5y1 53 y0
x2 y2 52 y1 54 y
5y2 53 y1
x3 y3 52 y2
5y3
x4 y4
75
Note: In the above table the differences 5n y with a fixed subscript i, lie along the
diagonal upward sloping.
Alternative notation: Let the function y = f (x) be given at equal spaces of the
independent variable x at x = a, a + h, a + 2h, . . . then we define 5 f (a) = f (a) −
f (a − h) where 5 is called the backward difference operator, h is called the interval
of differencing.
In general we can define
We observe that
5 f (x + h) = f (x + h) − f (x) = ∆ f (x)
5 f (x + 2h) = f (x + 2h) − f (x + h) = ∆ f (x + h)
...
Similarly we get
52 f (x + 2h) = 5[5 f (x + 2h)]
...
5n f (x + nh) = ∆n f (x).
⇒ 5 = 1 − E −1
or
E −1
5=
E
76
Chapter 5
Interpolation
Introduction:
In this chapter, we discuss the problem of approximating a given function by
polynomials. There are two main uses of these approximating polynomials. The
first use is to reconstruct the function f (x) when it is not given explicitly and only
values of f (x) and/ or its certain order derivatives are given at a set of distinct
points called nodes or tabular points. The second use is to perform the required
operations which were intended for f (x), like determination of roots, differentiation
and integration etc. can be carried out using the approximating polynomial P(x).
The approximating polynomial P(x) can be used to predict the value of f (x) at a
nontabular point. The deviation of P(x) from f (x), that is f (x) − P(x), is called
the error of approximation. Let f (x) be a continuous function defined on some
interval [a, b], and be prescribed at n + 1 distinct tabular points x0 , x1 , . . . , xn such
that a = x0 < x1 < x2 < ... < xn = b. The distinct tabular points x0 , x1 , ..., xn may
be non-equispaced or equispaced, that is xk+1 − xk = h, k = 0, 1, 2, . . . , n − 1. The
problem of polynomial approximation is to find a polynomial Pn (x), of degree ≤ n,
which fits the given data exactly, that is,
The polynomial Pn (x) is called the interpolating polynomial. The conditions given
in (5.1) are called the interpolating conditions
77
5.1 Linear Interpolation
Given two points (x0 , y0 ) and (x1 , y1 ), the linear polynomial passing through the
two points is the equation of the line passing through the points. One way to write
its formula is
x1 − x x − x0
P1 (x) = y0 + y1
x1 − x0 x1 − x0
Example 5.1.1 For the data points (2, 3) and (5, 7) find P1 (x).
Solution: let x0 = 2, y0 = 3 , x1 = 5 , y1 = 7
x1 − x x − x0 2−x x−2 7
P1 (x) = y0 + y1 = 3( ) + 7( ) = (5 − x) + (x − 2)
x1 − x0 x1 − x0 5−2 5−2 3
x x0 x1 x2 ... xn
f (x) f (x0 ) f (x1 ) f (x2 ) . . . f (xn )
78
At x = x0 , we get
(x − x0 ), (x − x1 ), . . . , (x − xi−1 ), (x − xi+1 ), . . . , (x − xn )
are factors of li (x). The product of these factors is a polynomial of degree n. There-
fore, we can write
where C is a constant.
Now, since li (xi ) = 1, we get
Hence
1
C=
(xi − x0 )(xi − x1 )...(xi − xi−1 )(xi − xi+1 )...(xi − xn )
Therefore,
Note that the denominator on the right hand side of li (x) is obtained by setting x = xi
in the numerator. The polynomial given in (5.2) where li (x) are defined by (5.4)
is called the Lagrange interpolating polynomial and li (x) are called the Lagrange
79
fundamental polynomials.
We can write the Lagrange fundamental polynomials li (x) in a simple notation.
Denote
w(x) = (x − x0 )(x − x1 ) . . . (x − xn )
which is the product of all factors. Differentiating w(x) with respect to x and sub-
stituting x = xi we get
since all other terms vanish. Therefore, we can also write li (x) as
w(x)
li (x) = .
(x − xi )(w0 (x)
Linear interpolation
x x0 x1
f (x) f (x0 ) f (x1 )
x − x1
l0 (x) = ,
x0 − x1
x − x0
l1 (x) =
x1 − x0
The Lagrange linear interpolation polynomial is given by
Quadratic interpolation
x x0 x1 x2
f (x) f (x0 ) f (x1 ) f (x2 )
80
The Lagrange fundamental polynomials are given by
(x − x1 )(x − x2 )
l0 (x) = ,
(x0 − x1 )(x0 − x2 )
(x − x0 )(x − x2 )
l1 (x) =
(x1 − x0 )(x1 − x2
(x − x0 )(x − x1 )
l2 (x) =
x2 − x0 )(x2 − x1 )
The Lagrange quadratic interpolation polynomial is given by
Example 5.2.1 Use Lagrange’s formula, to find the quadratic polynomial that takes
the values
x 0 1 3
y 0 1 0
(x − x0 )(x − x2 ) x(x − 3) 1
l1 (x) = = = (3x − x2 )
(x1 − x0 )(x1 − x2 ) (1)(−2) 2
1 1
f (x) = l1 (x) f (x1 ) = (3x − x2 )(1) = (3x − x2 )
2 2
Example 5.2.2 Construct the Lagrange interpolation polynomial for the data
x −1 1 4 7
f (x) −2 0 63 342
Hence, interpolate at x = 5.
81
Solution The Lagrange fundamental polynomials are given by
1 3
=− (x − 12x2 + 39x − 28).
80
(x − x0 )(x − x2 )(x − x3 ) (x + 1)(x − 4)(x − 7)
l1 (x) = =
(x1 − x0 )(x1 − x2 )(x1 − x3 ) (1 + 1)(1 − 4)(1 − 7)
1 3
= (x − 10x2 + 17x + 28).
36
(x − x0 )(x − x1 )(x − x3 ) (x + 1)(x − 1)(x − 7)
l2 (x) = =
(x2 − x0 )(x2 − x1 )(x2 − x3 ) (4 + 1)(4 − 1)(4 − 7)
1 3
=− (x − 7x2 − x + 7).
45
(x − x0 )(x − x1 )(x − x2 ) (x + 1)(x − 1)(x − 4)
l3 (x) = =
(x3 − x0 )(x3 − x1 )(x3 − x2 ) (7 + 1)(7 − 1)(7 − 4)
1 3
=(x − 4x2 − x + 4).
144
Note that we need not compute l1 (x) since f (x1 ) = 0. The Lagrange interpolation
polynomial is given by
1 3 1 1 3
=− (x −12x2 +39x−28)(−2)− (x3 −7x2 −x+7)(63)+ (x −4x2 −x+4)(342)
80 45 144
= x3 − 1.
82
5.3 Newton Interpolation Formula(forward and back-
ward difference formulas)
where h is the interval of differencing. Let φ (x) be a polynomial of the nth degree in
x taking the same values as y corresponding to x = x0 , x1 , . . . , xn , then, φ (x) repre-
sents the continuous function y = f (x) such that f (xr ) = φ (xr ) for r = 0, 1, 2, . . . , n
and at all other points f (x) = φ (x) + R(x) where R(x) is called the error term (Re-
mainder term) of the interpolation formula. Ignoring the error term let us assume
f (x) ≈ φ (x) ≈ a0 +a1 (x−x0 )+a1 (x−x0 )(x−x1 ) . . . an (x−x0 )(x−x1 ) . . . (x−xn−1 )
(5.5)
the constants a0 , a1 , a2 , . . . , an can be determine as follows. Putting x = x0 in
(5.5) we get
f (x0 ) ≈ φ (x0 ) = a0
⇒ y0 = a0
∴ y1 = y0 + a1 h
y1 − y0 ∆y0
⇒ a1 = =
h h
Putting x = x2 in (5.5) we get
∆y0
∴ y2 = a0 + a1 (2h) + a2 (2h)(h) = y0 + (2h) + a2 (2h)(h)
h
83
⇒ y2 = y0 + 2(y1 − y0 ) + a2 (2h2 )
y2 − 2y1 + y0 ∆2 y0
⇒ a2 = =
2h2 2!h2
Similarly by putting x = x3 , x = x4 , . . . , x = xn in (5.5) we get
∆3 y0 ∆4 y0 ∆n y0
a3 = , a 4 = , . . . , an =
3!h3 4!h4 n!hn
∆y0 ∆2 y0 ∆n y0
f (x) ≈ φ (x) = y0 + (x−x0 )+ (x−x0 )(x−x1 )+· · ·+ (x−x0 )(x−x1 ) . . . (x−xn−1 )
h 2!h2 n!hn
(5.6)
x−x0
Writing p = h , we get x − x0 = ph
x − x1 = x − x0 − (x1 − x0 ) = ph − h = (p − 1)h
Similarly
x − xn−1 = (p − n + 1)h
2. y0 may be taken as any point of the table, but the formula contains only those
values of y which come after the value chosen as y0 .
84
Example 5.3.1 Evaluate y = e2x for x = 0.05 using the following table
x y = e2x ∆y ∆2 y ∆3 y ∆4 y
0.000 1.0000
0.2214
0.10 1.2214 0.0490
0.2704 0.0109
0.20 1.4918 0.0599 0.0023
0.3303 0.0132
0.30 1.8221 0.0731
0.4034
0.4 2.2255
x − x0 0.5 − 0.00
∴ p= = = 0.5
h 0.1
∴ f (0.05) ≈ 1.052.
85
between certain limits were as follows:
Marks 30 − 40 40 − 50 50 − 60 60 − 70 70 − 80
No.o f Students 31 42 51 35 31
Find the number of candidates whose scores lie between 45 and 50.
Solution: Fist of all we construct a cumulative frequency table for the given data.
x y ∆y ∆2 y ∆3 y ∆4 y
40 31
42
50 73 9
51 −25
60 124 −16 37
35 12
70 159 −4
31
80 190
x − x0 45 − 40
p= = = 0.5
h 10
and
y0 = 73, ∆y0 = 42, ∆2 y0 = 9, ∆3 y0 = −25, ∆4 y0 = 37
86
= 31 + 21 − 1.125 − 1.5625 − 1.4452 = 47.8673
= 48 (approximately)
The number of students who obtained marks less than 45 = 48, and the number of
students who scored marks between 45 and 50 = 73 - 48 = 25.
Exercises 5.3.2 A second degree polynomial passes through the points (1, -1), (2,
-1), (3, 1), (4, 5). Find the polynomial.
f (x) ≈ φ (x) = a0 +a1 (x−xn )+a2 (x−xn )(x−xn−1 )+· · ·+an (x−xn )(x−xn−1 ) . . . (x−x1 )
(5.7)
Putting x = xn is (5.7) we get
f (xn ) ≈ φ (xn ) = a0 .
⇒ yn = a0 .
⇒ yn−1 = yn + a1 (−h)
⇒ a1 h = yn − yn−1
87
yn − yn−1 5yn
⇒ a1 = =
h 1!h
Putting x = xn−2 , we get
yn − yn−1
⇒ yn−2 = yn + (−2h) + a2 (−2h)(−h)
h
⇒ yn−2 = yn − 2yn + 2yn−1 + 2(h)2 a2
yn − 2yn−1 + yn−2 52 yn
⇒ a2 = =
2h2 2!h2
similarly putting x = xn−3 , x = xn−4 , x = xn−5 , . . . we get
53 yn 54 yn 5n yn
a3 = , a 4 = , . . . , a n =
3!h3 4!h4 n!hn
5yn 52 yn 5n yn
f (x) ≈ φ (x) = yn + (x−xn )+ (x−xn )(x−xn−1 )+. . .+ (x−xn )(x−xn−1 ) . . . (x−x1 )
1!h 2!h2 n!hn
(5.8)
x−xn
writing p = h we get x − xn = ph
p(p + 1)(p + 2) . . . (p + n − 1) n
+···+ 5 yn
n!
The above formula is known as Newton’s backward interpolation formula.
Example 5.3.2 The following data gives the melting point of an alloy of lead and
zinc, where t is the temperature in degrees c and P is the percentage of lead in the
88
alloy. P is the percentage of lead in the alloy.
P 40 50 60 70 80 90
t 180 204 226 250 276 304
Solution The value of 84 is near the end of the table, therefore we use the Newton’s
backward interpolation formula. The difference table is
x y 5y 52 y 53 y 54 y 55 y
40 184
20
50 204 2
22 0
60 226 2 0
24 0 0
70 250 2 0
26 0
80 276 2
28
90 304
53 yn = 54 yn = 55 yn = 0
x − xn 84 − 90
p== = −0.6
h 10
From Newton’s backward formula
5tn P(p + 1) 2
f (84) = tn + p + 5 tn + . . .
1! 2!
(−0.6)(−0.6 + 1)
f (84) = 304 + (−0.6)(28) + (2)
2!
= 304 − 16.8 − 0.24 = 286.96.
89
Exercises 5.3.3 Calculate the value of f (7.5) using table below
x 1 2 3 4 5 6 7 8
f (x) 1 8 27 64 125 216 343 512
∆y0 ∆2 y0 ∆n y0
f (x) = y0 + (x−x0 )+ (x−x0 )(x−x1 )+· · ·+ (x−x0 )(x−x1 ) . . . (x−xn−1 )
h 2!h2 n!hn
df d f dp 1 d f
= =
dx d p dx h d p
dp 1
Since dx = h
df 1 1 1 1
= [∆ f0 + (2p−1)∆2 f0 + (3p2 −6p+2)∆3 f0 + (4p3 −18p2 +22p−6)∆4 f0 +. . .]
dx h 2 6 24
(5.10)
0
At x = x0 , that is, at s = 0, we obtain the approximation to the derivative f (x) as
1 1 1 1
f 0 (x) = [∆ f0 − ∆2 f0 + ∆3 f0 − ∆4 f0 + . . .]
h 2 3 4
d2 f
dx2
= h1 ddp ( dd pf ) ddxp
1 1
(5.11)
= h2
[∆2 f0 + (p − 1)∆3 f0 + 12 (6p2 − 18p + 11)∆4 f0 + · · · ]
90
putting p = 0 in (5.11) we have
d2y 1 11
( 2
)x=x0 = 2 [∆2 f0 − ∆3 f0 − ∆4 f0 + · · · ] (5.12)
dx h 12
d3y 1 3
( 3
)x=x0 = 3 [∆3 f0 + ∆4 f0 + · · · ] (5.13)
dx h 2
x 1 2 3 4
f (x) 1 8 27 64
x y ∆y ∆2 y ∆3 y
1 1
7
2 8 12
9 6
3 27 18
37
4 64
We have h = 1, x0 = 1, and x = x0 + sh = 1 + s. For x = 1, we get s = 0. Therefore,
dy 1 1 1
(1) = (∆ f0 − ∆2 f0 + ∆3 f0 )
dx h 2 3
1 1
= 7 − (12) + (6) = 3
2 3
Exercises 5.4.1 The following data gives the velocity of a particle for 8 seconds at
an interval of 2 seconds. Find the initial acceleration using the entire data.
time(sec) 0 2 4 6 8
velocity(m/sec) 0 172 1304 4356 10288
91
5.4.2 Derivatives using Newton’s Backward Interpolation For-
mula
y = yn + p 5y n
1! +
P(p+1)
2! 52 yn + p(p+1)(p+2)
3! 53 yn
(5.14)
+ · · · + p(p+1)(p+2)...(p+n−1)
n! 5n yn
where p = x−x h
n
⇒ ddxp = 1h h being the interval of differencing
Differentiating (5.14) w.r.t. x we get
df d f dp 1 d f
= =
dx d p dx h d p
df
dx = 1h [5 fn + 12 (2p + 1) 52 fn + 16 (3p2 + 6p + 2) 53 fn + 24
1
(4p3 + 18p2 + 22p + 6) 54 fn
1
+ 120 (5p4 + 40p3 + 105p2 + 100p + 24) 54 fn + · · · ]
(5.15)
At x = xn , we get s = 0. Hence, we obtain the approximation to the first derivative
f (xn ) as
1 1 1 1 1
f 0 (xn ) = [5 fn + 52 fn + 53 fn + 54 fn + 55 fn + · · · ]
h 2 3 4 5
d2 f
1 d df dp 1 d df
2
= = 2
dx h dp dp dx h d p dp
d2 f 1 1
dx2
= h2
[52 fn + (p + 1) 53 fn + 12 (6p2 + 18p + 11) 54 fn
(5.16)
1
+ 24 (4p3 + 24p2 + 42p + 20) 54 fn + · · · ]
92
At x = xn , that is, at s = 0, we obtain the approximation to the second derivative
f 00 (x) as
f 00 (xn ) = h12 [52 fn + 53 fn + 11 4
12 5 f n
(5.17)
+ 56 54 fn + 137 5
180 5 f n + · · · ]
Remark We use the backward difference formulas for derivatives, when we need
the values of the derivatives near the end of table of values.
Example 5.4.2 Find f 0 (3) using the Newton’s backward difference formula, for the
data
Solution: The step length is h = 0.5 and x = xn + sh = 3.0 + s(0.5). For x = 3.0,
we get s = 0. We have the following backward difference table.
Backward difference table
x y 5y 52 y 53 y 54 y
1.0 −1.5
−1.375
1.5 −2.875 0.75
−0.625 0.75
2.0 −3.5 1.5 0
0.875 0.75
2.5 −2.625 2.25
3.125
3.0 0.5
1 1 1 1 1
f 0 (xn ) = [5 fn + 52 fn + 53 fn + 54 fn + 55 fn + · · · ]
h 2 3 4 5
we obtain
1 1 1
f 0 (3.0) = [3.125 + (2.25) + (0.75)] = 9
0.5 2 3
93
5.4.3 Numerical Integration
Introduction
The problem of numerical integration is to find an approximate value of the integral
Z b
I= w(x) f (x)dx
a
where w(x) > 0 in (a, b) is called the weight function. The function f (x) may be
given explicitly or as a tabulated data. We assume that w(x) and f (x) are integrable
on [a, b]. The limits of integration may be finite, semi-infinite or infinite. The
integral is approximated by a linear combination of the values of f (x) at the tabular
points as
Z b n
I= w(x) f (x)dx = ∑ λk f (xk )
a k=0
We note that, ab f (x)dx defines the area under the curve y = f (x), above the x-axis,
R
1
f (x) = f (x0 ) + (x − x0 )∆ f (x0 )
h
94
Figure 5.1: Trapizium rule
1 1
= (x1 − x0 ) f (x0 ) + [ (x − x0 )2 ]xx10 ∆ f (x0 )
h 2
1
= (x1 − x0 ) f (x0 ) + [ f (x1 ) − f (x0 )](x1 –x0 )2
2h
h
= h f (x0 ) + [ f (x1 ) − f (x0 )]
2
h (b − a)
= [ f (x1 ) + f (x0 )] = [ f (b) + f (a)].
2 2
The trapezium rule is given by
Z b
h b−a
I= f (x)dx = [ f (x1 ) + f (x0 )] = [ f (b) + f (a)] (5.19)
a 2 2
Hence, the trapezium rule integrates exactly polynomial of degree ≤ 1, and the
method is of order 1.
Composite trapezium rule
Let the interval [a, b] be subdivided into N equal parts of length h. That is,
h = b−a
N . The nodal points are given by
a = x0 , x1 = x0 + h, x2 = x0 + 2h, ..., xN = x0 + Nh = b.
We write
Z b Z xN Z x1 Z x2 Z xN
f (x)dx = f (x)dx = f (x)dx + f (x)dx + · · · + f (x)dx
a x0 x0 x1 xN−1
95
There are N integrals. Using the trapezoidal rule to evaluate each integral, we get
the composite trapezoidal rule as
Rb
af (x)dx = 2h [{ f (x0 ) + f (x1 )} + { f (x1 ) + f (x2 )} + · · · + { f (xN−1 ) + f (xN )}]
= h2 [ f (x0 ) + 2{ f (x1 ) + f (x2 ) + ... + f (xN−1 )} + f (xN )].
(5.20)
The composite trapezium rule is also of order 1.
The formula (5.20) is called Trapezoidal rule for numerical integration. The error
committed in this formula is given by
h3 00 (b − a)3 00
E ≈ − f (ξ ) = − f (ξ ), (5.21)
12 12n2
where
a = x0 < ξ < xn = b.
Solution With N = 2, 4 and 8, we have the following step lengths and nodal points.
1
N = 2, h = b−a
N = 2 the nodes are 0, 0.5, 1.0
1
N = 4, h = b−a
N = 4 the nodes are 0, 0.25, 0.5, 0.75, 1.0
1
N = 8, h = b−a
N = 8 the nodes are 0, 0.125, 0.25, 0.375, 0.5, 0.675, 0.75, 0.875, 1.0
We have the following tables of values.
N = 4: We require the above values. The additional values required are the
following:
x 0.25 0.75
f (x) 0.8 0.571429
N = 8: We require the above values. The additional values required are the follow-
ing:
x 0.125 0.375 0.625 0.875
f (x) 0.888889 0.727273 0.615385 0.533333
96
Now, we compute the value of the integral
h
N =2: I1 = [ f (0)+2 f (0.5)+ f (1.0)] = 0.25[1.0+2(0.666667)+0.5] = 0.708334.
2
h
N=4: I2 = [ f (0) + 2 f (0.25) + f (0.5) + f (0.75) + f (1.0)]
2
= 0.125[1.0+20.8 + 0.666667 + 0.571429+0.5] = 0.697024.
h
N=8: I3 = [ f (0) + 2( f (0.125) + f (0.25) + f (0.375) + f (0.5)
2
+ f (0.625) + f (0.75) + f (0.875)) + f (1.0)]
= 0.0625[1.0+2(0.888889+0.8+0.727273+0.666667+0.615385
The exact value of the integral is I = ln2 = 0.693147. The errors in the solutions
are the following:
Solution: With N = 4 and 8, we have the following step lengths and nodal points.
1
N = 4 : h = b−aN = 4 . The nodes are 1, 1.25, 1.5, 1.75, 2.0.
1
N = 8 : h = b−aN = 8 . The nodes are 1, 1.125, 1.25, 1.375, 1.5, 1.675, 1.75, 1.875, 2.0.
We have the following tables of values.
N = 4:
x 1.0 1.25 1.5 1.75 2.0
f (x) 0.125 0.11429 0.10526 0.09756 0.09091
97
N = 8: We require the above values. The additional values required are the
following
x 1.125 1.375 1.625 1.875
f (x) 0.11940 0.10959 0.10127 0.09412
Now, we compute the value of the integral.
h
N=4: I1 = [ f (1) + 2( f (1.25) + f (1.5) + f (1.75)) + f (2.0)]
2
= 0.125[0.125+2(0.11429+0.10526+0.09756)+0.09091] = 0.10627.
h
N=8: I2 = [ f (1) + 2( f (1.125) + f (1.25) + f (1.375) + f (1.5)
2
+ f (1.625) + f (1.75) + f (1.875)) + f (2.0)]
1 1
I = [5 + 3x]21 = [ln(11) − ln(8)] = 010615.
3 3
Exercises 5.4.2 Using the trapezium rule, evaluate the integral I = 01 x2 +6x+10
dxR
,
with 2 and 4 subintervals. Compare with the exact solution. Comment on the
magnitudes of the errors obtained.
Exercises 5.4.3 The velocity of a particle which starts from rest is given by the
following table.
t(sec) 0 2 4 6 8 10 12 14 16 18 20
v( f t/sec) 0 16 29 40 46 51 32 18 8 3 0
98
Note: Trapezoidal rule can be applied to any number of subintervals odd or even.
In the previous section, we have shown that the trapezium rule of integration in-
tegrates exactly polynomials of degree 1, that is, the order of the formula is 1.
In many science and engineering applications, we require methods which produce
more accurate results. One such method is the Simpson’s 1/3 rule. Let the interval
[a, b] be subdivided into two equal parts with step length h = b−a 2 . We have three
a+b
abscissas x0 = a, x1 = 2 , and x2 = b. Then, P(x0 , f (x0 )), Q(x1 f (x1 )), R(x2 , f (x2 ))
are three points on the curve y = f (x). We approximate the curve y = f (x), axb,
by the parabola joining the points P, Q, R, that is, we approximate the given curve
by a polynomial of degree 2. Using the Newton’s forward difference formula, the
quadratic polynomial approximation to f(x), interpolating at the points P(x0 , f (x0 )), Q(x1 f (x1 )), R(x2 , f (x
is given by
1 1
f (x) = f (x0 ) + (x − x0 )∆ f (x0 ) + 2 (x − x0 )(x − x1 )∆ f (x0 ).
h 2h
99
Chapter 6
dx/dy + Py = Q
100
is called a linear differential equation order 1.
We can solve these linear DEs using an integrating factor. For linear DEs of
order 1, the integrating factor is:
R
P dx
e
Solution:
Here,
3
P(x) = −
x
and
Q(x) = 7
− 3x dx x−3
R R
IF = e P dx
=e = e−3 ln x = eln = x−3
F(x, y, y0 , y00 ) = 0.
Definition: The degree of the DE is the degree of the derivative of the highest order
after the equation has been rationalized in derivatives. An ODE is of two types
namely linear and non-linear.
Definition:An ODE is said to be linear if no product of the dependent variable y(t)
with itself or any one of its derivatives occur. Otherwise, it is non-linear. A linear
DE of order m can be expressed in the form
m
∑ Φ p(t)y p(t) = r(t)
p=0
101
in which Φ p (t) are known functions. If the general non-linear DE (6.1) of order m
can be written as
y(m) = F(t, y, y0 , . . . , y(m−1) ) (6.3)
then the equation in (6.3) is called a canonical (or natural) representation of the DE
(6.1). In such form, the highest order derivative is expressed in terms of the function
y, the lower order derivatives and the independent variable t.
a. (y00 )2 = xy
b. y0 y = −x
c. y0 = siny
102