C.G. of Civil Eng. Dept. (Shobra).
CHAPTER7 - 1
CHAPTER SEVEN
SOLVING SINGLE EQUATIONS
• Engineers are often required to solve complicated equations.
• Or it is required to obtain the Roots Of Equations.
• There are different types of mathematical equations:
a) Algebraic equations such as:
f(x) = a0 + a1 x + … + an x n
or f(x) = 1-2.37 x + 7.5 x2
or f(x) = 5x2 – x3 + 7x6
b) Non-Algebraic equation (Transcendental) such as:
f(x) = sin x
or f(x) = ln x2-1
Required:
1 - The determination of the real roots of the equations.
2 - Develop a spread sheet solution to obtain the roots of the equations.
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 2
Bracketing Methods
These techniques exploit the fact that a function typically changes sign
in the vicinity of a root.
F(x)
Root
1 - Graphical Methods:
• Use the graphical approach to determine the roots of the
667.38
f (c) = (1 - e - 0.1468c ) - 40
c
equation:
c 4 8 12 16 20
F(c ) 34.115 17.653 6.067 -2.269 -8.401
From graph: c approximately = 15
40
30
20
f(c)
root
10
0
-10 0 5 10 15 20 25
-20
c
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 3
2 – THE BISECTION METHOD
It is based on the observation :
• If f(x) is a real function and continuos in the interval between
xl and xu
• and if f(x1) * f(xu) < 0
• Then there should be at least one real root between xl and xu.
ALGORITHM FOR BISECTION :
Step 1: Choose lower xl and upper xu guesses for the root such that the
function changes sign over the interval. This can be checked by
ensuring that f(xl)*f(xu) < 0.
Step 2: An estimate of the foot xr, is determined by
Xr = (Xl+ Xu )/2
Step 3: Make the following evaluations to determine in which subinterval
the root lies:
(a) If f(Xl) f(Xr) < 0, the root lies in the lower subinterval.
Therefore, set Xu = Xr , and return to step 2.
(b) If f (Xl)f(Xr) >0, the root lies in the upper subinterval.
Therefore, set Xl = Xr and return to step 2.
(c) If f (Xl)f(Xr) =0, the root equals Xr.
Terminate the computation.
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 4
Use the Bisection method to obtain the root of the equation
667.38
f (c) = ( 1 - e - 0.146843c ) - 40
c
Step 1 : choose ( guess ) two values of “ c “ that gives values
of f(c) with different signs.
take cl = 12 and cu = 16
f (cl) * f (cu ) = 6.067 * ( - 2.269 ) < 0.0
Step 2 : An estimate of the root cr is given by
cr = (cl + cu )/2 = (12+16 )/2 =14
Step 3 : check where does the root lie ?
f ( 12 ) f (14 ) = 6.067 * 1.569 = 9.514 > 0.0
∴ The root must be located between
c = 14 and c = 16
∴ Set cl = 14 and return to step 2
Step 2 : Cr = 14 + 16 = 15
2
F (15) f (14) = 1.569 ( - 0.425 ) = -0.666 < 0.0
∴ The root is between 14 and 15
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 5
14 + 15
Step 2 : Cr = = 14.5
2
Solving the problem in a tabular form:
Iteration C l Cu F(C l) F(C u) Cr F(C r) Check Error %
no.
0 12 16 6.06202 -2.27149 14 1.56506 9.48728
1 14 16 1.56506 -2.27149 15 -0.428 -0.66984 6.66667
2 14 15 1.56506 -0.428 14.5 0.54891 0.85907 -3.44828
3 14.5 15 0.54891 -0.428 14.75 0.05567 0.03056 1.69491
Termination Criteria and Error Estimates :
• We can stop the procedure when the error in calculating the root
drops below a certain value
εt = true error %
= true root - approximation * 100
true root
but we do not know the true root
• Use an approximate relation error
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 6
εt = approximate error %
x new
r − x old
r
εt = 100 %
new
xr
Using Excel to solve the Bisection method:
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 7
Incremental searches and Determining Initial Guesses:
To obtain all possible roots we use an Incremental search :
• Start at one end of the region of interest
• Make function evaluations at small increments across the region.
• When the function changes sign, it is assumed that a root falls
within the increment.
• The x values at the beginning and the of the increment can serve
as the initial guesses of xl and xu.
F( x )
X1 X2 X3 X4 X5 X6 X7 X8
Problems ?
• If the length of the increment is very small
The search may be time – consuming
• If the length is large some roots may by missed
f(x)
X
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 8
Open Methods :
• Based on formulas that require a single starting value x or two
starting values that do necessarily bracket the root.
• These methods sometimes diverge or move from the true root.
Newton – Raphson Method:
F(x)
Slope f’ (xi)
F( xi )
F (xi) - 0
X X
i+1 i x
xi - xi + 1
f ' (xi) = f(xi) - 0.0
xi - xi+1
xi+1 = xi - f(xi) Newton – Raphson Formula
f ' (xi)
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 9
Example :
Use the Newton – Raphson Method to estimate the root of
f ( x ) = e-x -x. Use initial guess of x0 = 0.
Solution:
∴ f’ (x) = - e-x -1
xi+1 = xi - f(xi)
f ' (xi)
xi+1 = xi - (e-xi -xi) / (- e-xi -1)
Starting with X0 = 0.0
No. of iteration root
i xi
0 0
1 0.5000000
2 0.566311003
3 0.567143165
4 0.567143290
Termination Criteria
When to stop iteration ?
ea = ABS [(xi - x i-1) / xI] * 100 % < Subscribed value
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 10
Using Excel to solve Newton-Raphson Problems
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 11
Pitfalls of the Newton – Raphson Method
1 – Slow convergence for some functions
ex : f ( x ) = x10 - 1 with x = 0.5
2 – Some other problems
Inflection point x1 x0 x2 divergence
near the root
Oscillate around
local maximum or minimum
xo x2 x1 x3
Initial guess
near a root x2 x1
can jump to far x0
location
Disater
x0 x1
Solution : Initial guess should be sufficiently close to the real root
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 12
SOLVING EQUATIONS IN EXCEL USING GOAL SEEK
• Now let us see how accurate solution can be obtained quickly and easily using
Excel's Goal Seek feature.
• This feature permits rapid solution of algebraic equations using iterative root-
finding technique from an initial guess.
• To solve a single algebraic equation with Goal and Seek, proceed as follows:
1- Enter an initial guess in one of the cells on the worksheet.
2- Enter a formula for the equation, in the form F(x) = 0, in another cell. Within
this formula, express the unknown quality x as the cell address containing the
initial guess.
3- Select Goal Seek from the "Tool" menu.
4- When the Goal Seek dialog appears, enter the following information:
(a) The address of the cell containing the formula in the (set cell) entry location.
(b) The value "0" in the (To value) entry location.
(c) The address of the cell containing the initial value in the entry location labeled
(by changing cell). Then click OK.
A new dialog box labeled Goal Seek Status will then appear, telling you whether
or not Excel has been able to solve the problem (i.e., whether convergence has
been obtained).
If a solution has been obtained, the value of the root will appear in the cell
originally containing the initial guess.
The value in the cell containing the formula will show a value that is close to zero
(but usually not exactly zero).
This last value will also appear within the Goal Seek Status dialog box.
The likelihood of obtaining a convergence solution will be enhanced if the initial
guess is as close as possible to the desired root.
C.G. of Civil Eng. Dept. (Shobra). CHAPTER7 - 13
Thus, we would like to use in approximate value for the root as the initial guess.
Example: Solving a Polynomial Using Goal Seek.
F(x) = 2 X5 – 3 X3 – 5 = 0 near X = 1.4