next up previous
Next: About this document ...

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

    \begin{displaymath}
x^2 - 4999x + 1 = 0
\end{displaymath}

    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. $\star$ As an example of an unstable algorithm, consider integer powers of the ``Golden Mean'' $\phi = (\sqrt{5} - 1)/2$. It can be shown that $\phi^{n+1} = \phi^{n-1} - \phi^n$, i.e. successively higher powers of $\phi$ 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 $n$, $\phi^n$ computed from the recursion relation, and $\phi^n$ computed directly (i.e. $\phi^n = \phi\phi^{n-1}$), for $n$ 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
    \begin{displaymath}
\mathbf{L} = \sum_i m_i (\mathbf{r}_i \mbox{\boldmath$\times$}\mathbf{v}_i) = \mathbf{I}
\mbox{\boldmath$\omega$},
\end{displaymath} 1
    where $m_i$ is the mass of particle $i$, $\mathbf{r}_i$ and $\mathbf{v}_i$ are its position and velocity vectors with respect to the centre of mass, $\mbox{\boldmath$\omega$}$ is the spin vector, and $\mathbf{I}$ is the inertia tensor

    \begin{displaymath}
\mathbf{I} = \sum_i m_i (r_i^2 \mathbf{1} - \mathbf{r}_i \mathbf{r}_i),
\end{displaymath}

    where $\mathbf{1}$ 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 $m_i$'s can be omitted entirely since the particles are identical.] Write a program to solve Eq. (1) for $\mbox{\boldmath$\omega$}$ (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 $2\pi/\vert\mbox{\boldmath$\omega$}\vert$.

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

    2. $\star$ 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.




next up previous
Next: About this document ...
Derek C. Richardson 2005-03-02