0% found this document useful (0 votes)
169 views24 pages

Numerical Methods: King Saud University

I. The document discusses numerical methods for finding roots of nonlinear equations. II. It introduces the bisection method, which uses interval bisection to bracket and converge on a root. The method works if the function is continuous on the interval and its values at the endpoints have opposite signs. III. An example applies the bisection method to find the root of x3 = 2x + 1 that lies between 1.5 and 2.0 to within 0.01 accuracy, obtaining the approximation 1.617188 after 6 iterations.

Uploaded by

MalikAlrahabi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views24 pages

Numerical Methods: King Saud University

I. The document discusses numerical methods for finding roots of nonlinear equations. II. It introduces the bisection method, which uses interval bisection to bracket and converge on a root. The method works if the function is continuous on the interval and its values at the endpoints have opposite signs. III. An example applies the bisection method to find the root of x3 = 2x + 1 that lies between 1.5 and 2.0 to within 0.01 accuracy, obtaining the approximation 1.617188 after 6 iterations.

Uploaded by

MalikAlrahabi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Numerical Methods

King Saud University


Aims

In this lecture, we will . . .


I Considering how to numerically find roots of algebraic equations
I Introduce the Bisection method
Nonlinear Equations

We will considere any one of the following types:


1. A polynomial equation of degree n:

an xn + an−1 xn−1 + · · · + a1 x + a0 = 0, an 6= 0, n > 1,

where an , an−1 , . . . , a1 and a0 are constants. For example, the following


equations are nonlinear.

x2 + 5x + 6 = 0; x3 = 2x + 1; x200 − 2x + 1 = 0.

2. The power of the unknown variable (not a positive integer number). For
example, the following non-polynomial equations are nonlinear
√ 2
x−1 + 2x = 1; x + x = 2; x2/3 + + 4 = 0.
x
3. The equation which involves the trigonometric functions, exponential
functions and logarithmic functions. For example, all the following
transcendental equations are nonlinear

x = cos(x); ex + x − 10 = 0; x + ln x = 10.
Roots of nonlinear equations

One of the most basic problems that numerical techniques are used for is finding
roots of nonlinear equations. This process involves finding a root, or solution, of
an equation of the form
f (x) = 0. (1)
A root of this equation is also called a zero of the function f . Here, we are going
to look at some common numerical methods for finding roots of equations.
Important Points

I. Nonlinear equations may have many roots but we will seek the approximation
of only one of its real root α lies in the given interval [a, b], that is

f (α) = 0, where α ∈ [a, b].

II. If f (x) is continuous function in in a interval [a, b] and f (x) has opposite signs
at the end points of the interval, then there must be a root of nonlinear equation
f (x) = 0 in [a, b].
III. Root of a nonlinear equation may be simple (not repeating) or multiple
(repeating). Simple root means

f (α) = 0 but f 0 (α) 6= 0.

For example, α1 = −3 and α2 = −2 are the simple roots of the nonlinear equation
x2 + 5x + 6 = 0. For the multiple root, we mean

f (α) = 0 but f 0 (α) = 0.

For example, α1 = −2 and α2 = −2 are the multiple roots of the nonlinear


equation x2 + 4x + 4 = 0.
IV. We will consider iterative methods which include bisection method,
fixed-point method, Newton method (also called, Newton-Raphson method) and
secant method which give us the approximation of single (or simple) root of the
nonlinear equation. For the multiple roots of the nonlinear equation we will use
other iterative methods, called, the first modified Newton’s method (also called
the Schroeder’s method) and the second modified Newton’s method.

V. Remember that the best method for the approximation of the simple root of
nonlinear equation is Newton’s method (called quadratic convergent method) and
for multiple root of nonlinear equation is modified Newton’s method (called
quadratic convergent method). Newton’s method for multiple root of nonlinear
root is called a linear convergent method.
The Bisection Method
The Bisection method is used to determine, to any specified accuracy that your
computer will permit, a solution to f (x) = 0 on an interval [a, b], provided:
I f (x) is continuous on [a, b];

I f (a) and f (b) are of opposite sign.

