You are on page 1of 18

SOLVING NONLINEAR EQUATIONS Part 2

Chapter 2

Graphical &
Bisection
Method
At the end of this chapter, students should be able to:
 Describe root finding
 Use graphical method to solve non-linear equations
 Describe and derive the Bisection method of finding roots
 Apply the Bisection method to reduce initial interval of uncertainty so as to attain
improved root estimates

2.1 Introduction
Chapter 2 shall discuss one of the most basic problems in numerical analysis,
that is solving non-linear equations also known as root finding. The problem
involves solving an equation of the form f ( x )  0 . An equation of this form can be
either linear or non-linear. A solution to the equation (also called a root of the
equation or a zero of f) is a numerical value of x that satisfies the given equation.
The equation may also have several possible roots or have no solution at all. In
this chapter, the focus of the discussion will be on solving non-linear equations in
one variable.

13
SOLVING NONLINEAR EQUATIONS Part 2

Definition
Given an equation f ( x )  0 , the function f (x ) is non-linear if it is not of the
form ax  b .

To begin with, let’s take a look at some classes of functions:


(a) linear functions: f ( x )  ax  b
(b) polynomials (non-linear):

f ( x )  an x n  an 1x n 1  an 2 x n 2  ...  a2 x 2  a1x  a0


(c) transcendental functions (non-linear):

Ex. f ( x )  tan x  x , or f ( x )  e x  3 ln 2x

2.2 Root Finding


In any algebra books we learn that the real roots of a quadratic equation can be
found either by factorizing or by using standard formula i.e. quadratic formula.
Even if the roots are irrational, they can always be found. The roots of a
polynomial of higher degree can also be found by using the factor theorem (only
when the roots are integers or simple rational fractions). When the equation is
simple, the solution can be determined analytically. However, in many situations
especially in engineering practice, it is almost impossible to determine the root of
an equation analytically. There are many equations whose roots cannot be
evaluated analytically or exactly by any methods. The approximate values of the
roots of such equations can be found either by a graphical approach or by one of
a number of methods using successive numerical approximations or by a
combination of these processes.

The procedure of solving a non-linear equation analytically is very different from


the algorithm used to solve it numerically. An analytical solution produces an
exact solution or exact solutions of the equation. A numerical solution is obtained
in a process that begins with finding a rough estimate of the solution and
subsequently followed by successive numerical procedures (sometimes called
“iterative procedures”) in which a better or more accurate estimate is
determined.

14
SOLVING NONLINEAR EQUATIONS Part 2

Essentially when we are discussing about solving non-linear equations or finding


roots of f ( x )  0 , graphically we are attempting to find where

(a) the function f (x ) crosses the x-axis, or


(b) two equations intersect each other (Figure 2.1).

y = f(x)
y y
y = h(x) y = g(x)

0 0
x x
root root

(a) (b)
Figure 2.1

In the case where f (x ) is a non-linear algebraic expression (transcendental


functions, polynomials or combinations of both), the approach to solving it
fundamentally begins with the intermediate value theorem.

If a function f (x ) is continuous on the interval (a, b) and if f (a) and f (b) have

different signs (one positive and one negative) or f (a)  f (b)  0 , then there exist
at least one real root in the interval (a, b).

y y

f(b) f(b)

0 0 a b x
a b x
f(a)
f(a)
root No root
f(a)

(a) f(x) is continuous on [a,b] (b) f(x) is not continuous on [a,b]


Figure 2.2

15
SOLVING NONLINEAR EQUATIONS Part 2

Take a note that the statement demands that the function f (x ) be continuous on
the given interval. Figure 2.2 illustrates two possible instances that may occur if
f (a)  f (b)  0 . Figure 2.2(b) shows that f (a)  f (b)  0 even though f (x ) is not
continuous (there exists no root between the values a and b).

Steps : Existence of a root

 Identify the interval (a, b)


 Identify the function f (x ) and compute f (a) and f (b)
 Determine if f (a)  f (b)  0

Example 1

Show analytically that f ( x )  x 3 has at least one root in the interval [-1, 2].

Solution

 Identify the interval


