Sie sind auf Seite 1von 104

Computer Arithmetic

and
Different Types of Errors
Dr. P. DHANUMJAYA
Department of Mathematics

BITS-Pilani K K Birla Goa Campus

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Why you should study Numerical Methods

Numerical methods are extremely powerful problem


solving tools.
They are capable of handling large systems of equations,
nonlinearities and complicated geometries that are often
arises in engineering braches.
They are ingeneral impossible to solve analytically.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

During your career, you may often have occasion to use


commercially available packages that involve numerical
methods. The intelligent use of these packages is often
predicted on knowledge of the basic theory underlying the
methods.
Many problems cannot be approached using commercially
available packages. If you are conversant with numerical
methods and computer programming, you can design your
own programs to solve the problems.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Finite Digit Arithmetic and Errors

We consider how numbers are represented in computers.


Most computers have an integer mode and a floating-point
mode for representing numbers.
The integer mode is used only to represent integers.
The floating-point form is used to represent real numbers.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Finite Digit Arithmetic and Errors

We consider how numbers are represented in computers.


Most computers have an integer mode and a floating-point
mode for representing numbers.
The integer mode is used only to represent integers.
The floating-point form is used to represent real numbers.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

Scientific calculations are usually carried out in


floating-point arithmetic.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

An n-digit floating-point number in base has the form


x = (.d1 d2 d3 dn ) e ,
where (.d1 d2 d3 dn ) is a -fraction called the mantissa, and
e is an integer called the exponent.
A floating-point number is said to be normalized if 1 d1 9
and 0 di 9, for each i = 2, 3, 4, , n.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

An n-digit floating-point number in base has the form


x = (.d1 d2 d3 dn ) e ,
where (.d1 d2 d3 dn ) is a -fraction called the mantissa, and
e is an integer called the exponent.
A floating-point number is said to be normalized if 1 d1 9
and 0 di 9, for each i = 2, 3, 4, , n.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

An n-digit floating-point number in base has the form


x = (.d1 d2 d3 dn ) e ,
where (.d1 d2 d3 dn ) is a -fraction called the mantissa, and
e is an integer called the exponent.
A floating-point number is said to be normalized if 1 d1 9
and 0 di 9, for each i = 2, 3, 4, , n.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

An n-digit floating-point number in base has the form


x = (.d1 d2 d3 dn ) e ,
where (.d1 d2 d3 dn ) is a -fraction called the mantissa, and
e is an integer called the exponent.
A floating-point number is said to be normalized if 1 d1 9
and 0 di 9, for each i = 2, 3, 4, , n.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

Most digital computers use the base 2 (binary) number


system or base 8 (octal) or base 16 (hexadecimal).
Pocket calculators use base 10 (decimal).

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

Most digital computers use the base 2 (binary) number


system or base 8 (octal) or base 16 (hexadecimal).
Pocket calculators use base 10 (decimal).

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example 1

The conversion of a base 2 number to decimal


(11011.01)2 = 1 24 + 1 23 + 0 22 + 1 21
+ 1 20 + 0 21 + 1 22
= 27.25

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example 1

The conversion of a base 2 number to decimal


(11011.01)2 = 1 24 + 1 23 + 0 22 + 1 21
+ 1 20 + 0 21 + 1 22
= 27.25

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Chopping and Rounding

Most real numbers x cannot be represented exactly by the


floating-point representation.
We approximate by a nearby number representable in the
machine.
Given an arbitrary real number x, we let fl(x) denote its
floating-point representation.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Chopping and Rounding

Most real numbers x cannot be represented exactly by the


floating-point representation.
We approximate by a nearby number representable in the
machine.
Given an arbitrary real number x, we let fl(x) denote its
floating-point representation.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Chopping and Rounding

Most real numbers x cannot be represented exactly by the


floating-point representation.
We approximate by a nearby number representable in the
machine.
Given an arbitrary real number x, we let fl(x) denote its
floating-point representation.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

There are two ways of producing fl(x) from x, chopping


and rounding.
Let a real number x be written in the form
x = (0.d1 d2 d3 dn dn+1 ) e
with d1 6= 0.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

There are two ways of producing fl(x) from x, chopping


and rounding.
Let a real number x be written in the form
x = (0.d1 d2 d3 dn dn+1 ) e
with d1 6= 0.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

There are two ways of producing fl(x) from x, chopping


