Next: Code Listings & Output
ASTR415 Spring 2007 Problem Set #2
Solution
- 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
nearly equals
. The
resulting subtraction in the formula introduces round-off error at
the 20% level. With double precision the round-off error is
greatly reduced.
- 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
.
- 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.
- Analysis of the supplied file is given at the end. The spin
period is 4.30458 h.
- Views projected along the Cartesian axes are given at the end,
along with the sm script used to generate them.
Next: Code Listings & Output
Massimo Ricotti
2007-02-12