Sie sind auf Seite 1von 12

PES College, PESIT campus, Department of BCA 1

Errors
Numerical methods:
What is numerical method?
Numerical method is to provide efficient methods
for obtaining higher degree of precision where
there is no exact solution.
Why numerical methods?
The approach of numerical methods is designed
in such a way that it can be easily programmed.
How it gets higher precision?
Numerical methods are iterative methods. Every
iteration the solution converges.
Significant digit
Significant digit are digits beginning with the
leftmost non zero digit and ending with right
most correct digit, including zeros that are exact.
Floating point representation
Standard way normalized form
37.21829 0.3721829 x 10
2

0.0022718 0.22718 x 10
-2
54321 0.54321 x 10
5


That is, in normalized scientific notation, the
number is represented by a fraction multiplied by
10
n
and leading digit in the fraction is not zero.

That is, x= 0.d
1
d
2
d
3
. x 10
n
where d10,
n-interger
Significant digits
are digits beginning with the leftmost nonzero
digit and ending with the rightmost correct digit,
including final zeroes that are exact.
Single precision floating point form
(-1)S x 2
C-127
x (1.f)
2

The left most bit is used for the sign of the
mantissa, where s=0 corresponding to positive
number and s=1 corresponding to negative.
The next eight bits are used to represent the
number C in the exponent of 2
C-127
, w hich is
interpreted as an (excess -127) code.
Finally, the last 23 bits represent is from the
fractional part of the mantissa in the
1+form(1.f)
2
.





Format:
b bbbbbbbb bbbbbbbbbbbbbbbbbbbbbbb
Sign
bit
(1)
Exponent
(8)
Mantissa (23)

For Double precision
b bbbbbb
bbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbb
1
b
i
t
Expone
nt
(12
bits)
Mantissa (52 bits)

Example 01:
Determine the single precision / double precision
representation of the decimal number
-52.234375.
First convert 52 into binary
(52)
10
(110100)
2

Next (0.234375)
10
(0.001111)
2

(-52.234375)
10
(110100.001111)
2

Convert to normalized form
0.110100001111x2
6
Convert to 1.f normalized form
1.10100001111x2
5
Since C-127=5 C=132
(132)
10
(10000100)
2

Finally, the number -52.234375 into single
precision format is
11000010010100001111000000000000
For double precision
Excess 1027 code.
Hence c-1023 = 5 c=(1028)
2
(10000000100)
2

110000000100101000011110000000000000000
0000000000000000000000000

Example 02:
Convert (BA390000)10 ( )
2

( B A 3 9 0 0 0 0)
16

1011 1010 0011 1001 0000 0000 0000 0000

(01110100)
2
(116)
10

C-127=116 C=-11

= -(1.0111001) x 2
-11

= -(0.000000000010111001)
2



PES College, PESIT campus, Department of BCA 2

|
.
|

\
|
+ + + + =
|
.
|

\
|
+ + + + =
262144
1
32768
1
16384
1
8192
1
2048
1
2
1
2
1
2
1
2
1
2
1
18 15 14 13 11

= - 0.0007057
= -(7.057)x10
-4


Loss of signification
The loss of signification happens in substraction.
Example:
0.59362008
- 0.59362002
-------------
0.00000
-------------

This is the answer if the system format can take
only upto 5 digits but the actual answer is
0.00000006 where we loss significant digits.

Avoiding loss of significance digits in
subtraction:
1. Rationalize

1 1
2
+ x =
1 1 1 1
1 1
1 1
2
2
2
2
2
+ +
=
+ +
+ +
+
x
x
x
x
x
Where the subtraction is avoided.

2. Sin(x) = ...
! ! !
+ +
7 5 3
7 5 3
x x x
x
=
|
|
.
|

\
|
+
|
|
.
|

\
|
+ + ....
! !
.....
! 7 3 5
7 3 5
x x x
x

In this case instead of n number of
subtraction we are doing just one
subtraction.

Note:
The value of c in single precision is restricted by
the inequality
0 < c < (1111111)
2
=(255)
10

0 to 255 represent only positive integer.
What about negative?
Hence the actual exponent of the number is
restricted by the inequality
-126 <= c-127<=127.

Like wise in mantissa,
1<=(1.f)
2
<=(1.11111111111111111111111)
2