[-1, 2]  a = -1 and b=2
 Identify the function and compute f(a) and f(b)

f (x)  x3 f ( 1)  1 f (2)  8

 Determine if f (a)  f (b)  0

f (1)  f (2)  (1)(8)  8  0

Since f ( 1)  f (2)  0 it can be concluded that there exists at least a root in the
interval [-1, 2].

Example 2

Given h( x )  x 3  x  1, show that one of the zeroes of this function lies


between -2 and 1.

16
SOLVING NONLINEAR EQUATIONS Part 2

Solution

 Identify the interval


[-2, 1]  a = -2 and b=1
 Identify the function and compute at a and b

h( x )  x 3  x  1 h(2)  5 h(1)  1
 Determine if h(a)  h(b)  0
h(2)  h(1)  (5)(1)  5  0
Hence, there exists at least a root or one zero of h(x ) in the interval [-2, 1].

Warm up exercise
Determine the existence of a root for the following functions within the given
interval.

(i) f ( x)  x 3  6x  16 ; [1, 2]

  3 
(ii) f ( x)  cos x  cos 3x ; 4, 4 
 

2.3 Graphical Solution


Example 1 and Example 2 show the existence of a root within given interval. It
does not indicate where the root(s) or solution(s) is located. A plot of the graph
would provide a rough estimate of the position of the root(s).
In order to determine the interval of the root, let’s plot the graph. There are two
options to do this.
(a) Plot the graph f (x ) and observe where it crosses the x axis.

(b) Rewrite f(x)  0 into an equation of two simpler functions h( x )  g( x )


and plot these functions on the same axes. Observe where the two
functions h(x ) and g(x ) intersect and note on the x value where it
occurs.

17
SOLVING NONLINEAR EQUATIONS Part 2

Steps : Graphical Solution

 Identify an interval (a, b).


 Identify the function f (x ) .
 Tabulate the values of x versus f (x ) in (a, b)
 Plot the graph using tabulated values.
 Identify the x-intercept

Plotting the graph of f (x ) versus x may be tedious due to complicated


computations. Thus, breaking the equation into two parts and renaming as h(x )
and g(x ) could be rewarding especially if both functions are polynomials or
common transcendental functions in which graphs of the functions are easy to
plot.
f (x)  0 where f ( x )  h( x )  g( x )
h( x )  g( x )  0
h( x )  g( x )
When the two functions h(x ) and g(x ) are plotted on a Cartesian plane and their
graphs intersect at a point where x  a , then h(a)  g(a) . Conversely, when at
x  b the graphs do not intersect then h(b)  g(b) . Thus the values of x at which
the two graphs intersect is the set of values of x satisfying the equation
h( x )  g( x ) or the equation f ( x )  0 and the value x  a , is called the root
of f (x ) or the zero of f. This value is simply an estimate of the actual root or the
actual zero of f.

Graphical method of solving an equation h( x )  g( x ) usually proceeds as follows:


(a) Sketch the two graphs on the same axes and indicates the number and
rough positions of the roots of the equation.
(b) Choose a range indicated by the sketch. A plot of the two graphs on the
same axes gives a fair approximation for the value of each root within that
range.
(c) In order to obtain a better approximation of the root, determine a suitable
scale or range near to each required root.

18
SOLVING NONLINEAR EQUATIONS Part 2

Steps : Graphical Solution – Alternative Approach

 Identify the equation f ( x )  0 .


 Break the equation into two parts or two functions
h(x ) and g(x ) .
 Tabulate the values of x versus h(x ) and g(x )
 Plot the graphs using tabulated values.
 Identify the intersection point(s) of h(x ) and g(x )

Example 3
Use the graphical method to determine the interval which contains the real root

of f ( x )  e x  x  2 .

Solution

 Identify the equation :

f (x)  ex  x  2  ex  x  2  0
 In order to determine the interval of the root, let’s plot the graph. There
are two options to do this.

(a) Plot f ( x )  e x  x  2 on a graph and observe where f (x ) crosses


the x-axis (Figure 2.3a)

(a) f ( x )  e x  x  2 (b) h( x )  e x and g( x )  2  x


Figure 2.3

