We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
TO Numerical Methods
Errors in Numerical Methods
1. True Error: True error is denoted by E; and is defined as the difference between the true
value and approximate value ie. True error = True value ~ Approximate value
2. Relative Error: Relative error is denoted by Er, and is defined as the ratio between the
‘True Error
true error and the true value ie. Relative error = Metron
rue Value
3. Approximate Error: Approximate error is denoted by E,and is defined as the difference
between the present approximation and previous approximation i.e.
Approximate error= Present approximation- previous approximation
4, Relative Approximate Error: Relative approximate error is denoted by Ex, and is
defined as the ratio between the approximate error and the present approximation ic.
“Approximate Error
Present approximation
Relative approximate erro1
‘urncation errors arises from using an approximation in place of
exact mathematical procedure. It is the error resulting from the truncation of the
numerical process. We often use some finite number of terms to estimate the sum of a
finite series. For e.g. § = Di29 a,x"! is replaced by some finite sum which give rise to
truncation errors.
2. Round off Errors: Round off errors occurs when fixed number of digits are used to
represent exact number. Since, the numbers are stored at every stage of computation;
round off errors is introduced at the end of every arithmetic operation.
Bracketing & Non-Bracketing Methods
> Bracketing Method start with two initial guesses that bracket the root and then
systematically reduce the width of the bracket until the solution is reached. E.g
- Bisection Method.
> Non-Bracketing Methods (Open-end Method) use a single starting value or two values
that do not necessarily bracket the root. E.g.
- Secant method,
- Newton-Raphson Method.
hups:/{collegenote.pythonanywhere.com Prepared By: Jayanta P¢TO Numerical Methods
Different methods for the solution of Non.
wear equations are expl
Bisection method is an iterative method used for the solution of non-linear equations, also
known as binary chopping or half interval method.
This method is based on the intermediate value theorem which states that if f (x) is
continuous in the interval [x,, 2] and f (x;,) and f (x2) has different signs then the equation
FC) = 0 has at least one root between x, and x2. f2-
Here mid-point x9 is, @)
_ it me
xa |
Xz. t+ x
This gives us two new intervals [2,0] & [0,2] Ke Xi
If f (Xo) = 0 then xp is the root of f(x). Otherwise Ga)
If fo) * f Ge) < 0 then the root lies between xp & x; else root lies between x9 & x. Then
we bisect the interval as before and continue the process until the desired level of accuracy
achieved.
Algorithi
1. Define function f(x) and error
2. Guess two initial values x, and xp.
3. Compute f(2x,) and f (x2),
4. Uf fGa)* FG) >0
goto step 8, otherwise:
Calculate xq = 22
Check if| f(%9)|> error
F(X)" FOr) >O
X1=Xo
else
ae
X2=Xo
‘goto step 5
Print root =X
8. END
DFind the root of equation x* — 2x — 5 = 0 using bisection method.
Sol":
Given that,
f(x) =x8-2x-5
Let the initial guess be 2 and 3.
f(2) =-1< and f(3) = 16 > 0. Therefore root lies between 2 and 3.
hups:/{collegenote.pythonanywhere.com: PrepareTI Numerical Methods
Now let us calculate root by tabulation method,
afm [om |, -2%%] flo)
Q 2
Tt 2 3 25 3.625
2,2 | 25 2.25 1.891
(2s | 2252215 0.346
Page| e221 258 | 210625 | =0'35132
S__| 2.0625 | 2.125 2.0938 -0.0083
6 [2.0938 | 2.125 | 2.1094 | 0.1671
7_[ 2.0938 | 2.1094 | 2.1016 | 0.0789
8 _| 2.0938 | 2.1016 | 2.0977 | 0.0352
9_| 2.0938 | 2.0977 | 2.0958 | 0.0139
10 | 2.0938 | 2.0958 2.0948 0.0027
Since, X;, x2 & Xp are same up to two decimal places, so the root of given equation is 2.0948.
‘Note: To find the root of trigonometric equation we have to first make sure that calculator
is in radian form.
2 Estimate a real root of following nonlinear equation using bisection method correct upto
two significant figures.
Sol":
Given that,
f(x) = x?sinx + e-* - 3
Let the
f(A) = -1.7906 <0
(2) = 0.7725 > 0.. Therefore root lies between 1 & 2.
xsinx +e* =3
0
I guess be 1 & 2.
Now let us calculate root by tabulation method,
ny] % m |[_,-5t] Feo)
° 2
1 1 2 13 -0.5325
2 15 2 1.75 0.1872
3 15 1.75 1.625 -0.1663
Pasa sl625e| meses 1.6875 0.0133
S| 1.625 | 1.6875 1.6562 -0.0761
6 [| 1.6562 [1.6875 1.6718 ~0.0314
7 | 1.6718 | 1.6875 1.6796 =9.17x10-$
8 [1.6796 [1.6875 1.6835 1.91x10
9 | 1.6796 | 1.6835 16815 [ =3.77x10
10 | 1.6815 | 1.6835 1.6825 =9.27x10~4
11_[ 1.6825 [1.6835 1.683 4.93x10~*
Since, x, X2 & Xp has same value up to 2 decimal place, so the root of given equation is
1.683.
hups:/{collegenote.pythonanywhere.com/
Prepared By: JayantéWOE Numerical Methods
Convergence of Bisection Method
In bisection method interval is halved every interval. After n'" iteration size of interval is
reduced to
yarns _ Ae
me
ax
Now we can say that maximum error after n"* iteration is Ey co
eo
(Boe
Similarly, after (n+1)" iteration max” error is given by
_m
oo
This equation shows that error is halved after each iteration of bisection method. Therefore
we can say that bisection method converges linearly.
Advantages of Bisection Method
1. The bisection method is always convergent. Since, the method brackets the roots, the
method guaranteed to converge.
2. As iteration are conducted, the interval gets halved. So one can guarantee the decrease in
the error in the solution of the equation,
Disadvantages of Bisection Method
1. The convergence of bisection method is slow as it is simply based on halving the interval.
2. Ifone of the initial guesses is closer to the root, it will take larger number of iterations to
reach the root.
This method uses two initial es
us consider the following figure:
ates but doesn’t require that they must bracket the root. Let
The point x, and x are starting point, they do not bracket the root. Slope of line (secant line)
passing through x, and x, is given by
FO) _ fa)
mM
F (41) G2 — X32) = fF 2) Or ~ x3)
xalf 2) — FG] = FO2)-¥1 — FO). 22
£Gea)x1 = fG)x2
FG2) = FG)
Now, by adding and subtracting f (xz), to the numerator
and rearranging the terms; we get
ax, —fOD= 1)
oe Fe) — FED)
hups:/{collegenote.pythonanywhere.com Prepared By
ocroroerccr( 0)PS) Numerical Methods
This equation is called secant formula, Here, x represents the approximate root of f(x). The
approximate value of root can be refined by repeating this procedure by replacing x; by
xz and x2 by x3 in equation (1) ie. next approximate value is given by
_,, fG)G3= m)
453 ~"FGe,) =F)
This procedure is continued till the desired level of accuracy is obtained.
The secant formula in general form is
_ fed 1)
FQD = Fa)
Xi =X
Algorithm
1. Define function f(x) and error
2. Guess two initial values x1 and x2
3. Calculate f (x,) and f (x).
= £(%2)(%2-%1)
4. Compute xy = x, — XM ED
$. Set x=, & X=
6. Check if \f(x3)| > error
goto step 4, otherwise,
7. Print root = x3
8. END
Lh Use the secant method to estimate the root of the equation sinx-2x+1.
Sol":
Given that,
Ses)= sinx-2e 1
Let the initial guess be O and 1.
Now, let us calculate the root using tabular form.
1 x x2 cea) ea | mene) Cri)
PE iio
1 1 0 -0.1585 1 0.863185
Py 0 0.863185, I 0.03355 0.89315
3 [0.863185 | 0.89315 [0.03355 | -0.00725 0.88782
4 [0.89315 | 0.88782 | -0.00725 | 0.000577 0.88786
Hence, the value of x: in 3" and 4" iteration is similar up to 3 decimal places so the root of
given equation is 0.088786
hups:/{collegenote.pythonanywhere.com/ Prepared By: JiNumerical Methods
Bi Estimate a real root of following nonlinear equation using secant method correct up to
three decimal places.
x +Inx =3
Sol":
Given that,
f(x) =x? + nx -3
Let the initial guess be 1 and 2.
‘Now, let us calculate the root using tabular form.
x Xp fe) | FG) |, f@d2—)
Oe fe) = Fad
1 1 2 2 1.6932 1.54154
2 2 1.54154 | 1.6932_| -0.19087 1.58799
FE] 1.54154 1.58799 _| -0.19087 | -0.01582 1.59219
4 1.58799 1.59219 | -0.01582 | 0.00018 1.59214
Flence, the value of x3 in 3 & 4" iteration is similar up to 3 decimal places so the root of
given equation is 1.59214.
BL Using the secant method, estimate the root of the equation x — 4x — 10 = 0 with the
initial estimates of x, = 4 & X2 = 2. Do these points bracket a root?
Sol:
Given that,
f(x) = x? -4x-10
Initial estimates be x, = 4 & x2
‘Now, let us calculate the root using tabular form,
a 4 EA fe) | FG) |, fG2G2—»)
3 = 2 "FGe,) = Fa)
T a 2 =10 “4 9
2 2 9 “14 35 4
7 9 4 35 -10 5.
4 4 3.11 =10 | 4336 5.97
5 5. 5.97 4.36 1.761 $5.72
6 5.97 5.72 1.761 0.1616 5.74
7 5.72 5.74 0.1616 | -0.0124 5.74
Hence, the value of x3 in 6” & 7® iteration is similar up to 2 decimal places so the root of
given equation is 5.74.
Here, the root of given equation doesn’t lie between given initial estimates x; = 4 & x, = 2
So, given points doesn’t bracket a root.
Convergence of Secant Method
Read yourself (page no. 155, E Balagurusamy's Numerical Methods)
hups:/{collegenote.pythonanywhere.com/ Prepared By: JayaNumerical Methods
Consider a graph below of f(x). Let us consider x; is an approximate root of f(x) = 0..
Draw a tangent at the curve f(x) at x = x; as shown in figure. The point of intersection of
this tangent with the x-axis gives the second approximation to the root. Let the point of
intersection be x2. The slope of the tangent is given by; fo
tan c= LO = f1x,)
Where f (x) is the slope of f(x) at x =
_ Sen
Fo)
Der FQ
1. Solving for x» we obtain
ee
[x2, Ge2)]
“Ne,
This is called the Newton-Raphson formula,
The next approximation would be
ae
43 = 72 HG)
In general,
_ fen)
Xn = Xn Tey
Repeat this process until the difference between two successive values is within a prescribed
limit
Algorithm
1. Guess initial root=x; and define stopping criteria error.
2. Evaluate fe) & f' (a)
3. Compute new root
f@)
F'G4)
Setx=x
Check if \foc2)| > error
goto step 3,otherwise;
6. Print root =
7. END
y= x,-
as
hups:/{collegenote.pythonanywhere.com/ Prepared By: JayaTG) Numerical Methods
Di Find the root of the equation e* — 3x = 0 using Newton Raphson method correct up to
3 decimal places.
Sol":
Given that,
fis) e* — 3x
f'@)=e-3
Let the initial guess be 0.5.
Now, let us calculate the root using tabular form,
n x FC4) f'Ga) -, fen
FG)
i 05 | 0.14872_[-1.351278 0.61005
2 0.61005 | 0.010373 -1.15947 0.61899.
3 0.61899 | 0.0081472 ~1.14294 0.61273
4 [0.61273 | 0.0035755 | -1.14287 0.61903
5__| 0.61903 | 0.00008575 | -1.14287 0.61906
Here, the 4" and 5" iteration has same value of x2 up to 3 decimal place, so that root of given
equation is 0.61906,
B Use the Newton method to estimate the root of the equation x? + 2x -2=0.
vy
Given that,
f@x)=x?+2x-2
fie) = 2x +2
Let the initial guess be 0.
‘Now, let us calculate the root using tabular form.
a] os Fea) Fe) | yy, feo
oe FD
1 0 2 2 1
2 1 1 4 0.75
3 0.75 0.0625 3.5 0.73214
4 | 0.73214 0.000309 3.464 0.73205
5 | 0.73205 | -2.7975x10~° 3.464 0.73205
Here, the 4" and 5® iteration has same value of x», so that root of given equation is 0.73205.
hups:/{collegenote.pythonanywhere.com/ Prepared By: Jayanta PoudelPI) Numerical Methods
Bi Find the root of equation xcosx — x = 0 using newton’s method up to 5 decimal
places.
Sol":
Given that,
f(x) = xcosx — x?
f'@) = cosx— xsinx — 2x
Let the initial guess be 1.
‘Now, let us calculate the root using tabular form.
n] om Fa) Fe) | 2, feo
eee FD
1 1 -0.4597 -2.3012 0.80023
2 | 0.80023 -0.0829 -L4781 0.74414
3 | 0.74414 | -6.302x10"3 | -1.2566 0.73912
4 | 0.73912 | —4.313x1075 | -1.2371 0.73908
5_| 0.73908 | 6.349x107° 1.2369 0.73908
Here, the 4" and 5® iteration has same value of x up to 5 decimal places, so that root of
given equation is 0.73908.
& Find the roots of the following equations using Newton’s method.
logx-cosx=0
Solution:
Given,
F(x) = logx — cosx
FG) = 7+ sinx
Let the initial guess be 0.5.
o x FG4) f'Ga) FG)
me Xn
eee FG)
1 05 “LIT 247 1.62
2 | 1.62 0.26 1.62 1.45
3 | 1.45 0.04 1.68 1.43
4 | 143 0.01 1.68 1.42
3_| 1.42 0.002 1.69 1.42
Here, the 4 and 5" iteration has same value of x up to 2 decimal place, so that root of given
equation is 1.42.
hups:/{collegenote.pythonanywhere.com/ Prepared By: Jayanta PoudelWO Numerical Methods
Sol":
Assume that x9 be the approximate root of f (x) = 0 and x,=x9 + h be correct root so that
Fa)=f@oth=0
Where, h is a small interval ic. h = xy — Xo
We can express f(x;) using Taylor series expansion as follows:
Fn) = feo) + f’eodh +f" (eo) St.
If we neglect the terms containing the second order and higher derivatives, we get
FO) = Fo) + fh = 0
xfo)
#7)
=fe%a)
i)
L(x)
10)
2X = Xo
Similarly,
soon fe
Thus,
— Leen)
Gn)
Xnet =n
Which is the required formula for Newton Raphson method.
Convergence of Newton-Raphson Method
Read yourself (page no. 147, E Balagurusamy's Numerical Methods)
Limitations of Newton-Raphson Method
1. Division by zero may occur if f(xy) is zero or very close to zero.
2. Ifthe initial guess is too far away from the required root, the process may converge to
some other root,
3. Calculating the required derivative for every iteration may be costly tasks for some
functions.
hups:/{collegenote.pythonanywhere.com/ Prepared By: JayaAny function in the form
FG) =0.. w
can be manipulated such that x is on the left hand side of the equation as shown below
XS G(X)ooesseesen (2)
Equations (1) & (2) are equivalent and therefore a root of equation (2) is a root of equation
a.
If x9 is the initial guess to a root, the next approximation is given by;
X= 9%)
Further approximation is given by;
%2= 90%)
Thus iteration process can be expressed in general form as;
Xr = 9) §=0,1,2..
Which is fixed point iteration formula.
The iteration process would be terminated when two successive approximation agree within
some specified error.
Algorithm
Define function f(x) and error
Convert the function f(x) =0 in the form x =g(x)
Guess initial values xo.
Calculate xix, = gO)
ay <= error
goto step 7, otherwise:
Assign X; = Xie1
goto step 4
Display x; as the root
END
‘ind the one root of the equation x + x —2 = 0 using the fixed point method.
Sol":
Given that,
FQ) HF $2 = 2 =O. eee (I)
hups:/{collegenote.pythonanywhere.com/ Prepared By: Jay‘Numerical Methods
For fixed point iteration method, arranging equation (1) in terms of g(x)
x+x-2=0
or, x(x +1) =
or,x =
est
2
sg =o
Let the initial guess be 0.
Now calculating the root using tabular form
x, Xie = 9%)
2
0.667
1.199
0.91
1.04
0.98
wolce|afos}en) sn fesfrs|—) =
1.00
10 1.00
Since, the value of x;41 in 9" and 10" iteration has similar value. So the root of the given
equation is 1.00.
Bi Find the root of equation sinx = 5x — 2 up to 4 decimal places with initial guess 0.5
using fixed point iteration method.
Sol":
Given that,
F(x) = sine — 5x +250 oe)
For fixed point iteration method, arranging equation (1) in terms of g().
sinx -5x+2=0
or, sinx = Sx—2
or, x = 3 (sinx + 2)
2 g(x) = x (sine +2)
Now calculating the root using tabular form
n x Xing = 9X)
1 0.5 0.49589
2 0.49589 0.49516
3 0.49516 0.49503,
4 | 0.49503 0.49501
Since, the value of xj, in 3 and 4" iteration has similar value up to 4 decimal place. So the
root of the given equation is 0.49503.
hups:/{collegenote.pythonanywhere.com/ Prepared By: Jayanta Poudel‘Numerical Methods
Let f(x) = ayx" + dy aX" + dy px"? +
(Coa Cay + Oy 2)8 + gg) Hanon tt) +
Let Pn = ay,
Prot = QnX + ya
Pa-2 = Pn-1X + On—2
Pi = PisiX +a
Pi = Pox + ay
FO) = Po = Pix +A
Algorithm
1. Read the order of function ‘n’ and coefficient a
2. Read the value for x where value should be determined.
3. Set Py=ay
4. Fori=n-1 100
Pi = Pes 2X +
Print functional value at x=po
END
an
Example
@ Evatuate the polynomial f(x) =5x'+42+3x+9 using Horner’s rule at x=2,
Sol": n=3, a=5, a4, a
Pix a5
S42+4=14
a= 9
P)=14*2+3=31
Po=31*2+9=71
+ fQ)=71
hups:/{collegenote.pythonanywhere.com/ Prepared By: Jaya‘Numerical Methods
References:
- E, Balagurusamy, Numerical Methods, Tata McGraw-Hill
Please let me know if [ missed anything or anytl
incorrect.
[email protected]
Prepared By: Jayanta Poudel