CE 403 Lecture 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Lecture No.

4 - Numerical Solutions to CE Problems

Finding the Roots of Non-Linear Equation

Bisection Method

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

Xl  Xu
2. An estimate of the root Xr is determined by Xr 
2

3. Make the following evaluations to determine in which sub-interval that the root lines

a. If f(XL)*f(Xr) < 0, the root lies in the lower sub-interval. Therefore, set
Xu = Xr and return to step 2

b. If f(XL)*f(Xr) > 0, the root lies in the upper sub-interval. Therefore, set
XL = Xr and return to step 2

c. If f(XL)*f(Xr) = 0, the root equal Xr, terminate the computation

4. Calculate the true relative error and the approximate relative percent error,

 To calculate the true relative error ( t ), get the value of xr for the given quadratic
function using quadratic formula, then solve for ( t ) using the formula below:

t = Xr  Xrprevious x100%
Xr

 To calculate the approximate relative percent ( a ), use the formula below:

a  xrpresent xrprevious x100%


xrpresent

5. Compare with. If a < s , then stop the computation. Otherwise, go to step 2 and
repeat the process by using the new interval.

Example : Use three iterations of the bisection method to determine the root of f(x) = -0.6x2 +
2.4x + 5.5. Employ initial guesses, XL = 5 and Xu = 10. Compute the approximate percent
relative error, a and true percent relative error, t after each iteration.

i XL Xu Xr f(XL) f(Xu) f(Xr) F(XL)*f(Xr) t a


1 5 10 7.5 2.5 -30.50 -10.25 -25.625 33.25 -

2 5 7.5 6.25 2.5 -10.25 -2.938 -7.344 11.04 20

3 5 6.25 5.625 2.5 -2.938 0.016 -0.039 0.06 11.11

Therefore, after three iterations, the approximate root of f(x) is Xr = 5.625 with t = 6%
and a = 11.11%.
False Position or Regular Falsi (the root lies in between XL and Xu)

It is an improvement of the Bisection Method.

1. Choose the lower guess, xl and the upper guess, xu that bracket the root such that the
function has opposite sign over the interval, xl ≤ x ≤ xu.

2. The estimation root, xr is computed by using

f ( Xu )( Xl  Xu)
Xr  Xu 
f ( Xl )  f ( Xu )

3. Make the following evaluations to determine in which sub-interval that the root lines

a. If f(XL)*f(Xr) < 0, the root lies in the lower sub-interval. Therefore, set
Xu = Xr and return to step 2

b. If f(XL)*f(Xr) > 0, the root lies in the upper sub-interval. Therefore, set
XL = Xr and return to step 2

c. If f(XL)*f(Xr) = 0, the root equal Xr, terminate the computation

4. Calculate the approximate relative percent error,

a  xrpresent  xrprevious x100%


xrpresent
5. Compare with. If a < s , then stop the computation. Otherwise, go to step 2 and
repeat the process by using the new interval.

Example: Determine the first root f(x) = -3x3 + 19x2 -20x -13 by using False Position method.
Use the inital guesses of XL = -1 and Xu = 0 with stopping criterion, s = 1%.

i XL Xu Xr f(XL) f(Xu) f(Xr) F(XL)*f(Xr) a


1 -1 0 -0.310 29 -13 -4.091 -142.129 -

2 -1 -0.310 -0.409 29 -4.900 -1.425 -41.334 24.38

3 -1 -0.409 -0.437 29 -1.424 -0.381 -11.055 6.33

4 -1 -0.437 -0.444 29 -0.382 -0.100 -2.091 1.65

5 -1 -0.444 -0.446 29 -0.100 -0.027 -0.774 0.43

Therefore after fifth iterations, the approximate root of f(x) is Xr = -0.446 with a =
0.43%.

Example: Determine the real root of f(x) = 5x3 -5x2 + 6x -2

Newton-Raphson Method

A calculus based method

1. Choose initial value, xo and find f’(xo).


