Moon Phase formula - updated

I have cited my sources in the other discussions (on this forum).

Also, I developed a (cumbersome but) more accurate algorithm and used that to validate the above (lunar simplex v0.5).

2 Likes

Thanks for the quick reply Andrew.

I will look up your previous posts.

Just for your info, here is a reference to a study titled “The length of the Lunar Cycle” by I. Bromberg : https://individual.utoronto.ca/kalendis/lunar/index.htm

In it he, amongst many other things, examines the variation in the lunar cycle over many thousands of lunations and at one point determines a mean value reference for the new moon as January 6, 2000 at 14:20:44 TT. ( which might be another good reference to use ).

Anyway, I have found the exercise quite interesting and I will look up you previous work - thanks for sharing.

Cheers
Mike

ps. The USNO gives the time of the new moon on Jan 7, 1970 as 20:35 concurring with yours. I will have to redo my table of predicted times for the next 10yrs using data from them.

I reproduced my spreadsheet using 20 years of data ( staring March 2019 ) from the US Naval Observatory ( https://aa.usno.navy.mil/data/docs/MoonPhase.php ).

Solving for X in the formula: ((((#DNOW#-X)/86400000))%29.530588), such that the Root Mean Square of the prediction error was a minimum, resulted in a value for X of

lunation start time = X = 582,481,649

The graph below shows the prediction error ( in days ) for the next 20 years of full moons based on two values of the offset.

Not surprisingly, due to the way X was determined, using the value above resulted in a zero mean error ( that is half the time the error is positive and half it is negative, cancelling to zero ).

Alternatively, I think unless one chooses a particular actual new moon so that it is near to the zero point in its cycle, using it as the lunation start will result in a fixed offset.

Now solving instead for X, such that the RMS error of the dates of all phases for next twenty years was minimum produced a slightly different solution:

X = 583,104,471

A massive 10 minute difference :grinning:

1 Like

I have produced a more complex approximation for moon phase that does not require the inverse tangent function. It is empirical, that is, there is no one-to-one relationship with a physical model ( at least not one I am aware of :slight_smile: ). It was produced by taking the simple model and adding sine waves to it ( I ended up with three ). The initial choice of amplitude, frequency and phase was made by looking at the error curve for the simple model ( versus the next 20 years of moon phase data from the USNO site ) and trying to fit sine waves to it. This was followed by a tedious process in EXCEL of solving for each variable over and over again until all variables converged.

Anyway, here is the formula:=

Moon Phase:
"(((#DNOW#-583084344)/2551442802)+0.005843543sin(((#DNOW#-583084344)/5022920569)+3.23423)+0.0175542sin(((#DNOW#-583084344)/378924049))-0.003826534sin(((#DNOW#-583084344)/437400425)+2.99521)-
floor(((#DNOW#-583084344)/2551442802)+0.005843543
sin(((#DNOW#-583084344)/5022920569)+3.23423)+0.0175542sin(((#DNOW#-583084344)/378924049))-0.003826534sin(((#DNOW#-583084344)/437400425)+2.99521)))
"

The output is a number that continuously increases between 0 and 1;
where:
0 => new moon,
0.25 =>1st qtr,
0.5 => full,
0.75 => 3rd qtr.

Note that the actual meat of the formula is only half of the above, the rest is needed to convert the “lunation” number ( in the form of say, 680.2723 ) to the phase ( 0.2723 ).

For comparison, the equivalent simple equation is:

“(((#DNOW#-583084344)/2551442802)-floor(((#DNOW#-583084344)/2551442802)))”

Now, how do they compare …

The graph shows the error ( in hours ) between the predictions from the models and the “true” phase at that time. The “true” phase data comes from the US Naval Observatory site. { note that the analysis is only based on data for new moon, 1st qtr, full moon and 3rd qtr as I could not find a source for reliable intermediate phases - the upshot of this is that the errors between the phases is unknown for both models. }

The red curve is the error for the simple model and the blue for the complex.

In terms of numbers:

Simple model:
Max error: 19.32 hours
Average magnitude of error: 8.15 hours

Complex model:
Max error: 1.28 hours
Average magnitude of error: 0.36 hours

Both have a total average error of zero. ( That is, half the time the error is negative and half the time positive without a constant offset. )

The difference between the models is, I believe, not significant for the purpose of displaying a moon phase image - the visual difference of the moon over a number of hours as viewed on a small watch is not great.

However, for the purpose of showing moon orbiting around the face of a watch, the difference becomes more significant as one places the moon further from the centre of rotation. At the watch edge the difference will, at times, be noticeable. How noticeable will depend on the particular implementation.

1 Like

I think the expressions will work with the MOD function ( % ) instead of FLOOR - thus simplifying the expressions to:

complex:

((((#DNOW#-583084344)/2551442802)+0.005843543sin(((#DNOW#-583084344)/5022920569)+3.23423)+0.0175542sin(((#DNOW#-583084344)/378924049))-0.003826534*sin(((#DNOW#-583084344)/437400425)+2.99521))%1)

Simple:

(((#DNOW#-583084344)/2551442802)%1)

I have kept working on trying to further reduce the error ( just because :slight_smile: ) …

This is it for now:

Phase =

(((#DNOW#/2551442844-0.228535)
+0.00591997sin(#DNOW#/5023359217+3.1705094)
+0.017672776
sin(#DNOW#/378923968-1.5388144)
-0.0038844429sin(#DNOW#/437435791+2.0017235)
-0.00041488
sin(#DNOW#/138539900-1.236334))%1)

The result is a real number in the range 0 to 1, where 0 means the moon is new, 0.5 means it is full, etc.

The maximum error has reduced by about 20% to around 60 minutes. During the next 20 years, the formula will give a result that is within 20 minutes of the true phase a little over half the time ( the rest somewhere between 20 and 60 minutes ). { Again note that this error data only relates to four points in the cycle (new moon, 1st qtr, full and 3rd qtr) and I have no way of determining the error in between these points. }

1 Like

Very good work. Just tested your formula with a rotational version, compared to the astronomical calendar and it works nearly perfect.

Formula modified for the rotational:

(((((#DNOW#/2551442844-0.228535)+0.00591997 * sin(#DNOW#/5023359217+3.1705094)+0.017672776 * sin(#DNOW#/378923968-1.5388144)-0.0038844429 * sin(#DNOW#/437435791+2.0017235)-0.00041488 * sin(#DNOW#/138539900-1.236334))%1) * 360)/2)

In following example i used shadowmaps and the formula should be modified/reversed to:

((((((#DNOW#/2551442844-0.228535)+0.00591997 * sin(#DNOW#/5023359217+3.1705094)+0.017672776 * sin(#DNOW#/378923968-1.5388144)-0.0038844429 * sin(#DNOW#/437435791+2.0017235)-0.00041488 * sin(#DNOW#/138539900-1.236334))%1) * 360)/2)*-1)

Greetings, GAUSS.

1 Like

Cool - I’m glad you were able to confirm that it works.

2 Likes

Hello to all, I am an astrology student, currently trying to use some excel funtions toi calculate the moon face with a spreadsheet, I have little knowledge of excel so no almost nothing of programming, I was looking for an answer on the internet and saw your interesting posts. Could your fprmulas be used with excel to calculate the moon phase?

Regards

1 Like

Welcome to the Facer.community group !!! @greyhound.racing.tip

This is a group where you can meet designers, programmers, and many good people, who can help you with your questions and ideas that you need …

For now with your question …
I tell you that Facer has its individual programming, by which it can be programmed, only in its program.
Here I show you the page, with which you can program …

Facer.io :point_left:

Because it has its own commands for your program. Here I show you the pages where you can see what kind of commands …

Tags :point_left:

Expressions :point_left:

Conditionals :point_left:

Boolean logic :point_left:

Weather condition icon codes :point_left:

I, many years ago (in the years 1998 to 2000), I did some programming with Excel. And as far as I know, Excel also has its individual programming, just for Excel.
After so many years, of not programming with Excel … I don’t know, how is the programming.
It may be that it has a more global form of programming. Java style and level …

Me too, I really like the subject of Astrology… :slightly_smiling_face: It is very important to have and know the “tables of the Ephemerides”
Here I found you, a little information, so you can see

Ephemerides :point_left:

Times of Ephemerides :point_left:

Astronomical epoch :point_left:

Having an information, the year of birth of a person. And also having the table of the Ephemeris … One can know the location of the planets, with the position of the Moon with the Sun. And from there, you can give information on the character, and way of being, of that person … Knowing also the energetic influences of each planet and distances …

I believe that, knowing well a programming program and the mathematics of astrology with the ephemeris table,
You can make a very nice and interesting program …
I have never tried to do it so far

Surely, someone from this group will also join your question, and give you more information, so that you can get an idea with your question.

I hope I can have helped you with your question…

I wish you enjoy the group
Cordially ! JDCardozo

1 Like

Thank you very much for your kind reply, also thank you for your information on the subject. I will keep looking my friend!

Regards

1 Like

You’re welcome @greyhound.racing.tip
For me it was a pleasure to help you :slightly_smiling_face:
Cordialmente

I was able to recreate the formulas in this post in Excel if you still need that.

Hi @mikeoday
I doubt that you are a relative of Einstein :thinking:
You really did a hard work. Too tall for my abilities :smile:
Have a nice day

1 Like

Hello @facer1
Do you by any chance still have the excel formula in hand? Can you share it here or privately? I was trying to recreate it by myself but to no success :frowning: IT would be of great help! Thanks

1 Like

There is a new MOONAGE Tag which makes everything more simple . In a spreadsheet you divide 1 by 28 or however may images or states you want . If you want to rotate it . use 360 / MOONAGE . you will have to add some numbers to compensate for the Orientation of your Image .
I have tests for both if you get stuck . However Respect to the guys who did it long hand .

2 Likes

See in the Tags List the new moonage stuff .
Also I post links to two tests I made with them .
No use at all to you unless you know how to inspect them .
.
.

.
.

.
.

.
.

2 Likes

@mikeoday Hi, I am just trying to confirm your math here, and I am not getting a result that seems to align with the current moon phase.

At the time of this message, the UNIX epoch is 1711318000.
Running that through your simplified formula ((#DNOW#-583084344)/2551442802)%1
I get a value of 0.442194.
However, the moon’s phase from NASA’s site NASA SVS | Moon Phase and Libration, 2024 shows 99.86%.
This means the formula’s current value should be about 0.4993. This seems like a large error.

Am I interpreting the math incorrectly here? I thought this formula would return 0 for a new moon, and 0.5 for a full moon, which we are almost at.

1 Like

What do you get with the complex expression?

The simple formula is not that accurate at times ( although the error you got does seem quite large ).

You are right about 0.5 for full.

1 Like

The next full moon is at: 2024 Mar 25 07:00 UTC or UNIX: 1711350000

refer: https://aa.usno.navy.mil

Testing the expressions gives the following:

Top: #DNOW#
Mid: simple
Bot: complex

I’m not sure why you are getting different results.

Are you sure you are testing with the time in creator adjusted for the correct UTC/GMT ?

Also, the reference used for the expressions is the US Navy Observatory, which is the official source for astronomical data in the US ( not NASA ) - although the differences should not be that great.

And finally, although again, it does not explain the size of the error, the expressions have been determined by empirical means and have only been confirmed to be reasonably accurate at the 4 phases of the Moon. And the errors will be larger during the intermittent phases. But, your example is very close to full Moon so that particular source of error should be very small in this case.

2 Likes