The concept of the Bisection method is simple, and is based on utilizing the
Intermediate Value Theorem. Essentially, due the continuity of f on [a, b], and
since f (a)f (b) < 0, then there must be a point a < α < b such that f (α) = 0. The
implication is that one of the values is negative and the other is positive. These
conditions can be easily satisfied by sketching the function, see Figure 1.

y=f(x)

a c c
1 2 3
0
c b1
1

Figure: Graphical Solution of Bisection Method.


Therefore the root must lies between a and b (by Intermediate Value Theorem)
and a new approximation to the root α be calculated as

a+b
c= ,
2
and, in general
an + bn
cn = , n ≥ 1. (2)
2
The iterative formula (2) is known as the bisection method.
If f (c) ≈ 0, then c ≈ α is the desired root, and, if not, then there are two
possibilities.
I Firstly, if f (a)f (c) < 0, then f (x) has a zero between point a and point c.
The process can then be repeated on the new interval [a, c].
I Secondly, if f (a)f (c) > 0 it follows that f (b)f (c) < 0 since it is known that
f (b) and f (c) have opposite signs. Hence, f (x) has zero between point c and
point b and the process can be repeated with [c, b]. We see that after one step
of the process, we have found either a zero or a new bracketing interval which
is precisely half the length of the original one.
I The process continue until the desired accuracy is achieved.
Example 0.1
Use the bisection method to find the approximation to the root of the equation

x3 = 2x + 1,

that is located in the interval [1.5, 2.0] accurate to within 10−2 .


Solution. Since the given function f (x) = x3 − 2x − 1 is a polynomial function
and so is continuous on [1.5, 2.0], starting with a1 = 1.5 and b1 = 2, we compute:

a1 = 1.5 : f (a1 ) = −0.625


b1 = 2.0 : f (b1 ) = 3.0,

and since f (1.5)f (2.0) < 0, so that a root of f (x) = 0 lies in the interval [1.5, 2.0].
Using formula (2) (when n = 1), we get:

a1 + b1
c1 = = 1.75; f (c1 ) = 0.859375.
2
Hence the function changes sign on [a1 , c1 ] = [1.5, 1.75]. To continue, we squeeze
from right and set a2 = a1 and b2 = c1 . Then the midpoint is:

a2 + b2
c2 = = 1.625; f (c2 ) = 0.041056.
2
Continue in this way we obtain a sequence {ck } of approximation shown by
Table 1.
Table: Solution of x3 = 2x + 1 by bisection method

n Left Right Function Value


Endpoint an Midpoint cn Endpoint bn f (cn )
01 1.500000 1.750000 2.000000 0.8593750
02 1.500000 1.625000 1.750000 0.0410156
03 1.500000 1.562500 1.625000 -0.3103027
04 1.562500 1.593750 1.625000 -0.1393127
05 1.593750 1.609375 1.625000 -0.0503273
06 1.609375 1.617188 1.625000 -0.0049520
We see that the functional values are approaching zero as the number of iterations
is increase. We got the desired approximation to the root of the given equation is
c6 = 1.617188 ≈ α after 6 iterations with accuracy  = 10−2 . •
3 3

2 2.5

1
y(x) = x3 − 2x − 1 2

3
0 1.5 y(x) = x − 2x − 1
y
y

−1 1

−2 0.5

−3 0

−4 −0.5
root 1 root 2 root 3

−5 −1
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2

x x

Figure: Graphical Solution of x3 = 2x + 1 in the intervals [−2, 2] and [−1.5, 2].


Note that to use MATLAB command for the bisection method, first we define a
function m-file as fn.m for the equation as follows:
f unction y = f n(x)
y = x.ˆ 3 − 2 ∗ x − 1;
then use the single commands:

>> s = bisect(0 f n0 , 1.5, 2, 1e − 2)

We can easily find the roots (1.61803399, −1.00, −0.61803399) of the equation
x3 = 2x + 1 by defining the coefficients of the polynomial equation using
MATLAB commands as:

>> CP = [1 0 − 2 − 1]; Sol = roots(CP );


