ASTR415/688C Spring 2005 Problem Set #2

Due March 8, 2005

Topics for this problem set include round-off error and linear algebra.

1. Write a program that uses the quadratic formula to compute both roots of

in single precision. The program should also recompute the smaller root from the larger, using the fact that the product of the roots must equal 1 in this case. Explain any discrepancy. Which method is preferable? What happens when you repeat this exercise in double precision?

2. As an example of an unstable algorithm, consider integer powers of the Golden Mean'' . It can be shown that , i.e. successively higher powers of can be computed from a single subtraction rather than a more expensive multiply. Write a single-precision program to compute a table consisting of the columns , computed from the recursion relation, and computed directly (i.e. ), for ranging from 1 to 20. Is the round-off error random? What happens in double precision?

3. Write a program to compute the instantaneous spin period of a rigid body made up of identical, discrete, point particles. Use the fact that the angular momentum is
 1
where is the mass of particle , and are its position and velocity vectors with respect to the centre of mass, is the spin vector, and is the inertia tensor

where is the unit matrix. [For continuous bodies the summations are replaced by volume integrations and the particle masses become a mass density. In the present case the 's can be omitted entirely since the particles are identical.] Write a program to solve Eq. (1) for (feel free to use the routines in Numerical Recipes). [On the department machines, look in /local/src/lib/NumRecC/ for C or NumRecF/ for FORTRAN. Warning: In C, remember NR's funny array indexing convention...] The spin period is then .

1. Test your code by reading the data file
http://www.astro.umd.edu/~dcr/Courses/ASTR415/ps2.dat
which is in the format (i.e. 6 values to a line separated by white space). The units are mks (SI). What is the spin period in hours?

2. Make a graphical representation of the body using your favorite graphing package. If you use 2-D projections, be sure to include enough viewing angles to get a complete picture.