Homework 1

advertisement
COT4501 Spring 2012
Homework I
This assignment has seven problems and they are equally weighted. The assignment is
due in class on Tuesday, January 31, 2012.
Problem 1 Provide short answers to the following questions:
• True or false: Floating-point numbers are distributed uniformly throughout their
range.
• True or false: In a floating-point number system, the underflow level is the smallest
positive number that perturbs the number 1 when added to it.
• Suppose you are solving a given problem using a given algorithm. For each of the
following, state whether it is affected by the stability of the algorithm, and why.
1. Propagated data error,
2. Accuracy of the computed result,
3. Conditioning of problem.
• Give two reasons why floating-point number systems are usually normalized.
• In a p-digit binary floating-point system with rounding to nearest, what is the value
of the unit roundoff mach ?
• Give an example of a number whose decimal representation is finite (i.e., it has
only a finite number of nonzero digits) but whose binary representation is not.
Problem 2
• Using four-digit decimal arithmetic and the formula
A = 4πr2 ,
to compute the surface area of the Earth, with r = 6370 km (kilometer).
• Using the same formula and precision, compute the difference in surface area if
the value of the radius is increased by 1 km.
• Since dA/dr = 8πr, the change in surface area is approximated by 8πrh, where
h is the change in radius. Use this formula, still with four-digit arithmetic, to compute the difference in surface area due to an increase of 1 km in radius. How does
the value obtained using this approximate formula compare with that obtained
from the exact formula in Part 2 above?
1
• Determine which of the previous two answers is more nearly correct by repeating
both computations using higher precision, say six-digit decimal arithmetic.
Problem 3 For computing the midpoint m of an interval [a, b], which of the following
two formulas is preferable in floating-point arithmetic? Why?
• m = (a + b)/2.0,
• m = a + (b − a)/2.0.
(Hint: Devise examples for which the midpoint given by the formula lies outside the
interval [a, b].)
Problem 4
• How many normalized machine numbers are there in a single-precision IEEE
floating-point system? How many additional machine numbers are gained if subnormals are allowed?
• In a single-precision IEEE floating-point system, what are the values of the largest
machine number, OFL, and the smallest positive normalized machine number,
UFL? How do your answers change if subnormal are allowed?
Problem 5
• What is the IEEE single-precision binary floating-point representation of the decimal fraction 0.1 a) with chopping? and b) with rounding to the nearest?
• In a floating-point system, is the unit roundoff mach necessarily a machine number?
• Is it possible to have a floating-point system in which mach < UFL? If so, give an
example.
Problem 6 Assume that you are solving the quadratic equation ax2 + bx + c = 0,
with a = 1.22, b = 3.34, and c = 2.88, using a normalized floating-point system with
β = 10, p = 3.
• What is the computed value of the discriminant b2 − 4ac?
• What is the correct value of the discriminant in real (exact) arithmetic?
• What is the relative error in the computed value of the discriminant?
Problem 7 Assume a normalized floating-point system with β = 10, p = 3 and L =
−98.
2
• What is the value of the underflow level UFL for this system?
• If x = 6.87 × 10−97 and y = 6.81 × 10−97 , what is the result of x − y?
• What would be the result of x − y if the system permitted gradual underflow?
3
Download