Example 0.2
Find the point of intersection of the graphs y = x3 + 2x − 1 and y = sin x, then
use bisection method within accuracy 10−3 .
Solution. The graphs in the Figure 3 show that there is an intersection at about
point (0.66, 0.61). Using the function f (x) = x3 + 2x − sin x − 1 and the starting
interval [0.5, 1.0], we compute:

a1 = 0.5 : f (a1 ) = −0.3544,


b1 = 1.0 : f (b1 ) = 1.1585.

Since f (x) is continuous on [0.5, 1.0] and f (0.5).f (1.0) < 0, so that a root of
f (x) = 0 lies in the interval [0.5, 1.0]. Using formula (2) (when n = 1), we get:

a1 + b1
c1 = = 0.75; f (c1 ) = 0.240236.
2
Hence the function changes sign on [a1 , c1 ] = [0.5, 0.75]. To continue, we squeeze
from right and set a2 = a1 and b2 = c1 . Then the midpoint is:

a2 + b2
c2 = = 0.625; f (c2 ) = −0.090957.
2
2 1.2

1.8
1

1.6
0.8
1.4 y = x3 + 2x − 1
y = x3 + 2x − sin x − 1
0.6
1.2

y
y

1 0.4

0.8
0.2

0.6
α
y = sin x
0
0.4

−0.2
0.2

0 −0.4
0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1
x x

Figure: Graphical Solution of sin x = x3 + 2x − 1 and x3 + 2x − sin x = 1.

Then continue in this manner we obtain a sequence {ck } of approximation shown


by Table 2.
Table: Solution of x3 + 2x − sin x − 1 by bisection method

n Left Right Function Value


Endpoint an Endpoint bn Midpoint cn f (cn )
01 0.5000 1.0000 0.750000 0.240236
02 0.5000 0.7500 0.625000 -0.090957
03 0.6250 0.7500 0.687500 0.065344
.. .. .. .. ..
. . . . .
07 0.6563 0.6641 0.660156 -0.005228
08 0.6602 0.6641 0.662109 -0.000302

We see that the functional values are approaching zero as the number of iterations
is increase. We got the desired approximation to the root of the given equation is
c8 = 0.662109 ≈ α after 8 iterations with accuracy  = 10−3 . •
Program 2.1
MATLAB m-file for the Bisection Method
function sol=bisect(fn,a,b,tol)
f a = f eval(f n, a); f b = f eval(f n, b);
if f a ∗ f b > 0; fprintf(’Endpoints have same sign’) return end
while abs (b − a) > tol c = (a + b)/2; f c = f eval(f n, c);
if f a ∗ f c < 0; b = c; else a = c; end; end; sol=(a + b)/2;
Theorem 1
(Bisection Convergence and Error Theorem)
Let f (x) be continuous function defined on the given initial interval
[a0 , b0 ] = [a, b] and suppose that f (a)f (b) < 0. Then bisection method (2)
generates a sequence {cn }∞ n=1 approximating α ∈ (a, b) with the property

b−a
|α − cn | ≤ , n ≥ 1. (3)
2n
Moreover, to obtain accuracy of

|α − cn | ≤ ,

(for  = 10−k ) it suffices to take

ln 10k (b − a)

n≥ , (4)
ln 2
where k is nonnegative integer.

Note:
The above Theorem 1 gives us information about bounds for errors in
approximation and the number of bisections needed to obtain any given accuracy.
Example 0.3
Show that number of iterations of bisection will require to attain an accuracy of
10−4 using the starting interval [a, b] is

ln(b − a) + 4 ln 5
n≥ + 4.
ln 2
Determine the number of iterations needed to achieve the an approximation with
same above given accuracy to the solution of x3 − 2x − 1 = 0 lying in the interval
[1.5, 2].
Solution. By using the inequality (4), we get

ln 10k (b − a)

ln(b − a) + ln[(5)(2)]4
n≥ = ,
ln 2 ln 2
or
ln(b − a) + 4[ln 5 + ln 2] ln(b − a) + 4 ln 5
n≥ = + 4.
ln 2 ln 2
Now by taking a = 1.5 and b = 2 in the above inequality, we get

