trying to compute moon illumination percent from moon day.

To get moon day in pseudo code I do:

LUNAR_MONTH = 29.530588853
KNOWN_NEW_MOON = JulianDay("2000-01-06 06:14")
age = (julian_day_now - KNOWN_NEW_MOON).abs % LUNAR_MONTH

So that shows me right now an age of 10.9 days. How do I tell percent illumination?

  • 2
    $\begingroup$ This computes the moon illumination given a date: celestialprogramming.com/… $\endgroup$ Jan 3, 2023 at 0:18
  • 1
    $\begingroup$ @GregMiller, glad that you see my question! I would be happy if you can answer my question on stackoverflow. I saw your page but I have no idea what it does. const T=(jd-2451545)/36525.0; - what is this? Lets assume I don't care so much to understand all other constants but I'd like to calculate this according to the method I use to get julian day. Otherwise I'm not sure whether my julian day is same as yours. $\endgroup$ Jan 3, 2023 at 10:35
  • 1
    $\begingroup$ @akostadinov, that line computes the number of Julian centuries since J2000. The "jd" is the standard Julian date, and the big number is the Julian date for Jan 1, 2000. The linked page also has routines for computing the Julian date, so you can use those if you're concerned. $\endgroup$ Jan 3, 2023 at 17:22
  • 2
    $\begingroup$ @akostadinov I added a bounty to attract an answer. If it turns out you've solved the problem and feel up to writing it up as an answer, please feel free to do so. $\endgroup$
    – uhoh
    Apr 5, 2023 at 3:31
  • 2
    $\begingroup$ @uhoh, I didn't post a solution here because I've got (and needed) a computer algorithm. That I've got and posted to stackoverflow. Also Greg has such in another language. I think an answer worth this site would be more theoretical math how to do it and not just pasting a magic algorithm that works reasonably well. I will be interested to see such an answer. Also referring to some app and not explaining how it works is also a non-answer imho. $\endgroup$ Apr 5, 2023 at 14:17

1 Answer 1


The algorithm below produces the fraction of moon illumination based on the Julian Day (rather than the moon age). It is from Meeus' Astronomical Algorithms Second Edition chapter 48.

$$ \begin{align} D &= 297.8501921 + 445267.1114034T - 0.0018819T^2 + \frac{1}{545868.0}T^3 - \frac{1}{113065000.0}T^4 \\ M &= 357.5291092 + 35999.0502909T - 0.0001536T^2 + \frac{1}{24490000.0}T^3 \\ M' &= 134.9633964 + 477198.8675055T + 0.0087414T^2 + \frac{1}{69699}T^3 - \frac{1}{14712000.0}T^4 \\ i &= 180 - D - 6.289 \sin M' + 2.1 \sin M -1.274 \sin(2D - M') -0.658 \sin 2D -0.214 \sin 2M' -0.11 \sin D \\ k &= \frac{1 + \cos i}{2} \end{align} $$

Where $T$ is the number of Julian centuries since J2000: $T=(jd-2451545)/36525.0$. And $k$ is the fraction (from 0.0 to 1.0) of the moon (approximated as a perfect sphere) which is illuminated as viewed from the Geocenter.

$D$, $M$, $M'$ are the Delaunay arguments. Respectively the Moon's mean elongation, the Sun's mean anomaly, and the Moon's mean anomaly.

Here is an example implementation in JavaScript.

As far as an explanation of what all of the contants, etc mean... Sadly there is no deep dark secret explanation guarded by mythical creatures in funny hats who require you to solve puzzles to enter their chamber. Rather, they're just a least squares fit to observations to find the coefficients $a_i$ of a function of the form: $$ f(x) = a_1f_1(x) + a_2f_2(x) + a_2f_2(x) + ... a_if_i(x) $$

For the Delaunay arguments, $f_i(x)$ are just the powers of $T$.

For $i$ the $f_i(x)$ are trig functions of integer multiples of the Delaunay arguments. This method has been used in many ephemeris algorithms, most notably VSOP87. Again, it might seem like there's a deep scientific method involved in figuring out which ones to use. But as described in "Synthetic representation of the Galilean satellites' orbital motions from L1 ephemerides", it's largely a matter of performing a Fourier transform to find good candidates, then trying almost every integer multiple of each argument and just picking the one which fits the observations best. Which solution to pick is largely a balance between computational complexity and accuracy over a desired time frame.

  • 2
    $\begingroup$ Despite being disappointed by the lack of involvement of mythical creatures, thank you very much for the explanation! And for adding some more info on your web site. It would have taken me enormous amout of time to implement based on the theory. $\endgroup$ Apr 6, 2023 at 17:58
  • 2
    $\begingroup$ Can I check - the T³ and T⁴ I would expect them to be in the numerator of the fractions, not the denominator. Are the formulas correct? Is that a typo? $\endgroup$
    – James K
    Apr 7, 2023 at 8:23
  • 2
    $\begingroup$ @JamesK You're correct, thanks. I have edited the post. $\endgroup$ Apr 7, 2023 at 13:21
  • 2
    $\begingroup$ Well pointed out! Jean Meeus's clever shortcut formulae for the illuminated fraction of the moon's disk deserve to be better known, I think. It might also be worth mentioning (because occasionally people express doubts about it), that the illuminated fraction of the diameter (taken to cut the crescent etc halfway between the moon's 'horns') is the same as the illuminated fraction of the disk area because the crescent is of ellipse form and the projection of circle on to ellipse preserves such area-ratios. It's a good algorithm. $\endgroup$
    – terry-s
    Apr 7, 2023 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .