0% found this document useful (0 votes)
41 views18 pages

Roots-Numerical Methods-Part 2

The document describes the bisection method for finding the root of a function. It explains that the bisection method works by repeatedly dividing the interval in which the root lies in half, and evaluating the function at the midpoint. If the function changes sign, the subinterval containing the sign change becomes the new interval. It provides an example of using the bisection method to find the root of a function between 50 and 200. The root is calculated iteratively with decreasing error estimates until it is known with the required precision.

Uploaded by

Mohamed Osama
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)
41 views18 pages

Roots-Numerical Methods-Part 2

The document describes the bisection method for finding the root of a function. It explains that the bisection method works by repeatedly dividing the interval in which the root lies in half, and evaluating the function at the midpoint. If the function changes sign, the subinterval containing the sign change becomes the new interval. It provides an example of using the bisection method to find the root of a function between 50 and 200. The root is calculated iteratively with decreasing error estimates until it is known with the required precision.

Uploaded by

Mohamed Osama
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/ 18

Mechatronics Engineering

MTE203- Numerical Methods


Level:200

ROOT: BISECTION METHOD


•The bisection method is a variation of the
incremental search method in which the interval is
always divided in half.

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

•If a function changes sign over an interval, the function value at the
midpoint is evaluated.
•The location of the root is then determined as lying within the
subinterval where the sign change occurs.
•The subinterval then becomes the interval for the next iteration.
•The process is repeated until the root is known to the required precision.

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

EXAMPLE 3: The Bisection


Method
Problem Statement:
Use bisection to solve the same
problem approached graphically in
Example 1.

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

Solution.
The first step in bisection is to guess two values of the
unknown (in the present problem, m) that give values for f(m)
with different signs.
From the graphical solution in Example 1, we can see that
the function changes sign between values of 50 and 200
Therefore, the initial estimate of the root xr lies at the
midpoint of the interval

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

125

Note that:
 The exact value of the root is 142.7376.
 This means that the value of 125 calculated here
has a true percent relative error of

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

 Next we compute the product of the function value


at the lower bound and at the midpoint:

125

which is greater than zero, and hence no sign change


occurs between the lower bound and the midpoint.
Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

Consequently, the root must be located in the upper interval


between 125 and 200.
Therefore, we create a new interval by redefining the lower
bound as 125.

125

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

 At this point, the new interval extends from xl = 125


to xu = 200. A revised root estimate can then be
calculated as

162.5

The root is now in the lower interval between 125


and 162.5.
Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

The upper bound is redefined as 162.5, and the root estimate


for the third iteration is calculated as

143.75

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

which represents a percent relative error of εt =


0.709%. The method can be repeated until the result is
accurate enough to satisfy your needs.

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

we require an error estimate that is not contingent


on foreknowledge of the root. One way to do this is
by estimating an approximate percent relative error
as in

(x rnew) is the root for the present iteration.


(x rold) is the root from the previous iteration.
Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

EXAMPLE 4: Error Estimates for Bisection


Problem Statement.
Continue Example 3 until the approximate error
falls below a stopping criterion of εs = 0.5%. Use
Equation above to compute the errors.
Solution.
The results of the first two iterations for Example 3
were 125 and 162.5. Substituting these values into
Equation above yields

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

Recall that the true percent relative error for the root
estimate of 162.5 was 13.85%. Therefore, |εa| is
greater than |εt|. This behavior is manifested for the
other iterations:

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

MATLAB M-file: bisect


function [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,varargin)
% bisect: root location zeroes
% [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,p1,p2,...):
% uses bisection method to find the root of func
% input:
% func = name of function
% xl, xu = lower and upper guesses
% es = desired relative error (default = 0.0001%)
% maxit = maximum allowable iterations (default = 50)
% p1,p2,... = additional parameters used by func
% output:
% root = real root
% fx = function value at root
% ea = approximate relative error (%)
% iter = number of iterations

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

MATLAB M-file: bisect


if nargin<3,error('at least 3 input arguments required'),end
test = func(xl,varargin{:})*func(xu,varargin{:});
if test>0,error('no sign change'),end
if nargin<4|isempty(es), es=0.0001;end
if nargin<5|isempty(maxit), maxit=50;end
iter = 0; xr = xl; ea = 100;
while (1)
xrold = xr;
xr = (xl + xu)/2;
iter = iter + 1;
if xr ~ = 0,ea = abs((xr − xrold)/xr) * 100;end
test = func(xl,varargin{:})*func(xr,varargin{:});

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

MATLAB M-file: bisect

if test < 0
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
if ea <= es | iter >= maxit,break,end
end
root = xr; fx = func(xr, varargin{:});

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

 Determine the mass at which a bungee jumper’s


free-fall velocity exceeds 36 m/s after 4 s of free fall
given a drag coefficient of 0.25 kg/m. Thus, you have
to find the root of

Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.
Mechatronics Engineering
MTE203- Numerical Methods
Level:200

fm = @(m,cd,t,v) sqrt(9.81*m/cd)*tanh(sqrt(9.81*cd/m)*t) − v;
[mass fx ea iter] = bisect(@(m) fm(m,0.25,4,36),40,200)

mass =
142.7377
fx =
4.6089e-007
ea =
5.345e-005
iter =
21

 Thus, a result of m = 142.74 kg is obtained after 21


iterations with an approximate relative error of εa =
0.00005345%, and a function value close to zero.
Dr. Maya M. Emarah Assistant Professor, Mechatronics Department. The High Institute of Engineering, City of Science and Culture.

You might also like