and rounding.
Let a real number x be written in the form
x = (0.d1 d2 d3 dn dn+1 ) e
with d1 6= 0.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

There are two ways of producing fl(x) from x, chopping


and rounding.
Let a real number x be written in the form
x = (0.d1 d2 d3 dn dn+1 ) e
with d1 6= 0.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The chopped machine representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The chopped machine representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The rounded representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e ,
whenever 0 dn+1 < 2 and
h
i
fl(x) = (0.d1 d2 dn ) + (0.00 01) e ,
whenever

dn+1 < 1.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The rounded representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e ,
whenever 0 dn+1 < 2 and
h
i
fl(x) = (0.d1 d2 dn ) + (0.00 01) e ,
whenever

dn+1 < 1.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The rounded representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e ,
whenever 0 dn+1 < 2 and
h
i
fl(x) = (0.d1 d2 dn ) + (0.00 01) e ,
whenever

dn+1 < 1.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The rounded representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e ,
whenever 0 dn+1 < 2 and
h
i
fl(x) = (0.d1 d2 dn ) + (0.00 01) e ,
whenever

dn+1 < 1.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The rounded representation of x is given by


fl(x) = (0.d1 d2 d3 dn ) e ,
whenever 0 dn+1 < 2 and
h
i
fl(x) = (0.d1 d2 dn ) + (0.00 01) e ,
whenever

dn+1 < 1.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note 3

Note that
(0.d1 d2 d3 dn ) =

Computer Arithmetic and Different Types of Errors

d1
d2
dn
+ 2 + + n.
1

Dr. P. Dhanumjaya

Note 3

Note that
(0.d1 d2 d3 dn ) =

Computer Arithmetic and Different Types of Errors

d1
d2
dn
+ 2 + + n.
1

Dr. P. Dhanumjaya

Definition of Errors

The absolute error is defined as the difference between the true


value x and the approximate value fl(x).
Thus,
ex = |x fl(x)|.
Absolute error may not reflect the reality.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Definition of Errors

The absolute error is defined as the difference between the true


value x and the approximate value fl(x).
Thus,
ex = |x fl(x)|.
Absolute error may not reflect the reality.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Definition of Errors

The absolute error is defined as the difference between the true


value x and the approximate value fl(x).
Thus,
ex = |x fl(x)|.
Absolute error may not reflect the reality.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Definition of Errors

The absolute error is defined as the difference between the true


value x and the approximate value fl(x).
Thus,
ex = |x fl(x)|.
Absolute error may not reflect the reality.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

One picks up 995 correct answers from 1000 problems


certainly is better than the one that picks up 95 correct answers
from 100 problems, although both of the errors are 5.
A more realistic error measurement is the relative error which is
defined as
absolute error
relative error =
.
true value

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

One picks up 995 correct answers from 1000 problems


certainly is better than the one that picks up 95 correct answers
from 100 problems, although both of the errors are 5.
A more realistic error measurement is the relative error which is
defined as
absolute error
relative error =
.
true value

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

One picks up 995 correct answers from 1000 problems


certainly is better than the one that picks up 95 correct answers
from 100 problems, although both of the errors are 5.
A more realistic error measurement is the relative error which is
defined as
absolute error
relative error =
.
true value

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

For example, if x 6= 0, then


relative error in x =

| x fl(x) |
.
|x|

Obviously, for different x, the error |x fl(x)| and the relative


error are different.
How do we then characterize the round-off errors?.
We seek the upper bounds.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

For example, if x 6= 0, then


relative error in x =

| x fl(x) |
.
|x|

Obviously, for different x, the error |x fl(x)| and the relative


error are different.
How do we then characterize the round-off errors?.
We seek the upper bounds.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

For example, if x 6= 0, then


relative error in x =

| x fl(x) |
.
|x|

Obviously, for different x, the error |x fl(x)| and the relative


error are different.
How do we then characterize the round-off errors?.
We seek the upper bounds.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

For example, if x 6= 0, then


relative error in x =

| x fl(x) |
.
|x|

Obviously, for different x, the error |x fl(x)| and the relative


error are different.
How do we then characterize the round-off errors?.
We seek the upper bounds.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

For example, if x 6= 0, then


relative error in x =

| x fl(x) |
.
|x|

Obviously, for different x, the error |x fl(x)| and the relative


error are different.
How do we then characterize the round-off errors?.
We seek the upper bounds.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

In place of relative error, we often use the concept of significant


