0% found this document useful (0 votes)
49 views4 pages

CSE213 - Numerical Analysis Sheet 1 - Error Analysis To Be Submitted On The 25 of February

This document contains numerical analysis problems related to error analysis, floating point representations, and propagation of errors in calculations. It discusses absolute and relative errors, truncation error, representing numbers in a hypothetical machine, chopping error, converting numbers to normal form, and techniques to reduce errors like adding numbers in order of magnitude and avoiding bad subtractions.

Uploaded by

Rewan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

CSE213 - Numerical Analysis Sheet 1 - Error Analysis To Be Submitted On The 25 of February

This document contains numerical analysis problems related to error analysis, floating point representations, and propagation of errors in calculations. It discusses absolute and relative errors, truncation error, representing numbers in a hypothetical machine, chopping error, converting numbers to normal form, and techniques to reduce errors like adding numbers in order of magnitude and avoiding bad subtractions.

Uploaded by

Rewan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CSE213 - Numerical Analysis

Sheet 1 - Error Analysis To be Submitted on the 25th of February

1. Absolute and Relative Errors: If x is the exact value and x* is the approximate
value, calculate the absolute and relative errors when
a. x = 10.147, x* = 10.159
b. x = 0.0047, x* = 0.0045
c. x = 671000, x* = 669000

2. Truncation Error: Use only the first 3 terms of the series

sin(x) = ∑ −1 ( )!

to evaluate sin ( ) and then find the truncation error.

3. Hypothetical Machine: Consider a hypothetical digital computer in which the


binary representation of a real number is: (1) (001) (11010), where (001)
corresponds to the Exponent, and (11010) corresponds to the Mantissa. Find:
a. The values of the parameters L, U, p, and b.
b. The representation (in base 10) of the given binary representation.
c. The absolute error resulting from the operation: 1.75 – 0.1875
d. The Maximum and Minimum decimal values that can be represented by the
given machine.
e. How many different numbers are in this floating point system?

Page 1
4. Verify that the chopping error resulting from calculating (1.0⁄6.0) to 2 significant
digits will cause that (1.0⁄6.0) ∗ 6.0 ≠ 1.0. Verify that when ( 1.0⁄6.0 ) is
approximated to 5 decimal digits, the result of (1.0⁄6.0) ∗ 6.0 will be 0.9996.

5. The critical part of floating-point operations is the potential loss of correct digits in
the significand. Consider a computer model that uses 4 digits for the significand, 1 digit
for the exponent plus an optional sign for both the significand and the exponent, any
real number 'a' may be written as a normalised decimal number a×10n, where the
number 'a' is in the range [0.1, 1) and is called the significand, while the integer n is
called the exponent.
Convert the following numbers to normal form and perform the required operation:
a = 42.34 and b = 0.0033, calculate a+b
a = 10.34 and b =-10.27, calculate a+b
a = 10/7 and b =-1.42, calculate a+b
a = 23.57 and b =-6.759, calculate a*b and a/b

6. Consider the simple algorithm


x = 0.0;
while x ≠ 1.0
print x
x = x +0.1;
Implement the algorithm in a program and check what values of x will be printed?
Explain what happened.

7. The following Python program shows the effect of the propagation of an initial
representation error which results in final (large!) error. Run the program, print its
results once for k in range(10) and in range(30). Comment on the obtained results.

a=[]
for n in range ( 1 ,11) :
x=1/n
for k in range(30) :
x=(n+1)*x-1
a . append ( x )
print(a)

Page 2
8. Errors in Computer Arithmetic
In order to reduce the chance of large errors occurring in calculations, here are some
tips that you should consider:

i. In general, it is better to add ‘floating-point’ numbers in order of magnitude if


possible. For example, suppose we compute
0.273000+0.001480+0.000862 (=0.275342).
If results are stored with mantissas 3 digits long; then,
0.273000 + 0.001480 = 0.274480 → 0.274000 and
0.27400 + 0.000862 = 0.274862 → 0.274000
whereas
0.000862 + 0.001480 = 0.002342 → 0.002340 and
0.002340 + 0.27300 = 0.275340 → 0.275000

ii. In order to prevent ‘loss of significance’, it is important to avoid a ‘bad subtraction’


that is, a subtraction of a number from another number having almost equal value. Let
us consider a simple problem of finding the roots of a second-order equation
ax2 + bx +c=0 by using the formulas:

Assuming the Discriminant: b2 – 4ac > 0, then depending on the sign of b, a “bad
subtraction” may be encountered when we try to find the smaller one of the two roots.
This implies that it is safe, from the “loss of significance” point of view, to compute the
root having the larger absolute value first and then obtain the other root by using the
relation (between the roots and the coefficients) x1 x2= c/a.

a) Apply this technique to solve the equation x2 + 62.10 x + 1 = 0 whose roots are
Approximately : x1 = -0.01610723 and x2= -62.08390. Check the relative errors
in the obtained roots (using four-digit rounding arithmetic) in case of finding both
roots using the formulas and the case of avoiding "bad subtraction".

b) Apply the idea of rationalizing the numerator of the quadratic formula to obtain a
more accurate four-digit rounding approximation for x1:

Page 3
iii. In consecutive multiplication/division processes, make the intermediate result as
close to one as possible. According to this rule, when computing xy/z, we program the
formula as
 (xy)/z when x and y in the multiplication are very different in magnitude,
 x(y/z) when y and z in the division are close in magnitude, and
 (x/z) y when x and z in the division are close in magnitude.

For instance, when computing y n/ en x with x >1 and y >1, we would program it
as (y/ex)n rather than as y n/ en x , so that overflow/underflow can be avoided. Verify this
using Excel/ Python/ Matlab for the case:
x = 36; y = 1e16; for n = {-20, -19, 19, 20}.

Page 4

You might also like