19
SOLVING NONLINEAR EQUATIONS Part 2

(b) Break f ( x )  e x  x  2 into two simpler functions (left and right of


the equal sign) and plot those functions on the same axes:
ex  x  2  0
ex  2  x
h( x )  g ( x )
Observe where the two functions h(x ) and g(x ) intersect and note on the x
value where it happens (Figure 2.3b).

Based on Figure 2.3 it can be shown that there exists a root in [0, 1]. From the
illustrations, we can further conclude that the root of f is roughly close to the
value 0.5. This value is a rough approximation of the root.

Example 4

Show graphically that the equation x 2 - x - 6  0 has two roots.

Solution

 Identify an interval (a, b)


(-4, 5)
 Identify the function f (x )

f(x)  x 2 - x - 6
 Tabulate the values of x versus f (x ) in (a, b).
Chose a suitable step-size.

x -4 -3 -2 -1 0 1 2 3 4 5
f(x) 14 6 0 -4 -6 -6 -4 0 6 14

 Plot the graph using points obtained.


 Identify where the function f (x ) intercepts x-axis.

 From the graph, the two roots of f are r1 and r2.

20
SOLVING NONLINEAR EQUATIONS Part 2

y
20

15 y=f(x)

10

0 x
-5 -4 -3 -2 -1 0 1 2 3 4 5 6

-5

r1 r2
-10

Figure 2.4

Example 5
x
Graphically show that equation sinx -  0 has a solution between x  1 and
2
x  2.

Solution

 Identify the equation f ( x )  0 .

x
sinx - 0
2
 Break the equation into two parts or two functions h(x ) and g(x ) .

x
sinx 
2
h(x)  g(x)
where
x
h(x)  sinx g(x) 
2
 Tabulate the values of x versus h(x ) and g(x )

x 1 1.2 1.4 1.6 1.8 2


h(x) 0.8415 0.9320 0.9854 0.9996 0.9738 0.9093
g(x) 0.5 0.6 0.7 0.8 0.9 1

 Plot the graphs h(x ) and g(x ) using the tabulated values.

21
SOLVING NONLINEAR EQUATIONS Part 2

y
1.2

0.8
h(x)=sin x

0.6

x
0.4 g(x) 
2

0.2

0 x
0 0.5 1 1.5 2 2.5
r
Figure 2.5

 Identify the intersection point(s) between h(x ) and g(x )

x
Figure 2.5 illustrates the graphs h( x )  sin x and g ( x )  being
2
plotted on the same axis and it can be observed that there is one
intersection point at x  r which is close to 2. Therefore, it can be
concluded that there exists at least a root r such that r  [1, 2] .

Let f ( x )  3x 2  e x  0 . Warm up exercise

(i) Algebraically determine where the root lies.


(ii) Graphically show the root(s).

The disadvantage of graphical method is that it lacks precision.


However, besides providing a rough approximation of the root, the graphical
method is an important tool and serves as a guide in understanding the
properties and behavior of the functions of interest and in anticipating pitfalls of
numerical procedure. In most numerical methods of finding roots, the rough
estimate of the root(s) obtained from graphing is used as a starting guess and
subsequently undergo numerical procedures to attain improved precision and
accuracy.

22
SOLVING NONLINEAR EQUATIONS Part 2

In the next section we are going to discuss three numerical methods of solving
non-linear equations or root finding:
(i) Bisection method
(ii) Newton’s method
(iii) Secant method
The numerical procedure for all the three methods is iterative in nature, or the
same process is repeated until a good approximation of the root is obtained.
Functional evaluation of f(x) at an improved estimation of the root should obtain a
value that is very near to the value zero.

2.4 Bisection Method


The simplest numerical technique that shall first be discussed here is the
Bisection method or sometimes called the method of halving of intervals (also
called the Bolzano’s method). The method is based on the Intermediate Value
theorem and attempts to locate a solution to the equation f (x )  0 in a sequence
of intervals of reducing size.

r1 r2 r3

f(b)
x
a
0 b

f(a)
Figure 2.6

In the Bisection method of solving f ( x )  0 , the function f (x ) is assumed to be