digits.
Let x denotes the true solution and x denotes an approximate
solution.
The number x is said to approximate x to k significant digits
(or figures) if k is the largest nonnegative integer for which
|x x |
5 10k .
|x|

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

In place of relative error, we often use the concept of significant


digits.
Let x denotes the true solution and x denotes an approximate
solution.
The number x is said to approximate x to k significant digits
(or figures) if k is the largest nonnegative integer for which
|x x |
5 10k .
|x|

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

In place of relative error, we often use the concept of significant


digits.
Let x denotes the true solution and x denotes an approximate
solution.
The number x is said to approximate x to k significant digits
(or figures) if k is the largest nonnegative integer for which
|x x |
5 10k .
|x|

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

In place of relative error, we often use the concept of significant


digits.
Let x denotes the true solution and x denotes an approximate
solution.
The number x is said to approximate x to k significant digits
(or figures) if k is the largest nonnegative integer for which
|x x |
5 10k .
|x|

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Let x = 0.33333 and x = 0.333, then the error


|x x | = 0.00033.
We say that x has three significant digits with respect to x.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Let x = 0.33333 and x = 0.333, then the error


|x x | = 0.00033.
We say that x has three significant digits with respect to x.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Let x = 0.33333 and x = 0.333, then the error


|x x | = 0.00033.
We say that x has three significant digits with respect to x.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Theorem 1
Let fl(x) be n floating-point representation of a real number
x and
x fl(x)
= ,
x
then
1

|| n+1 , if chopping is used

||

1 n+1
, if rounding is used.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Theorem 1
Let fl(x) be n floating-point representation of a real number
x and
x fl(x)
= ,
x
then
1

|| n+1 , if chopping is used

||

1 n+1
, if rounding is used.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Theorem 1
Let fl(x) be n floating-point representation of a real number
x and
x fl(x)
= ,
x
then
1

|| n+1 , if chopping is used

||

1 n+1
, if rounding is used.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Theorem 1
Let fl(x) be n floating-point representation of a real number
x and
x fl(x)
= ,
x
then
1

|| n+1 , if chopping is used

||

1 n+1
, if rounding is used.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Proof

We take
x = (0.d1 d2 d3 dn dn+1 ) e
then fl(x) when chopping is used is
fl(x) = (0.d1 d2 d3 dn ) e
We now consider the positive real number case. In case of
negative real number case there is no change in the sign of .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Proof

We take
x = (0.d1 d2 d3 dn dn+1 ) e
then fl(x) when chopping is used is
fl(x) = (0.d1 d2 d3 dn ) e
We now consider the positive real number case. In case of
negative real number case there is no change in the sign of .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Proof

We take
x = (0.d1 d2 d3 dn dn+1 ) e
then fl(x) when chopping is used is
fl(x) = (0.d1 d2 d3 dn ) e
We now consider the positive real number case. In case of
negative real number case there is no change in the sign of .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Proof

We take
x = (0.d1 d2 d3 dn dn+1 ) e
then fl(x) when chopping is used is
fl(x) = (0.d1 d2 d3 dn ) e
We now consider the positive real number case. In case of
negative real number case there is no change in the sign of .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Proof

We take
x = (0.d1 d2 d3 dn dn+1 ) e
then fl(x) when chopping is used is
fl(x) = (0.d1 d2 d3 dn ) e
We now consider the positive real number case. In case of
negative real number case there is no change in the sign of .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Calculating
x fl(x) = (0.000 0dn+1 ) e .
Let = 1, then
0 x fl(x) (0.000 0 ) e
h
i
= n1 + n2 + e
 n1 

e = n+e .
=
1 1

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Calculating
x fl(x) = (0.000 0dn+1 ) e .
Let = 1, then
0 x fl(x) (0.000 0 ) e
h
i
= n1 + n2 + e
 n1 

e = n+e .
=
1 1

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Calculating
x fl(x) = (0.000 0dn+1 ) e .
Let = 1, then
0 x fl(x) (0.000 0 ) e
h
i
= n1 + n2 + e
 n1 

=
e = n+e .
1 1

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Calculating
x fl(x) = (0.000 0dn+1 ) e .
Let = 1, then
0 x fl(x) (0.000 0 ) e
h
i
= n1 + n2 + e
 n1 

=
e = n+e .
1 1

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Now
0

x fl(x)
x

n+e
(0.d1 d2 dn dn+1 ) e
n
= n+1 .
(0.100 )