2. Compute the next estimate, xi+1 by using Newton Raphson Formula

f ( x)
xi  1  Xi 
f ' ( x)

3. Calculate the approximate perent relative error, a


a  xix1i1xi x100%

4. Compare with. If a < s , then stop the computation. Otherwise, repeat step 2.
Example: Determine the first root of f(x) = 8e-x sin(x)-1 by using Newton-Raphson Method. Use
the initial guesses of xo = 0.3 and perform the computation up to three iterations. (Use radina
mode in your computations)

i xi f(xi) f’(xi) xi+1 a


0 0.3 0.7514 3.9104 0.1078 178.18

1 0.1078 -0.2270 3.3674 0.1435 24.84

2 0.1435 -0.0090 5.8684 0.1450 1.05

Therefore, after three iterations, the approximate root of f(x) is x3 = 0.1450 with a =
1.05%.

Example: Find the root of f(x) = x3 -x -1, with xo = 2.5 using tolerance of 0.1%

Secant Method

1. Choose initial value, x-1 and xo. Find f(x-1) and f(xo)

2. Compute the next estimate, xi+1 by using Secant Method Formula

 f ( xi)( xi  1  xi ) 
xi  1  xi   
 f ( xi  1)  f ( xi ) 

5. Calculate the approximate perent relative error, a


a  xix1i1xi x100%

6. Compare with. If a < s , then stop the computation. Otherwise, repeat step 2.
Example: Determine one of the real root(s) of f(x) = -12 - 21x + 18x2 -2.4x3 by using Secant
Method with inital guesses of x-1 = 1.0 and xo = 1.3. Perform the computation until a < 5%.

i xi-1 xi f(xi-1) f(xi) xi+1 a


0 1 1.3 -17.4 -14.1527 2.6075 50.14

1 1.3 2.6075 -14.1528 13.0780 1.9796 31.72


2 2.6075 1.9796 13.0780 -1.6519 2.0500 3.44

Therefore, after three iterations, the approximate root of f(x) is x3 = 2.0500 with a =
3.44%.

Incremental Search

A technique of calculating f(x) for incremental values of x over the interval where the
root lies.

1. It starts with an initial value, xo.

2. The next value xn for n = 1,2,.. is calculated by using xn = xn-1 + h where h refers to the
step size.

3. If the signs of the two f(x) changes or if f(xn) * f(xn-1) <0 then the root exist over the
prescribed interval of the lower bound, xl and upper bound, xu.

xl  xu
4. The root is estimated by using xr 
2

Example: Find the first root of f(x) = 4.15x2 -16x +8 by using incremental search. Start the
procedure with the intial value, xo = 0 and the step size, h = 0.1. Perform three iterations of the
incremental search to achieve the best approximation root.

Start the estimation with initial value xo = 0 and step size, h = 0.1

x 0 0.1 0.2 0.3 0.4 0.5 0.6

f(x) 8 6.4415 4.966 3.5735 2.264 1.0375 -0.106

Increasing the accuracy of root estimation with step size, h = 0.01 for x  [0.5,0.6]

x 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6

f(x) 1.038 0.919 0.802 0.686 0.570 0.455 0.341 0.228 0.116 0.005 -0.106

Increasing the accuracy of root estimation with step size, h = 0.001 for x  [0.59,0.60]

x 0.59 0.591 0.592

f(x) 0.005 -0.006 -0.018

a  0.5905 0.595x100 %  0.76 %


0.5905
Therefore, after three iterations, the first root of f(x) = 4.15x2 -16x +8 is 0.5905with a =
0.76%.

Exercises

1. Use bisection method to find a root of equation f(x)=x3+4x2-10=0 using 13 iterations and
compute the approximate percent relative error, a and true percent relative error, t after
each iteration. Use the initial guesses of XL=1, XU=2

2. Use Newton Rhapson method to find a root of equation f(x)=-8x^3+6x^2+4x+5=0 using


