• No results found

The bisection method

Solving equations by iterative methods 9.1 Introduction to iterative methods

9.2 The bisection method

As shown above, by using functional notation it is possible to determine the vicinity of a root of an equation by the occurrence of a change of sign, i.e. if x1 and x2 are such that f (x1) and f (x2) have opposite signs, there is at least one root of the equation f (x)=0 in the interval between x1 and x2 (provided f (x) is a continuous function). In the method of bisection the mid-point of the inter- val, i.e. x3=

x1+x2

2 , is taken, and from the sign of f (x3) it can be deduced whether a root lies in the half interval to the left or right of x3. Whichever half interval is indicated, its mid-point is then taken and the procedure repeated. The method often requires many iterations and is therefore slow, but never fails to eventually produce the root. The procedure stops when two successive value of x are equal—to the required degree of accuracy.

The method of bisection is demonstrated in Prob- lems 1 to 3 following.

Problem 1. Use the method of bisection to find the positive root of the equation

5x2+11x−17=0 correct to 3 significant figures.

Let f (x)=5x2+11x−17

then, using functional notation: f (0)= −17

f (1)=5(1)2+11(1)−17=−1

f (2)=5(2)2+11(2)−17=+25

Since there is a change of sign from negative to positive there must be a root of the equation between x=1 and x=2. This is shown graphically in Fig. 9.2.

A

−3 −2 −1 1 2 20 f (x) f (x)=5x2+11x−17 10 −10 −17 −20 0 Figure 9.2

The method of bisection suggests that the root is at 1+2

2 =1.5, i.e. the interval between 1 and 2 has been bisected.

Hence

f (1.5)=5(1.5)2+11(1.5)−17 =+10.75

Since f (1) is negative, f (1.5) is positive, and f (2) is also positive, a root of the equation must lie between x=1 and x=1.5, since a sign change has occurred between f (1) and f (1.5).

Bisecting this interval gives1+1.5

2 i.e. 1.25 as the next root.

Hence

f (1.25)=5(1.25)2+11x−17 =+4.5625

Since f (1) is negative and f (1.25) is positive, a root lies between x=1 and x=1.25.

Bisecting this interval gives1+1.25

2 i.e. 1.125 Hence

f (1.125)=5(1.125)2+11(1.125)−17 =+1.703125

Since f (1) is negative and f (1.125) is positive, a root lies between x=1 and x=1.125.

Bisecting this interval gives1+1.125

2 i.e. 1.0625.

Hence

f (1.0625)=5(1.0625)2+11(1.0625)−17 =+0.33203125

Since f (1) is negative and f (1.0625) is positive, a root lies between x=1 and x=1.0625.

Bisecting this interval gives 1+1.0625

2 i.e.

1.03125. Hence

f (1.03125)=5(1.03125)2+11(1.03125)−17 =−0.338867. . .

Since f (1.03125) is negative and f (1.0625) is posi- tive, a root lies between x=1.03125 and x=1.0625. Bisecting this interval gives

1.03125+1.0625

2 i.e. 1.046875 Hence

f (1.046875)=5(1.046875)2+11(1.046875)−17 =−0.0046386. . .

Since f (1.046875) is negative and f (1.0625) is positive, a root lies between x=1.046875 and x=1.0625.

Bisecting this interval gives 1.046875+1.0625

2 i.e. 1.0546875

The last three values obtained for the root are 1.03125, 1.046875 and 1.0546875. The last two val- ues are both 1.05, correct to 3 significant figure. We therefore stop the iterations here.

Thus, correct to 3 significant figures, the positive root of 5x2+11x−17=0 is 1.05

Problem 2. Use the bisection method to deter- mine the positive root of the equation x+3=ex, correct to 3 decimal places.

Let f (x)=x+3−ex

then, using functional notation:

f (0)=0+3−e0=+2

f (1)=1+3−e1=+1.2817. . .

Since f (1) is positive and f (2) is negative, a root lies between x=1 and x=2. A sketch of f (x) = x+3−ex, i.e. x+3=ex is shown in Fig. 9.3.

f (x) 4 −2 f (x) = ex f (x) = x+3 3 2 0 1 −1 1 2 x Figure 9.3

Bisecting the interval between x=1 and x=2 gives 1+2

2 i.e. 1.5. Hence

f (1.5)=1.5+3−e1.5 =+0.01831. . .

Since f (1.5) is positive and f (2) is negative, a root lies between x=1.5 and x=2.

Bisecting this interval gives 1.5+2

2 i.e. 1.75. Hence

f (1.75)=1.75+3−e1.75 =−1.00460. . .

Since f (1.75) is negative and f (1.5) is positive, a root lies between x=1.75 and x=1.5.

Bisecting this interval gives 1.75+1.5

2 i.e. 1.625. Hence

f (1.625)=1.625+3−e1.625 =−0.45341. . .