continuous on the interval (a, b) such that f (a)  f (b)  0 . Hence, there exists at

least one value r in the interval (a, b) in which f (r )  0 (r is the root). The
interval is then halved or divided into two subintervals by the midpoint of a and b.
Checking is done to locate in which of the two smaller subintervals the root is

23
SOLVING NONLINEAR EQUATIONS Part 2

contained. The process is repeated until a desired accuracy is achieved (Figure


2.6).

Steps : Bisection Method

 Identify the existence of a root


ab
 Compute c  and f(c)
2
 Determine if
 f (a)  f (c )  0 then r  (a, c)
 f (b)  f (c )  0 then r  (c, b)
 Repeat until desired iteration/accuracy

Example 6

Show that f ( x )  x 3 has a root in the interval [-1, 2]. Apply Bisection method
with 3 iterations to reduce the interval of the root.

Solution
 Identify the existence of a root
[-1, 2]  a = -1 and b=2

f (x)  x3  f ( 1)  1 f (2)  8


f (1)  f (2)  (1)(8)  8  0

ab
 Compute c 
2
 1 2
c  0 .5 and f (0.5)  0.125
2
 Determine
f (1)  f (0.5)  (1)(0.125)  0

f (0.5)  f (2)  (0.125)(8)  0

 Since f (1)  f (0.5)  0 then r  (1 , 0.5)

 Repeat until desired iterations/accuracy:

24
SOLVING NONLINEAR EQUATIONS Part 2

i xi f ( xi )  xi 3 [ai , bi ] ci
0 -1 -1.0000
1 2 8.0000 [-1, 2] 0.5
2 0.5 0.1250 [-1, 0.5] -0.25
3 -0.25 -0.0156 [-0.25, 0.5] 0.125

Example 7

Given h( x )  x 3  x  1 , show that one of the solutions of h( x )  0 lies


between -2 and 1. Obtain the approximation to 2 significant digits.

Solution

 Identify the existence of a root


[-2, 1]  a = -2 and b=1

h( x )  x 3  x  1  h(2)  5 h(1)  1
h(2)  f (1)  (5)(1)  5  0

ab
 Compute c 
2
 2 1
c  0.5 and h(0.5)  1.375
2
 Determine :
h(2)  f (0.5)  (5)(1.375)  0

h(0.5)  f (1)  (1.375)(1)  0


Hence, r  (2 ,  0.5) .
 Repeat until desired iteration/accuracy:

i xi h( x i )  x i 3  x i  1 [ai , bi ] ci
0 -2 -5.000
1 1 1.000 [-2, 1] -0.5
2 -0.5 1.375 [-2, -0.5] -1.250
3 -1.250 0.297 [-2, -1.25] -1.625
4 -1.625 -1.666 [-1.625, -1.25] -1.438
5 -1.438 -0.533 [-1.438, -1.25] -1.344
6 -1.344 -0.083 [-1.344, -1.25] -1.297

25
SOLVING NONLINEAR EQUATIONS Part 2

Thus, the root of h( x )  x 3  x  1 accurate to 2 significant digits (or 1 decimal


place) is r  1.3 .

Example 8

f ( x)  e x  x  2 has one real root. Estimate the root correct to 3 decimal


places.

Solution

 Identify the existence of a root


There exist a root in [0, 1]. (Refer Example 3)
ab
 Compute c  and f(c)
2
0 1
c  0.5 and f(0.5) = 0.1487
2
 Determine
f(0).f(0.5) < 0
f(0.5).f(1) > 0
Then r  (0,0.5)
 Repeat until desired iteration/accuracy
The estimated root correct to 3 decimal places is r = 0.443.

i xi f ( x)  e x  x  2 [ai , bi ] ci
0 0.0000 -1.0000
1 1.0000 1.7183 [0, 1] 0.5000
2 0.5000 0.1487 [0, 0.5] 0.2500
3 0.2500 -0.4660 [0.250, 0.5] 0.3750
4 0.3750 -0.1700 [0.375, 0.5] 0.4375
5 0.4375 -0.0137 [0.4375, 0.5000] 0.4688
6 0.4688 0.0667 [0.4375, 0.4688] 0.4531
7 0.4531 0.0263 [0.4375, 0.4531] 0.4453
8 0.4453 0.0063 [0.4375, 0.4453] 0.4414
9 0.4414 -0.0037 [0.4414, 0.4453] 0.4434
10 0.4434 0.0013 [0.4414, 0.4434] 0.4424
11 0.4424 -0.0012 [0.4424, 0.4434] 0.4429
12 0.4429 0.0000 [0.4424, 0.4429] 0.4426