8 iterations and compute the approximate percent relative error, a after each iteration.
Use the initial guesses of X0=5

3. Use False Position or Regular Falsi method to find a root of equation f(x)= x³+2x+5=0
using 7 iterations and compute the approximate percent relative error, a after each
iteration. Use the initial guesses of XL=-1.5 and XU=-1

Solution

1.
i XL Xu Xr f(X L ) f(Xu) f(Xr)
F(X L )* t a
f(Xr)
1 1.000000 2.000000 1.500000 -5.000000 14.000000 2.375000 -11.875000 9.89 -
2 1.000000 1.500000 1.250000 -5.000000 2.375000 -1.796875 8.984375 8.42 20.000000
3 1.250000 1.500000 1.375000 -1.796875 2.375000 0.162109 -0.291290 0.73 9.090909
4 1.250000 1.375000 1.312500 -1.796875 0.162109 -0.848389 1.524448 3.85 4.761905
5 1.312500 1.375000 1.343750 -0.848389 0.162109 -0.350983 0.297770 1.56 2.325581
6 1.343750 1.375000 1.359375 -0.350983 0.162109 -0.096409 0.033838 0.41 1.149425
7 1.359375 1.375000 1.367188 -0.096409 0.162109 0.032356 -0.003119 0.16 0.571429
8 1.359375 1.367188 1.363281 -0.096409 0.032356 -0.032150 0.003100 0.13 0.286533
9 1.363281 1.367188 1.365234 -0.032150 0.032356 0.000072 -0.000002 0.02 0.143062
10 1.363281 1.365234 1.364258 -0.032150 0.000072 -0.016047 0.000516 0.05 0.071582
11 1.364258 1.365234 1.364746 -0.016047 0.000072 -0.007989 0.000128 0.02 0.035778
12 1.364746 1.365234 1.364990 -0.007989 0.000072 -0.003959 0.000032 0.00 0.017886
13 1.364990 1.365234 1.365112 -0.003959 0.000072 -0.001944 0.000008 0.01 0.008942
Therefore, after thirteen iterations, the approximate root of f(x) is Xr = 1.365112
with t = 0.01% and a = 0.008%.
2. i xi f(x i ) f’(x i ) x i+1 a
1 5.000000 -825.000000 -536.000000 3.460821 44.47439353
2 3.460821 -240.902831 -241.924900 2.465046 40.39581469
3 2.465046 -68.510929 -112.254251 1.854726 32.90616012
4 1.854726 -17.983253 -56.303523 1.535328 20.80326525
5 1.535328 -3.668292 -34.149636 1.427910 7.522756687
6 1.427910 -0.346028 -27.799319 1.415463 0.879383323
7 1.415463 -0.004365 -27.099268 1.415301 0.011379875
8 1.415301 -0.000001 -27.090259 1.415301 0.000001892
Therefore, after thirteen iterations, the approximate root of f(x) is Xr = 1.415301 and
a = 0.000%.
3. i XL Xu Xr f(X L ) f(Xu) f(Xr) F(X L )*f(Xr) a
1 -1.500000 -1.000000 -0.787199 -1.375000 2.000000 2.937789 -4.039460 -
2 -1.500000 -1.296296 -1.247885 -1.375000 0.229132 0.561001 -0.771376 36.92
3 -1.500000 -1.325393 -1.311405 -1.375000 0.020940 0.121858 -0.167555 4.84
4 -1.500000 -1.328012 -1.328012 -1.375000 0.001871 0.001871 -0.002573 1.25
5 -1.500000 -1.328246 -1.328246 -1.375000 0.000167 0.000167 -0.000229 0.02
6 -1.500000 -1.328267 -1.328267 -1.375000 0.000015 0.000015 -0.000020 0.00
7 -1.500000 -1.328269 -1.328269 -1.375000 0.000001 0.000001 -0.000002 0.00

Therefore, after seven iterations, the approximate root of f(x) is Xr = -1.328629 and
a = 0.000%.

You might also like