You are on page 1of 5

Experiment 4a

Roots of Equations
Objectives:
1. To be able to implement numerical methods in solving the roots of equations.
2. To be able to demonstrate the strengths and weaknesses of various root finding methods.
Introductory Information:
The problem of determining the roots of a function of the form f(x) = 0 is a
common problem that an engineer needs to solve. The roots occur where the function intersects
the x axis and are the values of x that will satisfy f(x) = 0. Knowing how to determine the roots
numerically for algebraic equations like polynomials or transcendental equations like
trigonometric functions are important for a lot of applications in engineering.
The numerical methods for solving roots of functions with one independent variable, x,
use initial guesses of the root to start of an iteration that will eventually result in an approximation
of the actual root. These methods can be distinguished by the type of the initial guess:
A. Bracketing methods requires two initial guesses that will serve as the interval that contains
the root to be calculated. As long that there is indeed a root bracketed by the initial guesses,
these methods will always work but usually takes lots of iterations.

Bisection Method This method can be used once the interval containing the root of the
given function has been determined. The said interval is divided into two per iteration as
the root is being homed on. Each iteration determines which half of the current interval
contains the root and upon determining it, divides that half and continues on the search
between those two new divisions until a given stop criterion is met.

Procedure:
1. Obtain the interval, xi and xi+1, containing the root.
2. Evaluate the midpoint of the interval, xi 1 / 2 xi xi 1 / 2
3. Check the sign of the product f xi f xi 1 / 2
(a) If the sign of the product is positive, then the root lies in the RIGHT half of the interval.
Replace xi by xi+1/2 and retain xi+1.
(b) If the sign of the product is negative, then the root lies in the LEFT half of the interval.
Replace xi+1 by xi+1/2 and retain xi.
(c) If the product is zero, then the root is equal to xi+1/2.
4. Repeat steps 2 and 3 and stop when the absolute percent relative error of xi+1/2 is less than
a given error, which is a very small number close to zero, e.g. error = 1x10 -5. The present
value of xi+1/2 may then be considered as the root.
LBYEC34 (NUMMETH Lab)
Experiment No. 4a: Roots of Equations
Page 1 of 5

False Position Method Also known as the Regula Falsi or Linear Interpolation method.
Like the Bisection method, this method can be used once the interval containing the root
has been determined. The method deals with joining the function at the upper and lower
intervals with a line. The intersection point of the said line with the x axis is the new root
value, which will replace either one of the intervals a better approximation of the root.
Each iteration estimates the actual root more closely until a given stopping criterion is
met.

Procedure:
1. Let the interval containing the root be x1 and x2.
2. Compute f x1 and f x 2 .
3. Compute x3.

x3

x1 f x 2 x 2 f x1
f x 2 x 2 x1
or x3 x 2
f x 2 f x1
f x 2 f x1

4. Check the sign of the product f x1 f x3


(a) If the sign of the product is positive, then the root is between x3 and x2. Replace x1 by x3
and retain x2.
(b) If the sign of the product is negative, then the root is between x1 and x2. Replace x2 by x3
and retain x1.
(c) If the product is zero, then the root is equal to x3.
5. Repeat steps 2 to 4 and stop when the absolute percent relative error of x3 is less than a
given error, for example error = 1x10-5. The value of x3 may then be considered as the
root.
B. Open methods uses one or more initial guesses but they do not need to bracket the root.
These methods may not come up with an approximation of the root no matter how many
iterations are performed, however when they do work they approximate the root really quick.

Secant Method (Open Method) This is almost the same as the False Position method in
the sense that it draws lines between two current two current interval function points upon
which the intersection point is the new root estimate. The major difference is that once the
iteration starts, the lower interval will always be replaced by the upper interval and the
new estimate will be the upper interval. The method name is derived from the lines that
join the interval function points, as they are secant lines of the function itself.

Procedure:
1. Start with two initial guesses of the root, x1 and x2.
2. Compute f x1 and f x 2 .
3. Compute x3.

x3

x1 f x 2 x 2 f x1
f x 2 x 2 x1
or x3 x 2
f x 2 f x1
f x 2 f x1

LBYEC34 (NUMMETH Lab)


Experiment No. 4a: Roots of Equations
Page 2 of 5

4. Replace x1 by x2 and replace x2 by x3.


5. Repeat steps 2 to 4 and stop when the absolute percent relative error of x3 is less than a
given error, for example error = 1x10-5. The value of x3 may then be considered as the
root.
Exercise
******************************************************************************
Create a program that will perform root location for the equation f(x) = x3-2x2- 5 using the three
root-finding methods Bisection, False Position Method, and Secant Method. The user will
choose one of the methods, input a guess for the value of the interval points, and the program will
calculate the approximate value of the root, along with the percent relative error Ea. The
calculations will stop when the absolute value of Ea falls below error criterion Es or after 20
iterations. Tabulate the results for each method. Ensure that the result will be correct to at least 3
significant figures, use Es = (0.5 x 102-3)% = 0.05%.
******************************************************************************
Tables:

(a) Bisection Method Show in 5 columns the value for xi, xi+1, xi+1/2, the sign of the product in
step 3, and the relative error.

LBYEC34 (NUMMETH Lab)


Experiment No. 4a: Roots of Equations
Page 3 of 5

(b) False Position Method Show in 5 columns the value for x1, x2, x3, the sign of the product in
step 3, and the relative error.

(c) Secant Method Show in 4 columns the value for x1, x2, x3, and the relative error.

LBYEC34 (NUMMETH Lab)


Experiment No. 4a: Roots of Equations
Page 4 of 5

Guide Questions:
1. Explain the distinction of Bisection, False-position, and Secant method with respect to the
results of the experiment.
From the experiment, the results of the 3 methods are near to one another. In some cases there
are some irregularities in which one method shows a very large difference compare to the
other methods. Another observation was the number of iteration used in order to attain the
0.05% tolerance; the secant method shows the least iteration compare to the other two
methods.
2. Enumerate the strengths and weaknesses of various root finding methods used in this
experiment.

LBYEC34 (NUMMETH Lab)


Experiment No. 4a: Roots of Equations
Page 5 of 5

You might also like