0% found this document useful (0 votes)
77 views7 pages

Numerical Solution of Equations of A Single Variable

Uploaded by

alla guermiti
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)
77 views7 pages

Numerical Solution of Equations of A Single Variable

Uploaded by

alla guermiti
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/ 7

CHAPTER I

Numerical Solution of Equations of a Single Variable


This chapter focuses on numerical solution of equations of a single variable, which
appear in the general form:

( )

Graphically, a solution (or root) of f(x) = 0 refers to the point of intersection of f(x)
and the x-axis. Therefore, depending on the nature of the graph of f(x) in relation to the
x-axis, the equation above may have a unique solution, multiple solutions, or no
solution.

A root of an equation can sometimes be determined analytically resulting in an exact


solution in closed form:

 For instance, the equation e3x − 2 = 0 can be solved analytically to obtain a


unique equation .
 In most situations, however, this is not possible and the root(s) must be found
numerically.

Numerical methods for solving an equation are divided into two main categories:

1.1 Bracketing methods:


1.1.1 Bisection Method:

It is assumed that f(x) is continuous on an interval [a, b] and has a root there so that
f(a) and f(b) have opposite signs, hence f(a)f(b) < 0.

Fig.1. Approximate solution of 2 − x + cos x = 0.

The procedure goes as follows:

 Locate the midpoint of [a, b], that is, . If f(a) and f(c1) have opposite
signs, the interval [a, c1] contains the root and will be retained for further
analysis; that is, the left end is retained while the right end is adjusted. If f(b) and
f(c1) have opposite signs, we continue with [c1, b]; that is, the right end is kept
while the left end is adjusted.
 The process is repeated until the length of the most recent interval [a, b] satisfies
the desired accuracy.
 The initial interval [a, b] has length (b – a). Beyond that, the first generated
interval has length ( ) , the next interval ( ), and so on. Thus, the
nth interval constructed in this manner has length (b − a)/2n− 1, and because it
brackets the root, the absolute error associated with the nth iteration satisfies:
| | (b>a)
 it can be shown that the number N of iterations needed to meet the tolerance
condition satisfies:
( ) ( )

Fig.2. Method of bracketing methods.

 Example1: Use bisection method to find the root of f(x) = x3 − 10x2 + 5 = 0 that
lies in the interval (0.6, 0.8).

 Solution: f(x) is continuous in the interval [0.6, 0.8] and f(0.6)xf(0.8)=-1.4350<0.


a b f(a) f( ) f(b)

0.6 0.8 0.7 1.6160 0.4430 -0.8880


0.7 0.8 0.75 0.4430 -0.2031 -0.8880
0.7 0.75 0.725 0.4430 0.1248 -0.2031
0.725 0.75 0.7375 0.1248 -0.0379 -0.2031
0.725 0.7375 0.7312 0.1248 0.0438 -0.0379
0.7312 0.7375 0.7344 0.0444 0.0033 -0.0379
0.7344 0.7375 0.7360 0.0027 -0.0176 -0.0379
0.7344 0.7360 0.7352 0.0027 -0.0078 -0.0183
0.7344 0.7352 0.7348 0.0027 -0.0026 -0.0078
0.7344 0.7348 0.7346 0.0027 4.5858e- -0.0026
005
0.7346 0.7348 0.7347 4.5858e- -0.0013 -0.0026
005
 Example2: Use bisection method to find the root of f(x) = x3 − 10x2 + 5 = 0 that
lies in the interval (0.6, 0.8) with MATLAB.
 Solution:
clc;clear all;close all
a=0.6;
b=0.8;
f=@(x)(x^3-10*x^2+5);
for i=1:100
c=(a+b)/2;
if f(a)*f(c)<0
b=c;
else
a=c;
end
if abs(f(a))<1.0e-4
break
end
end
fprintf(' The root is: %6.4f\n ',a)
fprintf('The number of iterations is: %d\n',i)

1.2 Open methods:


1.2.1 Newton–Raphson Method:

Newton’s method is the most commonly used open method to solve f(x) = 0, where f’
is continuous.
Consider the graph of f(x) in Fig.3.
 Start with an initial point x1 and locate the point (x1, f(x1)) on the curve.
 Draw the tangent line to the curve at that point, and let its x-intercept be x2. The
equation of this tangent line is:
( ) ( )( )
 Therefore, its x-intercept is found by setting y = 0 and solving for x:
( )
( )

 Once x2 is available, locate the point (x2, f(x2)), draw the tangent line to the curve
at that point, and let x3 be its x-intercept, which is found as:
( )
( )

 Continue this process until the sequence {xn} converges to the intended root r.
Fig.3. Geometry of Newton’s method.

 Example3: Use the Newton’s method to find a root of the polynomial equation
f(x). For the initial point use x1=0.7:

f(x) = x3 − 10x2 +5.

 Solution:
The derivative of the function is : ( ) , so that:
x f(x) f’(x) ( )
( )

x1 0.7 0.4430 -12.5300 0.7354


x2 0.7354 -0.0104 -13.0856 0.7346
x3 0.7346 4.5858e-005 -13.0731 0.7346

 Example4: Use the Newton’s method to find a root of the polynomial equation
f(x) with MATLAB. For the initial point use x1=0.7:

f(x) = x3 − 10x2 +5.

 Solution:

clc;clear all;close all


x1=0.7;
f=@(x)(x^3-10*x^2+5);
df=@(x)(3*x^2-20*x);
x=x1;
for i=1:100
y=x;
x=y-(f(x)/df(x));
if x-y<1.0e-4
break
end
end
fprintf(' The root is: %6.4f\n ',x)
fprintf('The number of iterations is: %d\n',i)
1.3 MATLAB Built-In Functions:
 The fzero function finds the roots of f(x) = 0 for a real function f(x).

>> f=@(x)(x^3-10*x^2+5);
>> fzero(f,[0.6,0.8])
 roots(C) computes the roots of the polynomial whose coefficients are the
elements of the vector C.
>> C=[1,-10,0,5];
>> x=roots(C)
 solve seeks zeros of the expressions or solutions of the equations.
>> x=solve('x^3-10*x^2+5=0');
>> double(x)
Bibliography
[1] Ramin S Esfandiari. Numerical methods for engineers and scientists using
MATLAB
®. Crc Press, 2017.
[2] Kiusalaas Jaan. Numerical methods in engineering with matlab, 2009.
[3] Tao Pang. An introduction to computational physics, 1999.
[4] Chris Woodford and Chris Phillips. Numerical methods with worked examples:
Matlab edition. Springer Science & Business Media, 2011.

You might also like