=2-2
-23
(hint: 9.999 can be written as 10 - 10
-3
)

Hence
The largest number representable is
(2-2
-23
)x 2
127
= 34 x 10
38


The smallest number representable is
2
-126
= 1.2 x 10
-38

Exercise
Determine the single precision and double
precision machine representation in a 32 bit word
length computer of the following numbers.
1. (492.78125)
10

2. (64.37109375)
10

3. (3F27E520)
16


4. (3BCDCA00)
16

5. (0.2)
10








PES College, PESIT campus, Department of BCA 3

Roots of an Equation
In Mathematics we often encounters problems of
obtaining solutions of equations of the form
f(x)=0.
Due to limitations of analytical methods, formula
giving exact numerical values of the solutions
exist only in very simple cases.
In this chapter we present the following methods
for obtaining approximate solutions for algebraic
and transcendental equations.

i) Iteration method(successive app.,)
ii) Bisection method (Bolzano method)
iii) Regula Falsi method(method of false
position)
iv) Newton Raphson method (method of
tangent)
v) Secant method. (open method)

Solving equations are two types.
1. closed form solutions
2. trial and error
Closed form

is a closed solution for


ax
2
+bx+c=0. For higher order polynomial
equations and non-polynomial it is difficult and in
many cases impossible to get closed form
solutions, rounding errors often reduced their
accuracy.
Trial and error
It is however, dislike by a human problem
solver, because a sequence of steps is repeated
over and over again.
Such a procedure is concisely expressible
as a computational algorithm it is thus a natural
method to use with computer.
Root:
The roots of the equation are the points
where the graph of y=f(x) cuts the x-axis. For
example f(x) = x
3
-2.5x
2
-2.4x+3.96=0





x -3 -2 -1 0 1 2 3
f(x) -38.2 -9.1 2.9 4.0 0 -3 1.1

Theorem:
If f(x) is continuous in the interval [a, b] and if
f(a) and f(b) are of opposite signs then the
equation f(x)=0 has atleast one root lying
between a and b.


0 -1 -2 1 2 3


PES College, PESIT campus, Department of BCA 4

Iterative Method (Successive approximation Method)
Theory:
Let f(x) =0 be the given equations. Suppose the
equation can be expressed in the x=(x), where
(x) is a continuous function. Let x0 be an
approximate value of the desired root. We define
x1=(x0)
X2=(x1)
.
.
.
Xn=(xn-1)
The sequence (x0, x1, x2, .., , xn) is called the
sequence of successive approximation.
Suppose the sequence (xn)o. That is

) . Since (x) is a continuous function