Since f (1.625) is negative and f (1.5) is positive, a root lies between x=1.625 and x=1.5.

Bisecting this interval gives1.625+1.5

2 i.e. 1.5625.

Hence

f (1.5625)=1.5625+3−e1.5625 =−0.20823. . .

Since f (1.5625) is negative and f (1.5) is positive, a root lies between x=1.5625 and x=1.5.

Bisecting this interval gives 1.5625+1.5

2 i.e.1.53125 Hence

f (1.53125)=1.53125+3−e1.53125 =−0.09270. . .

Since f (1.53125) is negative and f (1.5) is positive, a root lies between x=1.53125 and x=1.5. Bisecting this interval gives

1.53125+1.5

2 i.e. 1.515625 Hence

f (1.515625)=1.515625+3−e1.515625 =−0.03664. . .

Since f (1.515625) is negative and f (1.5) is positive, a root lies between x=1.515625 and x=1.5. Bisecting this interval gives

1.515625+1.5

2 i.e. 1.5078125 Hence

f (1.5078125)=1.5078125+3−e1.5078125 =−0.009026. . .

Since f (1.5078125) is negative and f (1.5) is positive, a root lies between x=1.5078125 and x=1.5. Bisecting this interval gives

1.5078125+1.5

2 i.e.1.50390625 Hence

f (1.50390625)=1.50390625+3−e1.50390625 =+0.004676. . .

Since f (1.50390625) is positive and f (1.5078125) is negative, a root lies between x=1.50390625 and x=1.5078125.

A

Bisecting this interval gives 1.50390625+1.5078125

2 i.e.1.505859375 Hence

f (1.505859375)=1.505859375+3−e1.505859375 =−0.0021666. . .

Since f (1.50589375) is negative and f (1.50390625) is positive, a root lies between x=1.50589375 and x=1.50390625.

Bisecting this interval gives 1.505859375+1.50390625

2 i.e.1.504882813 Hence

f (1.504882813)=1.504882813+3−e1.504882813 =+0.001256. . .

Since f (1.504882813) is positive and f (1.505859375) is negative,

a root lies between x=1.504882813 and x= 1.505859375.

Bisecting this interval gives 1.504882813+1.50589375

2 i.e.1.505388282 The last two values of x are 1.504882813 and 1.505388282, i.e. both are equal to 1.505, correct to 3 decimal places.

Hence the root of x+3=exis x= 1.505, correct to 3 decimal places.

The above is a lengthy procedure and it is proba- bly easier to present the data in a table as shown in the table.

Problem 3. Solve, correct to 2 decimal places, the equation 2 ln x+x=2 using the method of bisection.

Let f (x)=2 ln x+x−2

f (0.1) =2 ln (0.1)+0.1−2= −6.5051. . .

(Note that ln 0 is infinite that is why x=0 was not chosen)

x1 x2 x3= x1+x2 2 f (x3) 0 +2 1 +1.2817. . . 2 −2.3890. . . 1 2 1.5 +0.0183. . . 1.5 2 1.75 −1.0046. . . 1.5 1.75 1.625 −0.4534. . . 1.5 1.625 1.5625 −0.2082. . . 1.5 1.5625 1.53125 −0.0927. . . 1.5 1.53125 1.515625 −0.0366. . . 1.5 1.515625 1.5078125 −0.0090. . . 1.5 1.5078125 1.50390625 +0.0046. . . 1.50390625 1.5078125 1.505859375 −0.0021. . . 1.50390625 1.505859375 1.504882813 +0.0012. . . 1.504882813 1.505859375 1.505388282 f (1)=2 ln 1+1−2= −1 f (2)=2 ln 2+2−2= +1.3862. . .

A change of sign indicates a root lies between x=1 and x=2.

Since 2 ln x+x=2 then 2 ln x= −x+2; sketches of 2 ln x andx+2 are shown in Fig. 9.4.

f (x) 2 1 2 x −2 f (x) = −x+2 f (x) = 2 ln x 0 Figure 9.4

As shown in Problem 2, a table of values is produced to reduce space.

x1 x2 x3= x1+x2 2 f (x3) 0.1 −6.6051. . . 1 −1 2 +1.3862. . . 1 2 1.5 +0.3109. . . 1 1.5 1.25 −0.3037. . . 1.25 1.5 1.375 +0.0119. . . 1.25 1.375 1.3125 −0.1436. . . 1.3125 1.375 1.34375 −0.0653. . . 1.34375 1.375 1.359375 −0.0265. . . 1.359375 1.375 1.3671875 −0.0073. . . 1.3671875 1.375 1.37109375 +0.0023. . .

The last two values of x3are both equal to 1.37 when expressed to 2 decimal places. We therefore stop the iterations.

Hence, the solution of 2 ln x+x=2 is x=1.37, correct to 2 decimal places.

Now try the following exercise.

Exercise 39 Further problems on the