From: mcdonald@aries.scs.uiuc.edu (J. D. McDonald)
Subject: Re: NO NUMBERS! (or even SHORT INTS!)
Organization: UIUC SCS
Date: Sat, 3 Oct 1992 23:22:51 GMT

In article <1992Oct3.173435.417@mnemosyne.cs.du.edu> jcastner@nyx.cs.du.edu (John Castner) writes:

>In article <kaufman.718082916@Xenon.Stanford.EDU> kaufman@CS.Stanford.EDU writes:
>>How about the following:
>>
>>GMST = 24110.54841 + (8640184.812866 + (0.093104 - 6.2e-6 * Tu) * Tu) * Tu;
>>
>>which is the equation for the relationship between Greenwich mean sidereal
>>time and Universal time. (or was in 1985).  I could also post the equation
>>for the nutation of the Moon, which has 19 terms.  Surely you don't expect
>>someone to define constants for each of them...

>I would guess that if you were writing a program with this expression, you
>would be likely to need these numbers again.  Even if you didn't need
>them anywhere else, constants would be nice.  Or better yet, since these
>numbers had to come from some equation, probably other than this one,
>compute them from more basic numbers like the length of the sidereal year
>in seconds. (Plus, of course, a user entered value like the number of
>leap seconds added so far this year.  :)  But I would never use numbers
>like these as literal constants.  0, 1, 2, and traditional values like
>XSub1, YSub1, XSub2, and YSub2 (for a distance formula) are as far as I go.

>Of course, I don't know the meaning of the values in this expression
>(since someone forgot to comment them!  :), so I could be wrong.
>Still, they shouldn't be in the program statements like that.
>--


OK look at this, which, like the nutation of the moon, is a better example:

#include <math.h>
#include "astro.h"
/* ....jupiter */
p_jupiter (t, s, dml, ds, dm, da)
double t, s;
double *dml, *ds, *dm, *da;
{
	double dp;
	double x1, x2, x3, x4, x5, x6, x7;
	double sx3, cx3, s2x3, c2x3;
        double sx5, cx5, s2x5;
	double sx6;
        double sx7, cx7, s2x7, c2x7, s3x7, c3x7, s4x7, c4x7, c5x7;
	aux_jsun (t, &x1, &x2, &x3, &x4, &x5, &x6);
        x7 = x3-x2;
	sx3 = sin(x3);
	cx3 = cos(x3);
        s2x3 = sin(2*x3);
	c2x3 = cos(2*x3);
        sx5 = sin(x5);
	cx5 = cos(x5);
        s2x5 = sin(2*x5);
	sx6 = sin(x6);
        sx7 = sin(x7);
	cx7 = cos(x7);
        s2x7 = sin(2*x7);
	c2x7 = cos(2*x7);
        s3x7 = sin(3*x7);
	c3x7 = cos(3*x7);
        s4x7 = sin(4*x7);
	c4x7 = cos(4*x7);
        c5x7 = cos(5*x7);
	*dml = (3.31364e-1-(1.0281e-2+4.692e-3*x1)*x1)*sx5+
	      (3.228e-3-(6.4436e-2-2.075e-3*x1)*x1)*cx5-
	      (3.083e-3+(2.75e-4-4.89e-4*x1)*x1)*s2x5+
	      2.472e-3*sx6+1.3619e-2*sx7+1.8472e-2*s2x7+6.717e-3*s3x7+
	      2.775e-3*s4x7+6.417e-3*s2x7*sx3+
	      (7.275e-3-1.253e-3*x1)*sx7*sx3+
	      2.439e-3*s3x7*sx3-(3.5681e-2+1.208e-3*x1)*sx7*cx3;
        *dml += -3.767e-3*c2x7*sx3-(3.3839e-2+1.125e-3*x1)*cx7*sx3-
	      4.261e-3*s2x7*cx3+
	      (1.161e-3*x1-6.333e-3)*cx7*cx3+
	      2.178e-3*cx3-6.675e-3*c2x7*cx3-2.664e-3*c3x7*cx3-
	      2.572e-3*sx7*s2x3-3.567e-3*s2x7*s2x3+2.094e-3*cx7*c2x3+
	      3.342e-3*c2x7*c2x3;
	*dml = degrad(*dml);
	*ds = (3606+(130-43*x1)*x1)*sx5+(1289-580*x1)*cx5-6764*sx7*sx3-
	     1110*s2x7*sx3-224*s3x7*sx3-204*sx3+(1284+116*x1)*cx7*sx3+
	     188*c2x7*sx3+(1460+130*x1)*sx7*cx3+224*s2x7*cx3-817*cx3+
	     6074*cx3*cx7+992*c2x7*cx3+
	     508*c3x7*cx3+230*c4x7*cx3+108*c5x7*cx3;
	*ds += -(956+73*x1)*sx7*s2x3+448*s2x7*s2x3+137*s3x7*s2x3+
	     (108*x1-997)*cx7*s2x3+480*c2x7*s2x3+148*c3x7*s2x3+
	     (99*x1-956)*sx7*c2x3+490*s2x7*c2x3+
	     158*s3x7*c2x3+179*c2x3+(1024+75*x1)*cx7*c2x3-
	     437*c2x7*c2x3-132*c3x7*c2x3;
	*ds *= 1e-7;
	dp = (7.192e-3-3.147e-3*x1)*sx5-4.344e-3*sx3+
	     (x1*(1.97e-4*x1-6.75e-4)-2.0428e-2)*cx5+
	     3.4036e-2*cx7*sx3+(7.269e-3+6.72e-4*x1)*sx7*sx3+
	     5.614e-3*c2x7*sx3+2.964e-3*c3x7*sx3+3.7761e-2*sx7*cx3+
	     6.158e-3*s2x7*cx3-
	     6.603e-3*cx7*cx3-5.356e-3*sx7*s2x3+2.722e-3*s2x7*s2x3+
	     4.483e-3*cx7*s2x3-2.642e-3*c2x7*s2x3+4.403e-3*sx7*c2x3-
	     2.536e-3*s2x7*c2x3+5.547e-3*cx7*c2x3-2.689e-3*c2x7*c2x3;
	*dm = *dml-(degrad(dp)/s);
	*da = 205*cx7-263*cx5+693*c2x7+312*c3x7+147*c4x7+299*sx7*sx3+
	     181*c2x7*sx3+204*s2x7*cx3+111*s3x7*cx3-337*cx7*cx3-
	     111*c2x7*cx3;
	*da *= 1e-6;
}

Considering the name of the subroutine, you can guess pretty well what they 
are for. They are the lowest terms in the series expansion for the orbit of 
Jupiter. 

They come from a standard theory that is decades old. It is not going
to change, ever. If, for some reason, such as a perturbing star passing
nearby, the orbit changes, it's going to need a new theory.

Any names you give to these terms are going to be about as meaningful as
the ones I have assigned to the temporary variables. Sure, I could
assign more verbose names to those variables .... but who cares. The
meaning of the variables in the subroutine parameters are indeed
documented in the calling routine.

Oh yes. This is the **simplified** version. And there are several more 
planets. We're talking about whole books of constants: Astronomical Formulae 
for Calculators by Jean Meeus.  Richmond, Va., U.S.A., Willmann-Bell, 
1982 and Astronomy with your Personal Computer by Dr. Peter Duffett-
Smith, Cambridge University Press, 1985. 

Frankly, I'm not worried about what to call them or that they are hard
coded. I was **seriously** worried that they were wrong until I verified
the output versus published values. If they are wrong, it is within
the noise of my output and/or the published values are wrong too.


Doug McDonald