26
SOLVING NONLINEAR EQUATIONS Part 2

Warm up exercise
Let f ( x )  x 3  x  1 in [1, 2].
(i) Identify the existence of a root.
ab
(ii) Compute c  and f(c).
2
(iii) Compute
(a) f(1).f(c)
(b) f(2).f(c)
(iv) Determine where the root lies.
(v) Find the root accurate to 2 significant digits.

2.5 Convergence of Bisection Method

Theorem
Let f  a, b and suppose f(a).f(b) < 0. The Bisection method generates a
sequence c approximating r such that
E  cr
ba

2n
If an error tolerance has been prescribed in advance, it is possible to determine
the number of iterations required in the Bisection method. Suppose it is required
that r - cn  E . Then it is necessary to solve the following inequality for n.

27
SOLVING NONLINEAR EQUATIONS Part 2

Steps : Convergence and number of iterations

 Identify the interval


 Identify the error
 Solve for n
ba
 E
2n

Example 9
Determine approximately how many iterations are necessary to solve
f(x)  x 3  4x 2 - 10 with 10-5 accuracy where a  1 and b  2 .

Solution
 Identify the interval
[1, 2]  a  1 and b  2
 Identify the error
E  10 -5
 Solve for n
ba
E
2n
E  10 5
2 1
n
 10  5
2
1
2n  5
10
2  10 5
n

n log 2  log10 5
5
n
log 2
 16.61

Hence, at least 17 iterations are needed to obtain 10-5 accuracy.


(Note: to ensure desired accuracy is achieved, round-off the number of
iterations to a larger integer).

28
SOLVING NONLINEAR EQUATIONS Part 2

Example 10
Find a maximum bound for the number of iterations needed to achieve an
approximation with 10-4 accuracy to the solution x 3 - x - 1  0 , lying on
the interval [1, 2].

Solution
e  10 4
2 1
 10  4
2n
2 n  10 4
n log 2  log10 4
n log 2  4
4
n
log 2
 13.29
Hence, at least 14 iterations are required to achieve the desired accuracy.

Note that the accuracy of Bisection method is only dependent on its interval
and not the function.

Warm up exercise
Approximate the root of f ( x )  x 3  x  1 in [1, 2] accurate to 2 decimal
places.
(i) Identify the interval which contains the root.
(ii) Calculate the error using the error formula of the Bisection method.
(iii) Determine the required iterations.

29
SOLVING NONLINEAR EQUATIONS Part 2

Exercise 2

1. Given x 3  6x  16  0 .
a) show that there exists one real root in the interval (1, 2)
b) plot the graph and hence show and estimate the root.

2. Apply the Bisection method to the equation sin x  0.75  0 in the interval
[0.8, 0.9] and try to determine the root with three correct decimals.

3. Using the Bisection method determine the first four approximations of the actual
1
root of the equation x 3   0 in the interval [0, 1].
2

4. By the method of Bisection determine the first three approximations of the


following equations:
a) sin x  x 3  1  0 ; [-2, 0]
b) x  ln x  3  0 ; [4, 5]
  
c) f ( x )  cos x  cos 3x ;  2 , 2
 
d) 2 x  tan x ; [0, 3]

5. Show that x 3  x  2  0 has a root between 1 and 2. Use the Bisection method
to approximate the root accurate to two decimal places.

6. Using the Bisection method, solve x  ln x  3 , given that the root is close to 2.
Obtain the root correct to two decimal places.

7. Use the Bisection method to approximate the zero of f ( x )  1  x  x 2 in [0, 1].


Give your answers accurate to 2 significant digits.

8. Solve 2 cos x  e x with accuracy 104 using the Bisection method.

30

You might also like