we have

) ().
o=(o)
This o is a root of the equation x=(x) and hence
it is a root of f(x)=0.
Note: In general the sequence of successive
approximation ((x0, x1, x2, .., , xn) may not a
convergent sequence.
Example: x = 2
x

Let x
0
=0, x
1
`=2
0
=1, x
2
=2, x
3
=4, .
The above sequence is divergent. In order to
avoid this divergence, we have to choose x in a
such a way that |(x)|<1 in some interval I
containing o.
Problem 01:
Use the method of iteration, to find the real root
of the equation x
3
-3x+1=0 upto 3 decimal
places.
Solution:
Let f(x) = x
3
-3x+1
f(0) = 1, f(1)=-1 and f(2)=3. Here f(1) and f(2)
are of opposite sign. Hence there is atleast one
root lying between 1 and 2.
Let x0=0.
X
3
=3x-1 x = (3x-1)
1/3
=(x)
And hence (x)=1/(3x-1)
2/3
. Clearly |(x)|<1
(). Hence if we take x
0
=2, then the
sequence of successive approximation (x0, x1,
x2, .., , xn) will converge.
Let x
0
=2
X
1
=(x
0
)= (2)=5
1/3
=1.7100
X
2
=(x
1
)= (1.71)=1.6044
X
3
=(x
2
)= (1.6044)=1.5623
X
4
=1.5449
X
5
=1.5375
X
6
=1.5344
X
7
=1.5331
X
8
=1.5325
X
9
=1.5323
X
10
=1.5322
The difference between x
9
and x
10
are 0.0001
which is less than e=0.001.
Hence approximate value of the required root is
1.5322.
Note:
If we rearrange x = (x
3
+1)/3 then
X
0
=2
X
1
=(x
0
)= (2)=3


PES College, PESIT campus, Department of BCA 5

X
2
=(x
1
)= (3)=9.3333
X
3
=(x
2
)= (9.3333)=271.3428
.
.
.
Which is divergence because |(x)|not less than
one.
Hint:
The x should be choosen from the highest power
of the equation in order to avoid divergence.
Problem 02:
Find the real root of the equation cos(x)=3x-1
correct to four decimal places using successive
approximation method.
Solution:
Let f(x) = 3x-1-cos(x)
f(0)=0-1-1=-2 and f()=(3 /2)-1-0=4.7143-
1=3.7143.
therefore, one root lies between 0 and .
Now, f(x)=0 can be written as
x=1/3*(1+cos(x))= (x).
Let Let x
0
=0
X
1
=(x
0
)= (0)=0.6667
X
2
=(x
1
)= (0.6667)=0.5953
X
3
=(x
2
)= (0.5933)=0.6093
X
4
=0.6067
X
5
=0.6072
X
6
=0.6071
X
7
=0.6071
Therefore, the root is 0.6071.
Hint:
Whenever the trigonometric function are used,
we need to work in terms of radian not in
degree.
Exercise:
1. x
3
+x
2
-1=0 Ans:0.7548
Hint:

= (x)
for x=(1-x
2
)
1/3
, (x) is not less than 1 in
[a,b] (x) is not continuous and hence
it may be either cyclic or divergence.
2. 3x- Ans:0.3919
3. x
3
+x
2
-100 Ans:4.3311
4. 2x-logx-7=0 Ans:3.7892
5. 1+sinx-2x=0 Ans: 1.497





PES College, PESIT campus, Department of BCA 6

Bisection Method
Let f(x) be the given equation. Give different
values of x and find the sign of f(x), whenever
there is a change in sign of f(x) either from
positive to negative or vice versa, it is implied
that the root lies between these two values.

Procedure to solve by Bisection Method
Step 1: Let f(a) be negative and f(b) be positive
then the root lies between a and b.
Step 2: Bisect the interval [a,b] and find
x
0
=(a+b)/2
Step 3: if f(x
0
)=0, we conclude that x
0
is a root of
the equation. Otherwise the root lies
either between a and x
0
or between x
0

and b depending on whether f(x
0
) is
positive or negative.
Step 4: Repeat this process until the latest value
is reached desired precision.


Convergence Analysis:
It is clear that the interval length is
reduced by half in each interval.
We designate this new interval as [a1, b1]
whose length is |b-a|/2.
We repeat this process until the latest
interval (which contains the root) is as small as
desired say e.
At the nth iteration, the new interval will
be [a
n
, b
n
] of length
||


We have
||


||


||

||

.

The above equality gives the number for
iterations required to achieve an accuracy e.
The minimum number of iterations required for
converging to a root in the interval (0, 1) for
given e are listed below.
Number of iterations
e
10
-2
10
-3
10
-4
10
-5
10
-6
10
-7

N 7 10 14 17 20 24
The method is shown graphically.








Problem 01:
Find the real root of the equation x
3
-2x-5.
Solution:
Let f(x)= x
3
-2x-5
f(1)=1-2-5=-6
f(2)=8-4-5=-1 (negative)
f(3)=27-6-5=16(positive)
therefore the root lies between 2 and 3.
No. of a x b
iteration
1 2 2.5 3
2 2 2.25 2.5
3 2 2.125 2.25
4 2 2.0625 2.125
5 2.0625 2.0938 2.125
6 2.0938 2.1094 2.125
7 2.0938 2.1016 2.1094
root
X
0
X
1
X
2



PES College, PESIT campus, Department of BCA 7

8 2.0938 2.0977 2.1016
9 2.0938 2.0957 2.0977
10 2.0938 2.0948 2.0957
11 2.0938 2.0943 2.0948
12 2.0943 2.0945 2.0948
13 2.0945 2.0947 2.0948
14 2.0945 2.0946 2.0947
15 2.0945 2.0946
2.0946
The difference between last two roots is less that
0.001 and hence the root is 2.0946.
Exercise:
1. x
3
-x-1 Ans: 1.3248
2. x
3
-4x+1 Ans: 1.8607
3. xe
x
-1 Ans: 0.5671
4. e
x
-3x Ans: 0.6191
5. xsinx+cosx Ans: -2.7984



PES College, PESIT campus, Department of BCA 8

Newton(-Raphson) or open methods
Proper choice of the initial root is very
important in the Newton method. If the initial
choice happens to be near the root the technique
converges very fast. If one is unfortunate to pick
a wrong starting point the procedure may lead to
an endless cycle. See the diagram.








Note:
a. a safety exit out of the iteration loop
should be provided after computing a pre-
assigned number of iteration to prevent
the program from getting into an endless
cycle.
b. Once a preliminary estimate is available
then the Newton-Raphson procedure may
be safety applied to quickly converge to
the root.
Theory:
Let f(x) = 0 be the given function. Let x
0
be the
approximated root of f(x)=0 and let x
0
+h be the
correct root so that f(x
1
)=0. Implied f(x
0
+h)=0
Expanding f(x0+h) using Taylors series, we get
F(x
0
+h)=
f(x
0
)+hf(x
0
)+(h
2
/2)f(x
0
)+(h
3
/3!)f(x
0
)+..=0 -
---(1)
neglecting the second and higher order
derivatives, we have,
f(x
0
)+hf(x
0
)=0
h=-f(x
0
)/f(x
0
) -----(2)
a better approximation than x0 is given by x1.
Substituting (2) in (1) we get,


x
1
=

)
. The successive
approximation are given by x
1
, x
2
, x
n+1
where

)

this is newton Raphson formula.
Problem 01:
Use NR method to find the root of the equation
x
3
-x-1=0 near 1.5.
Solution:
Let f(x) = x
3
-x-1=0 and x
0
=1.5
Current f(x
n
) f(x
n
) next root
root

)

x
n

1.5 0.875 5.7500 1.3478
1.3478 1.3252
1.3252 1.3247
1.3247 1.3247
Therefore, the root of the given equation is
1.3247
Exercise:
1. Sin(x) = x-2 near x
0
=2.5 Ans: 2.5542
2. X
3
-2x-5=0 near 1.8 Ans: 2.0946
3. X+logx=2 Ans: 1.5571
4. 4(x-sinx)=1 Ans: 1.1712
5. Sinx=1-x Ans: 0.9830
X1
cyclic
divergenc
e
X
a
X2


PES College, PESIT campus, Department of BCA 9


Newtons method for multiple roots:
For double root:

)


For multiple roots:

()(

()(

)
and so on.
Problem: 02
Find the double root of the equation
f(x)=x
3
-x
2
-x+1.
Solution:
f(x)=3x
2
-2x-1
f(x)=6x-2

=1012

=1.043
These value indicate there is a double root
near 1.

)
=1.012-0.0099=1.0001

)
(

)
=1.01-
0.0099=1.0001
Hence we conclude that there is a double root
near x=1.0001
Problem:03
The equation f(x)=x
3
-7x
2
+16x-12=0 has a
double root at x=2. Starting with the initial
approximation x
0
=1. Find the root correct to 3
decimal places using modified Netwons method
with m=2.
Solution:

)
=1.8

)
=1.625
Choose x
1
=1.8 (because it is near to 2)

)
=1.9846

)
(

)
=1.9625
Choose x2=1.9846

)
=1.999884

)
(

)
=1.999659
The root correct to 3 decimal places is 2.000
Exercises:
Show that the equation 1-xe
1-x
=0 has a double
root at x=1. The root is obtained by using the
modified Newton raphson method with m=2,
starting with x
0
=0.
Problem 04:
Find an iterative formula to find (where N is a
positive number) and hence find .
Solution:
Let x= x
2
-N=0


PES College, PESIT campus, Department of BCA 10

Let f(x)= x
2
-N=0, f(x)=2x

)
The above formula is the iterative formula to find

To find , put N=5 and also root lies between 2
and 3. Therefore take x
0
=2.
Apply in the above formula we get
x1=2.25,x2=2.2361and x3=2.2360. hence the
approximate root is 2.2360
Exercise:
Fine the iterative method for finding 1/N, N
1/3
.
Apply the methods to N=18 to obtain the result.
Newtons method for system of Non-linear
equations.
Theorem:
let (x
0
, y
0
) be an approximation to a root (,q) of
the system f(x,y)=0, g(x, y)=0 in the closed
neighborhood R containing (,q). If
i. f, g and all their first and second
derivatives are continuous and
bounded in R and
ii. J(f,g) 0 in R, then the sequence of
approximation given by

()
|

| and

()
|

|
converges to the root (,q) of the given system.
Working Procedure
Step 1: Find J(f, g) is the Jacobian given by
( )
|
|

|
|

Step 2: Find J
0
-1
= [

=
[

]
|

|

Step 3: *

+ *

+-J
0
-1
[
(

)
(

)
]
The process is to be repeated till we
obtain the roots to the desired degree
of accuracy. If the iteration converges, it does so
quadratically.
Problem 05:
Find the real root of the equations x
2
-y
2
=3 and
x
2
+y
2
=13.
Solution:
For initial approximation, substitute y=x,
In x
2
-y
2
=3, it will become zero.
In x
2
+y
2
=13, y=x 2x
2
=13 x
2
=6.5
x=
substitute x= in x
2
+y
2
=13,
y
2
=13-6.5 y=
Hence the initial approximation are
x
0
==2.54951, y
0
==2.5491.
Now let f(x,y)= x
2
-y
2
=3 & g(x,y)= x
2
+y
2
=13
Calculate

( ) |

( ) |

| =8x
0
y
0
.
J
0
-1
= [

=
[

]
|

|
=
*

+
|

|

Now we can write
*

+ *

+-J
0
-1
[
(

)
(

)
]
*

+ *

+-

()
*


+ *

+
= *

+
*

+ *

+-

*


+ *

+ = *

+


PES College, PESIT campus, Department of BCA 11

*

+ *

+
X
2
and x
3
are sufficiently close to each other and
hence we stop our iterative process.
Therefore, the roots are x
3
=2.82847,
y
3
=2.23615.
Exercise:
Solve the system of nonlinear equations:
1. x
2
-y
2
=4: x
2
+y
2
=16
2. x
2
+xy+y
2
=7; x
3
+y
3
=9
3. The system of equation x
2
y+y
3
=10; xy
2
-x
2
=3
has a solution near x=0.8 and y=2.2.
Perform two iterations to obtain the root.
4. X
2
+y=1; y
2
+x=7
5. X
2
=3xy-7 ; y=2x+2



PES College, PESIT campus, Department of BCA 12


The secant method
A serious disadvantage of the NR method
is, the need to calculate f(x) in each iteration.
The numerical methods which do not need the
evaluation of f(x) have been sought. One of
these is secant method.
In this method, f(x) is approximate by the
expressions

()
()()

where xi
and xi-1 are two approximated to the root.
The iterative formula to go to ith to the
(i+1) is given by

()
()()()

Observe that in this method a secant is
drawn connecting f(x
i-1
) and f(x
i
). The point
where it cuts the x axis is x
i+1
.
Another secant is drawn through f(x
i
) and
f(x
i+1
) to get x
i+2
. This repeat till f(x) 0.
For calculation we use

)
(

)(

)
.
The secant method formula is
For calculation we use

)
(

)(

)
(

).
This process will continued till the desired
accuracy is reached.
Note:
There are chances of process to diverge because
we never check f(x
n
)x f(x
n-1
)<0 that is, for
opposite sign.

Example01:
Solve x
4
-x-10=0 using secant method.
f(1)=1-1-10=-10
f(2)=16-2-10=4.
Let x
0
=1, x
1
=2

)
(

)(

)
(

).


()

=1.7143.
Similarly, x3=1.8385
X4=1.8578
X5=1.8556
X6=1.8556
There fore, the root is 1.8556

Exercise:
1. X
3
-x-3 Ans:1.6717
2. X
2
-2x-1 Ans: 2.4142
3. X+logx=2 Ans:
4. 4(x-sinx)=1 Ans:
Golden Ratio:
The order of convergence for the secan method
can be expressed in terms of the inequality
|

| |


Where o=(1/2)x(1+)~1.62 is the golden ratio.

root
X
0
X
1
X
2

Das könnte Ihnen auch gefallen