Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Numerical Analysis (MATH-254)

Fall 2021
Lecture No. 4 (Root Location Methods for Nonlinear Equations: M-II.
Tabulation Method)

Focus

- Tabulation (or Trial and Error) Method for Location of Roots

- Some Common Notions of Numerical Analysis

M-II. Tabulation Method for Location of Roots of f (x) = 0

Theorem (Intermediate Value Theorem): If f ∈ C[a, b] and K is any


real number between f (a) and f (b), then there exists c (intermediate point)
in (a, b) for which f (c) = K.

Corollary: If the function f is continuous on the interval [a, b] and if f (a)


and f (b) have opposite signs, i.e. if

f (a) f (b) < 0,

then the equation f (x) = 0 has at least one solution in this interval.

Remark I: If f (a) and f (b) have same signs then nonlinear equation
f (x) = 0 has no real roots or has an even number of real roots.

Remark II: If the curve y = f (x) touches the x-axis at some point, say,
x = α, then α is a root of f (x) = 0 though f (a) and f (b) have same signs.
Such roots are called repeated roots.

1
Example 1: Given 8x3 −20x2 −2x+5 = 0. Locate the roots of this equation.

Solution:(a) By Graphical Method


3 2
Graph of f(x)=x -20x -2x+5
40

20 Graph of f(x)=8x 3, g(x)=20x 2+2x-5


150
Cubic
Quadratic

0
y=f(x)

100
-20

y=f(x), y=g(x)
-40
50

-60

0
-80
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5
x
x

(a) Graph of f (x) = 8x3 − 20x2 − 2x + 5 (b) Graph of f (x) = 8x3 and g(x) = 20x2 +
2x − 5

Figure 1: Ref: (Example 1) Location of Roots by Graphical and Tabulation


Method

Solution:(b) By Tabulation Method

x -2 -1 0 1 2 3 4
f (x) -135 -21 5 -9 -15 35 189
Sign - - + - - + +

The (exact) roots are 2.5, 0.5, and −0.5.

MATLAB Code: To plot the graphs of functions, use the plot command
in MATLAB as follows.

x = −1 : 0.01 : 0; plot(x, 6 ∗ x.2 + 5 ∗ x + 1), gridon, title(0 f(x) = 6x2 + 5x + 10 )

2
Example 2: Given 3x − 3x − 2 = 0. Locate the roots of this equation.

Solution:(a) By Graphical Method


x
Graph of f(x)=3 -3x-2
10

Graph of f(x)=3 x, g(x)=3x+2


10

5 Exponential
Linear
y=f(x)

y=f(x), y=g(x)
0

-5
-5
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5
x x

(a) Graph of f (x) = 3x − 3x − 2 (b) Graph of f (x) = 3x and g(x) = 3x + 2

Figure 2: Ref: (Example 2) Location of Roots by Graphical and Tabulation


Methods

Solution:(b) By Tabulation Method

x -1 0 1 2 3
f (x) 1.3333 -1 -2 1 16
Sign + - - + +

- Caution with use of Tabulation Method: It is important to be vigi-


lant when using Tabulation method for root location. Some times, roots of
a nonlinear equation may be located very close which may not be noticed if
one does not take test points close enough. For instance, see Figure ??.

- Some Important Notions of numerical Analysis: Before introducing


the numerical methods for finding the approximate solutions of the nonlinear
(system of) equations in one variable, it is pertinent to define some important
related notions.

- (a). Iterations Repetition of a certain procedure/steps of a numerical


method

- (b). Tolerance A small positive bound () on errors of approximation or

3
2
f(x)=6x +5x+1
2

2
f(x)=-12x +7x-1
1.5 0.2

1
-0.2

-0.4
0.5
-0.6

0 -0.8

-1

-0.5
-1.2
-1 -0.8 -0.6 -0.4 -0.2 0 0 0.1 0.2 0.3 0.4 0.5 0.6

(a) Graph of f (x) = 6x2 + 5x + 1 (b) Graph of f (x) = −12x2 + 7x − 1

Figure 3: Ref: (Caution) Location of Roots by Graphical and Tabulation


Methods

function values

- (c). Stopping Criterion Following are the commonly used stopping cri-
terion (depending on the tolerance) for stopping an iterative process.

(i) If the number of iterations N are fixed then we stop when the desired
number of iterations are done.

(ii) |pN − pN −1 | < , i.e., stop when the absolute difference/error between two
successive approximations/iterations, at the (N − 1)th (pN −1 ) and N th (pN )
iterations, of the desired root is less than the specified tolerance. The desired
root will be pN .

(iii) |pN |p
−pN −1 |
N|
< , pN 6= 0, i.e., stop when the relative difference between two
successive approximations is less than the specified tolerance. The desired
root will be pN .

(iv) |f (pN )| <  i.e., when the absolute value of the function at N th approxi-
mation/iteration is less than the specified tolerance. The desired root will be
pN .

Note: Without additional knowledge about f or p, inequality in (iii) is the


best stopping criterion to apply because it comes closest to testing relative
error.

4
Next Lecture: Root Finding Methods for Nonlinear Equations: M-I Bisec-
tion Method

5
Numerical Analysis (MATH-254)
Fall 2021
Lecture No. 5 (Root Finding Methods for Nonlinear Equations: M-I
Bisection Method)

Focus

- Root Finding Problem

- Bisection method: Procedure and Examples

Definition (Root Finding Problem): Assume that f (x) is a continuous