The second part is similar. Please try by your own.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Now
0

x fl(x)
x

n+e
(0.d1 d2 dn dn+1 ) e
n
= n+1 .
(0.100 )

The second part is similar. Please try by your own.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Now
0

x fl(x)
x

n+e
(0.d1 d2 dn dn+1 ) e
n
= n+1 .
(0.100 )

The second part is similar. Please try by your own.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagation of Errors

Propagated error in an arithmetic operations (+, , , /) occurs


due to approximate values of numbers taken by computer with
finite digits.
Let x and y are the true or exact values and x and y are the
corresponding approximate values respectively.
Then we have
x = x + ,

Computer Arithmetic and Different Types of Errors

y = y + .

Dr. P. Dhanumjaya

Propagation of Errors

Propagated error in an arithmetic operations (+, , , /) occurs


due to approximate values of numbers taken by computer with
finite digits.
Let x and y are the true or exact values and x and y are the
corresponding approximate values respectively.
Then we have
x = x + ,

Computer Arithmetic and Different Types of Errors

y = y + .

Dr. P. Dhanumjaya

Propagation of Errors

Propagated error in an arithmetic operations (+, , , /) occurs


due to approximate values of numbers taken by computer with
finite digits.
Let x and y are the true or exact values and x and y are the
corresponding approximate values respectively.
Then we have
x = x + ,

Computer Arithmetic and Different Types of Errors

y = y + .

Dr. P. Dhanumjaya

Propagation of Errors

Propagated error in an arithmetic operations (+, , , /) occurs


due to approximate values of numbers taken by computer with
finite digits.
Let x and y are the true or exact values and x and y are the
corresponding approximate values respectively.
Then we have
x = x + ,

Computer Arithmetic and Different Types of Errors

y = y + .

Dr. P. Dhanumjaya

Propagated Relative Error in Multiplication


We calculate
xy x y = xy (x )(y )
= x + y .
The relative error in multiplication is
rxy



xy x y
= +
xy
y
x
xy
= rx + ry rx ry .

For |rx |, |ry |  1 then


rxy rx + ry .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated Relative Error in Multiplication


We calculate
xy x y = xy (x )(y )
= x + y .
The relative error in multiplication is
rxy

xy x y



= +
xy
y
x
xy
= rx + ry rx ry .

For |rx |, |ry |  1 then


rxy rx + ry .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated Relative Error in Multiplication


We calculate
xy x y = xy (x )(y )
= x + y .
The relative error in multiplication is
rxy

xy x y



= +
xy
y
x
xy
= rx + ry rx ry .

For |rx |, |ry |  1 then


rxy rx + ry .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated Relative Error in Multiplication


We calculate
xy x y = xy (x )(y )
= x + y .
The relative error in multiplication is
rxy

xy x y



= +
xy
y
x
xy
= rx + ry rx ry .

For |rx |, |ry |  1 then


rxy rx + ry .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated Relative Error in Multiplication


We calculate
xy x y = xy (x )(y )
= x + y .
The relative error in multiplication is
rxy

xy x y



= +
xy
y
x
xy
= rx + ry rx ry .

For |rx |, |ry |  1 then


rxy rx + ry .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated Relative Error in Multiplication


We calculate
xy x y = xy (x )(y )
= x + y .
The relative error in multiplication is
rxy

xy x y



= +
xy
y
x
xy
= rx + ry rx ry .

For |rx |, |ry |  1 then


rxy rx + ry .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in division


The relative error in division is
rx
y

=
=
=

x
y

x
y

x
y
x
y

x
y

x
y

y x

.
xy 1 y

For |ry |  1 then


r x rx ry .
y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in division


The relative error in division is
rx
y

=
=
=

x
y

x
y

x
y
x
y

x
y

x
y

y x

.
xy 1 y

For |ry |  1 then


r x rx ry .
y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in division


The relative error in division is
rx
y

=
=
=

x
y

x
y

x
y
x
y

x
y

x
y

y x

.
xy 1 y

For |ry |  1 then


r x rx ry .
y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in division


The relative error in division is
rx
y

=
=
=

x
y

x
y

x
y
x
y

x
y

x
y

y x

.
xy 1 y

For |ry |  1 then


r x rx ry .
y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

For both multiplication and division, relative errors do not


propagate rapidly.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in addition and subtraction

The relative error in addition (subtraction) is


