Numerical Methods 1
Numerical Methods 1
Numerical Methods 1
For example,
3x3 – 2x2 – x – 5 = 0, x4 – 3x2 + 1 = 0, x2 – 3x + 1 = 0,
are algebraic (polynomial) equations, and
xe2x – 1 = 0, cos x – xex = 0, tan x = x
are transcendental equations.
Root/zero A number α, for which f(α) ≡ 0 is called a root of the equation f(x) = 0, or a zero of
f(x). Geometrically, a root of an equation f(x) = 0 is the value of x at which the graph of the
equation y = f(x) intersects the x-axis (see Fig. 1.1).
Simple root A number α is a simple root of f(x) = 0, if f(α) = 0 and f ′(α) ≠ 0. Then, we can write
f(x) as
f(x) = (x – α) g(x), g(α) ≠ 0.
(1.3)
Remark 1 A polynomial equation of degree n has exactly n roots, real or complex, simple or
multiple, where as a transcendental equation may have one root, infinite number of roots or no
root.
We shall derive methods for finding only the real roots.
The methods for finding the roots are classified as (i) direct methods, and (ii) iterative
methods.
Direct methods These methods give the exact values of all the roots in a finite number
of steps (disregarding the round-off errors). Therefore, for any direct method, we can give the
total number of operations (additions, subtractions, divisions and multiplications). This number
is called the operational count of the method.
For this method, we can give the count of the total number of operations. There are
direct methods for finding all the roots of cubic and fourth degree polynomials. However, 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.
This method uses one initial approximation to the root x0. The sequence of
approximations is given by
x1 = φ(x0), x2 = φ(x1), x3 = φ(x2), .....
The function φ is called an iteration function and x0 is called an initial approximation. If
a 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, .....
(1.6)
(i) We count the number of changes of signs in the coefficients of Pn(x) for the equation
f(x) = Pn(x) = 0. The number of positive roots cannot exceed the number of changes of
signs. For example, if there are four changes in signs, then the equation may have four
positive roots or two positive roots or no positive root. If there are three changes in signs,
then the equation may have three positive roots or definitely one positive root. (For
polynomial equations with real coefficients, complex roots occur in conjugate pairs.)
(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 cannot exceed the number of
changes of signs. Again, if there are four changes in signs, then the equation may have four
negative roots or two negative roots or no negative root. If there are three changes in signs,
then the equation may have three negative roots or definitely one negative root. We use the
following theorem of calculus to determine an initial approximation. It is also called the
intermediate value theorem.
Theorem 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,
Page 2 of 15
b). This result is very simple to use. We set up a table of values of f (x) for various values of
x. Studying the changes in signs in the values of f (x), we determine the intervals in which
the roots lie. For example, if f (1) and f (2) are of opposite signs, then there is a root in the
interval (1, 2).
Example 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
(ii) 3x3 – 2x2 – x – 5 = 0.
Solution:
(i) Let f(x) = 8x3 – 12x2 – 2x + 3 = 0.
The number of changes in the signs of the coefficients (8, – 12, – 2, 3) is 2. Therefore,
the equation has 2 or no positive roots. Now, f(– x) = – 8x 3 – 12x2 + 2x + 3. The number
of changes in signs in the coefficients (– 8, – 12, 2, 3) is 1. Therefore, the equation has
one negative root. We have the following table of values for f(x), (Table 1.1).
Solution:
(i) Let f(x) = xex – cos x = 0. We have f(0) = – 1, f(1) = e – cos 1 = 2.718 – 0.540 =
2.178. Since, f(0) f(1) < 0, there is a root in the interval (0, 1).
Since, f(1.1) f(1.2) < 0, the root lies in the interval (1.1, 1.2).
Now, we present some iterative methods for finding a root of the given algebraic or
transcendental equation.
We know from calculus, that in the neighborhood of a point on a curve, the curve can be
approximated by a straight line. For deriving numerical methods to find a root of an equation
f(x) = 0, we approximate the curve in a sufficiently small interval which contains the root, by a
straight line. That is, in the neighborhood of a root, we approximate
f(x) ≈ ax + b, a ≠ 0
where a and b are arbitrary parameters to be determined by prescribing two appropriate
conditions on f(x) and/or its derivatives. Setting ax + b = 0, we get the next approximation to
the root as x = – b/a. Different ways of approximating the curve by a straight line give different
methods. These methods are also called chord methods. Method of false position (also called
regula-falsi method) and Newton-Raphson method fall in this category of chord methods.
Page 3 of 15
The interval [a, b] is halved with each loop through steps B1 to B3. The test B2
will be satisfied eventually, and with it the condition |α − c| ≤ ε will be satisfied. Notice
that in the step B3 we test the sign of sign[f(b)] · sign[f(c)] in order to avoid the
possibility of underflow or overflow in the multiplication of f(b) and f(c).
EXAMPLE:
1.) Find the largest root of f(x) = x6 − x − 1 = 0 accurate to within ε = 0.001.
2.) Find the root of the given function using bisection method, f(x)= x 3+3x-5: (ε = 0.01)
2.) Find the largest root of the given function using bisection method: (ε = 0.01)
f(x)= x3+3x-5
(a,b)=(1,2)
n a b c b-c f(c)
1 1 2 1.5 0.5 2.875
2 1 1.5 1.25 0.25 0.7031
3 1 1.25 1.125 0.125 -0.2012
4 1.125 1.25 1.1875 0.0625 0.2371
5 1.125 1.1875 1.1563 0.0312 0.0149
6 1.125 1.1563 1.1407 0.0156 -0.0936
7 1.1407 1.1563 1.1485 0.0078 -0.0396
8 1.1485 1.1563 1.1524 0.0039 -0.01
Page 4 of 15
Having found x2, we can drop x0 and use x1, x2 as a new set of approximate
values for α. This leads to an improved values x 3; and this can be continued indefinitely.
Doing so, we obtain the general formula for the secant method
( )
EXAMPLE:
1. Find the root of the equation f(x)=x 6-x-1=0; Do five iterations only.
x0=1;x1=2
Therefore, the root of the equation at 5th iteration is approximately equal to 1.13367.
2. Find the root of the equation f(x)=xex-cos(x); Correct to three decimal places.
X0=0,X1=1
Page 5 of 15
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 (x k–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 (Figs. 1.2a, b). The line PQ is
taken as an approximation of the curve in the interval [x k–1, xk]. The equation of the line
PQ is given by
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
(1.10)
(1.11)
Therefore, starting with the initial interval (x0, x1), in which the root lies, we compute
Now, if f(x0) f(x2) < 0, then the root lies in the interval (x0,
x2). Otherwise, the root lies in the interval (x 2, x1). The iteration is continued using the
interval in which the root lies, until the required accuracy criterion given in Eq.(1.8) or
Eq.(1.9) is satisfied.
Page 6 of 15
Remark 3 At the start of each iteration, the required root lies in an interval, whose
length is decreasing. Hence, the method always converges.
Remark 4 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
(1.12)
(1.13)
Remark 5 The computational cost of the method is one evaluation of the function f(x),
for each iteration.
Remark 6 We would like to know why the method is also called a linear interpolation
method. Graphically, a linear interpolation polynomial describes a straight line or a
chord. The linear interpolation polynomial that fits the data (x k–1, fk–1), (xk, fk) is given by
(We shall be discussing the concept of interpolation polynomials in Chapter 2). Setting
f(x) = 0, we get
Page 7 of 15
EXAMPLE:
1. Locate the intervals which contain the positive real roots of the equation x 3 – 3x + 1 =
0. Obtain these roots correct to three decimal places, using the method of false
position.
Solution:
We form the following table of values for the function f(x).
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
Since, f(0) f(0.5) < 0, the root lies in the interval (0, 0.5).
Since, f(0) f(0.36364) < 0, the root lies in the interval (0, 0.36364).
Since, f(0) f(0.3487) < 0, the root lies in the interval (0, 0.34870).
Since, f(0) f(0.34741) < 0, the root lies in the interval (0, 0.34741).
Page 8 of 15
Since, f(1.25) f(2) < 0, the root lies in the interval (1.25, 2). We use the formula given in
Eq.(1.13).
Since, f(1.407407) f(2) < 0, the root lies in the interval (1.407407, 2).
Since f(1.482367) f(2) < 0, the root lies in the interval (1.482367, 2).
Since, f(1.513156) f(2) < 0, the root lies in the interval (1.513156, 2).
Since, f(1.525012) f(2) < 0, the root lies in the interval (1.525012, 2).
Since, f(1.529462) f(2) < 0, the root lies in the interval (1.529462, 2).
Since, f(1.531116) f(2) < 0, the root lies in the interval (1.531116, 2).
Since, f(1.531729) f(2) < 0, the root lies in the interval (1.531729, 2).
Page 9 of 15
2. Find the root correct to two decimal places of the equation xex = cos x, using the
method of false position.
Solution:
Define f(x) = cos x – xex = 0. There is no negative root for the equation. We have
f(0) = 1, f(1) = cos 1 – e = – 2.17798.
A root of the equation lies in the interval (0, 1). Let x 0 = 0, x1 = 1. Using the
method of
false position, we obtain the following results.
Since, f(0.31467) f(1) < 0, the root lies in the interval (0.31467, 1). We use the formula
given in Eq(1.13).
Since, f (0.44673) f(1) < 0, the root lies in the interval (0.44673, 1).
Since, f (0.49402) f(1) < 0, the root lies in the interval (0.49402, 1).
Since, f(0.50995) f(1) < 0, the root lies in the interval (0.50995, 1).
Since, f(0.51520) f(1) < 0, the root lies in the interval (0.51520, 1).
Page 10 of 15
3. Newton-Raphson Method
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.
where f ′(x0) is the slope of the tangent to the curve at P. Setting y = 0 and solving for x, we get
(1.14)
This method is called the Newton-Raphson method or simply the Newton’s method. The
method is also called the tangent method.
(1.15)
Page 11 of 15
Remark 7 Convergence of the Newton’s method depends on the initial approximation to the
root. If the approximation is far away from the exact root, the method diverges (see Example
1.6). However, if a root lies in a small interval (a, b) and x 0 ∈ (a, b), then the method
converges.
Remark 8 From Eq(1.14), we observe that the method may fail when f ′(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.
Remark 9 The computational cost of the method is one evaluation of the function f(x) and one
evaluation of the derivative f ′(x), for each iteration.
EXAMPLE:
1. Derive the Newton’s method for finding 1/N, where N > 0. Hence, find 1/17, using the
initial approximation as (i) 0.05, (ii) 0.15. Do the iterations converge?
Solution:
Let x= , or =N. Define f(x)= – N. Then, f’(x)=-
Since, | x4 – x3 | = 0, the iterations converge to the root. The required root is 0.058823.
(ii) With N = 17, and x0 = 0.15, we obtain the sequence of approximations
x1 = 2x0 – Nx02 = 2(0.15) – 17(0.15)2 = – 0.0825.
x2 = 2x1 – Nx12 = 2(– 0.0825) – 17(– 0.8025)2 = – 0.280706.
x3 = 2x2 – Nx22 = 2(– 0.280706) – 17(– 0.280706)2 = – 1.900942.
x4 = 2x3 – Nx32 = 2(– 1.900942) – 17(– 1.900942)2 = – 65.23275.
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 17 1/3 correct to four decimal places, assuming the
initial approximation as x0 = 2.
Solution:
Let x = N1/q, or xq = N. Define f(x) = xq – N. Then, f ′(x) = qx q –1
. Newton’s method gives
the iteration
Page 12 of 15
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 root lies in the
interval (0, 1). Applying the Newton’s method, we obtain
Page 13 of 15