function. The problem of finding a number α for which f (α) = 0 is called
the root finding problem.

Procedure of Bisection Method: Given a nonlinear equation f (x) = 0


in one variable. The aim is to find an approximate root p∗ of this equation.

I. Locate the root(s) of the given NL equation (if required), i.e., find an in-
terval [a, b] such that f (a) and f (b) have opposite signs, i.e., f (a) f (b) < 0.

II. Decide/Specify a stopping criteria.

III. Perform the iterations of Bisection Method. Each iteration of the Bisec-
tion Method will consist of the following steps.

Step 1 (Labeling): (Re-)Label the end points of the interval.

Step 2: Take the mid-point c1 = a+b 2 of the interval as the first approximation
of the root, i.e., p1 = c1 . Find f (p1 ).

Step 3: If f (p1 ) = 0 is zero then p1 is an exact root of the equation. You


are lucky ... you have obtained the root. STOP! If f (p1 ) 6= 0, then check
the stopping criteria. If it is satisfied then STOP the iterative process. p1
is an approximation of the root as per specified accuracy or criteria. This
completes the FIRST iteration.

6
IV. If the stopping criteria is not fulfilled, then repeat the above 3 steps until
the stopping criteria is satisfied. This will produce a sequence p1 , p2 , p3 , · · · , pN , · · ·
of approximations of the root of f (x) = 0.

Q.1(B) Use √the Bisection method to find p3 (or simply perform 3 iterations)
for f (x) = x − cos x = 0 (on [0, 1]) working with 4 decimal place accuracy.

Related Exercises: Example 1, Qs. 1-2, (B)

Note The value of root correct to 4 decimal points using calculator (it also
uses some numerical algorithm) is 0.6417.

0.5

0.9

0 0.8

0.7

0.6

0.5

-0.5 0.4

0.3

0.2

0.1

-1 0
0 0.2 0.4 0.6 0.8 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
x

(a) Root Location as abcissa (b) Root Location as Point of Intersection

Figure 4: Ref: Q.1(B) Location of Roots by Graphical Method

Next Lecture: Error Bound Formula for Bisection Method, Solution of


some Selected Exercises, and MATLAB Demo

7
Numerical Analysis (MATH-254)
Fall 2021
Lecture No. 6 (Error Bound Formula for Bisection Method, Solution of
some Selected Exercises, and MATLAB Demo)

Focus

- Error Bound Formula

- Computing the number of iterations required for desired accuracy

Theorem 2.1 (Error Bound)/B Suppose that f ∈ C[a, b] and f (a)f (b) <
0. The Bisection method generates a sequence {pN }∞ N =1 for approximating a

zero p of f with
b−a
|pN − p∗ | ≤ N , N ≥ 1.
2
The above formula gives a bound for approximation error, i.e., at each itera-
tion N , the error |pN − p∗ | can’t exceed b−a
2N . However, this bound might be
quite conservative, i.e., the actual error at the N th iteration may be signifi-
cantly smaller than the EB.

Remark: Note that as N → ∞, the error |pN − p∗ | → 0, i.e., sequence


of approximations obtained from Bisection Method always converges to the
root of the equation.

Related Exercises: Examples 1-2, Qs. 3-17 (B), Examples 2.1-2.6, Qs. 1-4
(R)

Q. 6d(B) Show that the equation x + 1 − 2 sin πx = 0 has only one sim-
ple root in the interval [0.5, 1]. Determine how many iterations of Bisection
method will be required to find an approximate root accurate to within 10−5 .
Hence, find p3 .

Example
√ 2.6(R) Find a nonlinear equation which has one simple positive
4
root 18. Use bisection method to compute the second approximation to the
positive root using a = 2 and b = 2.5. Compute an error bound and absolute
error for the approximations. Find also the bound for |p12 − p∗ |. Use 4 d.p.

8
5

4
4
3
3
2

1 2

0
1

-1
0
-2
-1
-3

-4 -2

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

(a) Root Location as abcissa (b) Root Location as Point of Intersection

Figure 5: Location of Roots by Graphical Method in Q.6(d)

accuracy in all computations.

Note: The value of the fourth root of 18 using calculator (it also uses some
numerical algorithm) is 2.059767 (correct to 7 digits).

4
f(x)=x -18
25

f(x)=x 4-18
20 40
4
f(x)=x
g(x)=18

15 35

10 30

5 25

0 20

-5 15
2 2.1 2.2 2.3 2.4 2.5 2 2.1 2.2 2.3 2.4 2.5

(a) Root Location as abcissa (b) Root Location as Point of Intersection

Figure 6: Location of Roots by Graphical Method in Exp. 2.6

Advantages of Bisection Method

- The Bisection method is conceptually clear and simple to code.

- It has the important property that it always converges to a solution, and


for that reason it is often used as a starter for the more efficient methods.

9
Drawbacks of Bisection Method

- There are sequences with the property that the differences pN − pN −1 con-
verge to zero while the sequence {pN }∞
N =1 itself diverges. (See Exercise 17 of
Burden and Faires)

- It is also possible for f (pN ) to be close to zero while pN differs significantly


from p∗ . (See Exercise 16 of Burden and Faires)

- It is relatively slow to converge (that is, N may become quite large before
|p∗ − pN | is sufficiently small)

- A good intermediate approximation might be inadvertently discarded. (See


Example 1 of Burden and Faires)

Next Lecture: Root Finding Methods for Nonlinear Equations: M-II Fixed-
Point Method
∗∗
Last updated on September10, 2021

10

You might also like