rxy

=
=

(x y) (x y )
x y
x x x
y y y

.
x
x y
y
x y

This gives
rxy = rx

x
y
ry
.
x y
x y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in addition and subtraction

The relative error in addition (subtraction) is


rxy

=
=

(x y) (x y )
x y
x x x
y y y

.
x
x y
y
x y

This gives
rxy = rx

x
y
ry
.
x y
x y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in addition and subtraction

The relative error in addition (subtraction) is


rxy

=
=

(x y) (x y )
x y
x x x
y y y

.
x
x y
y
x y

This gives
rxy = rx

x
y
ry
.
x y
x y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Propagated relative error in addition and subtraction

The relative error in addition (subtraction) is


rxy

=
=

(x y) (x y )
x y
x x x
y y y

.
x
x y
y
x y

This gives
rxy = rx

x
y
ry
.
x y
x y

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

The relative error in addition and subtraction


rxy
can be much larger than the relative error in x and y .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

The relative error in addition and subtraction


rxy
can be much larger than the relative error in x and y .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

The relative error in addition and subtraction


rxy
can be much larger than the relative error in x and y .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Let x = and x = 3.1416.


Similarly, we take y =

22
7

and y = 3.1429.

We have
x x 7.35 106 ,
y y 4.29 105 .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Let x = and x = 3.1416.


Similarly, we take y =

22
7

and y = 3.1429.

We have
x x 7.35 106 ,
y y 4.29 105 .

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The relative error in x and y respectively as


rx

2.34 106

ry

1.36 105 .

But the relative error in x y is


rxy 0.028.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The relative error in x and y respectively as


rx

2.34 106

ry

1.36 105 .

But the relative error in x y is


rxy 0.028.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The relative error in x and y respectively as


rx

2.34 106

ry

1.36 105 .

But the relative error in x y is


rxy 0.028.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The relative error in x and y respectively as


rx

2.34 106

ry

1.36 105 .

But the relative error in x y is


rxy 0.028.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

The relative error in x and y respectively as


rx

2.34 106

ry

1.36 105 .

But the relative error in x y is


rxy 0.028.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

The error in (x y ) is quite small but the relative error in


(x y ) is much larger than rx or ry alone.
When subtracting nearly equal quantities, it is possible to
have a large decrease in accuracy.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Note

The error in (x y ) is quite small but the relative error in


(x y ) is much larger than rx or ry alone.
When subtracting nearly equal quantities, it is possible to
have a large decrease in accuracy.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Cancellation (Loss of Significants)

This is due to subtraction of two nearby quantities.


Suppose, we want to find the roots of the quadratic polynomial
equation
ax 2 + bx + c = 0.
The roots are
x=

b2 4ac
.
2a

Assume b2 4ac > 0.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Find the roots of the quadratic polynomial equation


0.0501 x 2 98.78 x + 5.015 = 0,
using four digit floating point arithmetic with rounding.
Compare the computed roots with the given most accurate
roots
x = 1971.605916,
x = 0.05077069387.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Find the roots of the quadratic polynomial equation


0.0501 x 2 98.78 x + 5.015 = 0,
using four digit floating point arithmetic with rounding.
Compare the computed roots with the given most accurate
roots
x = 1971.605916,
x = 0.05077069387.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Find the roots of the quadratic polynomial equation


0.0501 x 2 98.78 x + 5.015 = 0,
using four digit floating point arithmetic with rounding.
Compare the computed roots with the given most accurate
roots
x = 1971.605916,
x = 0.05077069387.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Find the roots of the quadratic polynomial equation


0.2 x 2 47.91 x + 6 = 0,
using four digit floating point arithmetic with rounding.
Compare the computed roots with the given most accurate
roots
x = 239.4247,
x = 0.1253.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Find the roots of the quadratic polynomial equation


0.2 x 2 47.91 x + 6 = 0,
using four digit floating point arithmetic with rounding.
Compare the computed roots with the given most accurate
roots
x = 239.4247,
x = 0.1253.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Example

Find the roots of the quadratic polynomial equation


0.2 x 2 47.91 x + 6 = 0,
using four digit floating point arithmetic with rounding.
Compare the computed roots with the given most accurate
roots
x = 239.4247,
x = 0.1253.

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

THANK YOU...

Computer Arithmetic and Different Types of Errors

Dr. P. Dhanumjaya

Das könnte Ihnen auch gefallen