Astronomy Answers: Calculate Astronomical Things

Astronomy Answers
Calculate Astronomical Things


[Astronomy Answers] [Dictionary] [AnswerBook] [Universe Family Tree] [Science] [Starry Sky] [Planet Positions] [Calculate] [Colophon]

You can calculate various astronomical things yourself:

The formulas that I give on the mentioned pages are mathematical formulas. To be able to use them in computer programs you need to take into account how those computer languages and compilers work. For example, if you copy the formula \( 4000*s/1461001 \) (with \( s \) a whole number) without changes into a program that can handle whole numbers only, then the result can depend on the order in which the calculations are done, because in such a program the intermediate results can only be whole numbers, too, and any fractional parts are discarded. If intermediate results are too large, then parts of them can be discarded as well, and then the results won't fit the mathematical results, either.

Suppose that \( s = 400 \). Then the mathematical result is \( 4000*400/1461001 = 1600000/1461001 = 1 + 138999/1461001 \). If this is calculated in a program that can handle whole numbers only, and if the multiplication is performed first, then the intermediate result is \( 4000*s = 1600000 \) and the second calculation \( 1600000/1461001 \) then yields the end result 1, because the fractional part of the result is discarded. If the division is done first, then the first calculation is \( s/1461001 = 400/1461001 \) which yields 0, because the remainder of the division is discarded. The second calculation is then \( 0*4000 = 0 \) so the end result is 0. The end result depends on the order in which the calculations are done.

Many astronomical formulas involve angles. If you turn around once and end up facing in the same direction, then you've swung through an angle of 360 degrees. So, two directions that differ by a multiple of 360 degrees are equivalent, and you can always reduce any angle to an equivalent angle that is between 0 and 360 degrees, by subtracting a suitable multiple of 360 degrees. For example, an angle of 19462.44 degrees can be reduced to the equivalent angle of 22.44 degrees. The difference between the two is 19440 degrees, which is exactly 54 times 360 degrees.

One way to do that is as follows:

In a computer program, you'd use the "modulus" function or operator, something like 19462.44 % 360 or 19462.44 mod 360, or mod(19462.44, 360).



[AA]

languages: [en] [nl]

//aa.quae.nl/en/reken.html;
Last updated: 2021-07-19