next up previous
Next: Code Listings & Output

ASTR415 Spring 2007 Problem Set #2


Solution


  1. My code listing is given at the end, with output for single and double precision (the macro FLOAT is used to choose precision). In the single precision case, the smaller root as computed from the quadratic formula differs from that computed from the larger root because the discriminant $b^2 - 4ac$ nearly equals $b^2$. The resulting subtraction in the formula introduces round-off error at the 20% level. With double precision the round-off error is greatly reduced.

  2. My code listing is given at the end, with output for single and double precision (the macro FLOAT is used to choose precision). The round-off error in the recursion formula is not random: it oscillates with steadily increasing amplitude above and below the correct solution. With double precision the round-off error is greatly reduced in the specified range for $n$.

  3. My code listing is given at the end. The code reads in the specified data file in double precision until EOF is reached (or the arrays are full). The center-of-mass position and velocity is subtracted from each particle and the total angular momentum and inertia tensor are computed. The single-precision NRiC function gaussj() is used to solve for the spin vector, which is then converted into a spin period in hours.

    1. Analysis of the supplied file is given at the end. The spin period is 4.30458 h.

    2. Views projected along the Cartesian axes are given at the end, along with the sm script used to generate them.




next up previous
Next: Code Listings & Output
Massimo Ricotti 2007-02-12