ln(2 − 1.5) + 4 ln 5
n≥ + 4 = 8.2877 + 4 = 12.2877.
ln 2
So no more than thirteen iterations are required to obtain an approximation
accurate to within the given accuracy 10−4 . •
Example 0.4
Find a bound for the number of iterations needed to achieve an approximation
with accuracy 10−1 to the solution of xex = 1 lying in the interval [0.5, 1] using the
bisection method. Find an approximation to the root with this degree of accuracy.
Solution. Here a = 0.5, b = 1 and k = 1, then by using inequality (4), we get

ln[101 (1 − 0.5)]
n≥ ≈ 2.3219.
ln 2
So no more than three iterations are required to obtain an approximation accurate
to within 10−1 .
The given function f (x) = xex − 1 is continuous on [0.5, 1.0], so starting with
a1 = 0.5 and b1 = 1, we compute:

a1 = 0.5 : f (a1 ) = −0.1756,


b1 = 1: f (b1 ) = 1.7183,

since f (0.5)f (1) < 0, so that a root of f (x) = 0 lies in the interval [0.5, 1]. Using
formula (2) (when n = 1), we get:

a1 + b1
c1 = = 0.75; f (c1 ) = 0.5878.
2
Hence the function changes sign on [a1 , c1 ] = [0.5, 0.75]. To continue, we squeeze
from right and set a2 = a1 and b2 = c1 . Then the bisection formula gives
a2 + b2
c2 = = 0.625; f (c2 ) = 0.1677.
2
Finally, we have in the similar manner as
a3 + b3
c3 = = 0.5625,
2
the value of the third approximation which is accurate to within 10−1 . •

1.5

1
y

0.5

α
0

−0.5

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

Figure: Graphical Solution of xex = 1.


Example 0.5 √
4
Use the bisection method to compute the first three approximate values for 18.
Also, compute an error bound and absolute error for your approximation.
Solution. Consider
√4
x = 18 = (18)1/4 , or x4 − 18 = 0.

Choose the interval [2, 2.5] on which the function f (x) = x4 − 18 is continuous and
the function f (x) satisfies the sign property, that is

f (2)f (2.5) = (−2)(21.0625) = −42.125 < 0.



4
Hence root α = 18 = 2.0598 ∈ [2, 2.5] and we compute its first approximate
value by using formula (2) (when n = 1) as follows:

2.0 + 2.5
c1 = = 2.2500 and f (2.25) = 7.6289.
2
Since the function f (x) changes sign on [2.0, 2.25]. To continue, we squeeze from
right and use formula (2) again to get the following second approximate value of
the root α as:
2.0 + 2.25
c2 = = 2.1250 and f (2.1250) = 2.3909.
2
Then continue in the similar way, the third approximate value of the root α is
c3 = 2.0625 with f (2.0625) = 0.0957.
Note that the value of the function at each new approximate value is decreasing
which shows that the approximate values are coming closer to the root α. Now to
compute the error bound for the approximation we use the formula (3) and get

2.5 − 2.0
|α − c3 | ≤ = 0.0625,
23
which is the possible maximum error in our approximation and

|E| = |2.0598 − 2.0625| = 0.0027,

be the absolute error in the approximation. •


Procedure
(Bisection Method)

1. Establish an interval a ≤ x ≤ b such that f (a) and f (b) are of opposite sign,
that is, f (a).f (b) < 0.
2. Choose an error tolerance ( > 0) value for the function.
3. Compute a new approximation for the root:
(an + bn )
cn = ; n = 1, 2, 3, . . . .
2
4. Check tolerance. If |f (cn )| ≤ , use cn , n ≥ 1 for desired root; otherwise
continue.
5. Check, if f (an )f (cn ) < 0, then set bn = cn ; otherwise set an = cn .
6. Go back to step 3, and repeat the process.
Summary

In this lecture, we ...


I Considered how to numerically find roots of algebraic equations
I Introduced the Bisection method.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy