Orbital Lunar Eclipse Predictor

63 views
Skip to first unread message

Bert Mariani

unread,
Oct 7, 2025, 11:10:58 AMOct 7
to The Ring Programming Language
Hello Mahmoud et ALL

Attached is a Lunar Eclipse Predictor
 -  OrbitalLunarEclipse.ring

It will predict Lunar Eclipses based on Start and End Year
    - Total, Partial, Penumbral
    - Date, Time, Type 

Although the Lunar Synodic Cycle (month) is 29.53 days
It varies by +- 7 hours every month due to Sun gravity etc
That means it can vary from 29 to 30 days.
The Predictor is Close but not Exact.
It requires Meeus calculations which can be 100 parameters.
The first 8-10 parameters of Meeus gets fairly close.
   
# --- Start --- Set Start and End Year ---
func main
    see "Start main()" + nl
    MyMain(2022, 2030)     // <<<< Start End Years
    SaveEclipsesToCSV(2022, 2028, "eclipses.csv")
end

Note:
I used various AI to see what they could do 
ChatGpt, Claude, DeepSeek, Owen3-Max, CoPilot, Grok
They all vary in ability ... but require lots of Debugging ...
Lots or repetitive errors. They don't remember.
They tend to make up stuff.
After a while I noticed similarities ... they fetch data from similar Web Pages.

===================
Output

Start main()
Lunar Eclipse Prediction from 2022 to 2030
JD ,Date, Type, NodeSep_deg,Lat_deg, LunarRadius_deg, Umbra_deg, Penumbra_deg, Dist_km
2459715.79, 2022-05-16 06:55:50, Total.....,   176.96, 0.27, 0.27, 0.76, 1.03, 366997
2459891.80, 2022-11-08 07:11:55, Total.....,     2.82, 0.25, 0.26, 0.72, 0.98, 390318
2460070.41, 2023-05-05 21:46:31, Penumbral.,   168.44, 1.03, 0.26, 0.73, 1.00, 381123
2460246.18, 2023-10-28 16:26:16, Partial...,    10.71, 0.96, 0.27, 0.75, 1.02, 372712
2460394.82, 2024-03-25 07:45:16, Penumbral.,   168.75, 1.00, 0.25, 0.69, 0.96, 404650
2460571.67, 2024-09-18 04:10:50, Partial...,    11.29, 1.01, 0.27, 0.77, 1.04, 363872
2460748.66, 2025-03-14 03:52:29, Total.....,   176.15, 0.35, 0.25, 0.70, 0.96, 400899
2460926.45, 2025-09-07 22:51:12, Total.....,     2.69, 0.24, 0.27, 0.75, 1.02, 372879
2461102.77, 2026-03-03 06:27:37, Total.....,   176.23, 0.34, 0.26, 0.73, 1.00, 383504
2461280.87, 2026-08-28 08:55:51, Partial...,     5.60, 0.50, 0.26, 0.72, 0.98, 390349
2461457.31, 2027-02-20 19:33:35, Penumbral.,   168.21, 1.05, 0.27, 0.76, 1.03, 368213
2461634.88, 2027-08-17 09:03:42, Penumbral.,    13.52, 1.20, 0.25, 0.69, 0.96, 404498
2461782.78, 2028-01-12 06:48:42, Partial...,   168.66, 1.01, 0.27, 0.76, 1.03, 365993
2462137.40, 2028-12-31 21:42:41, Total.....,   176.62, 0.30, 0.26, 0.74, 1.00, 379211
2462313.45, 2029-06-25 22:52:36, Total.....,     0.15, 0.01, 0.27, 0.74, 1.01, 375540
2462491.59, 2029-12-21 02:15:20, Total.....,   175.89, 0.37, 0.25, 0.70, 0.97, 397511
2462668.20, 2030-06-15 16:41:58, Partial...,     8.61, 0.77, 0.27, 0.77, 1.03, 364645
2462845.44, 2030-12-09 22:32:26, Penumbral.,   168.75, 1.00, 0.25, 0.69, 0.96, 405589
Saved to eclipses.csv

ObitalLunarEclipse.ring

Mounir IDRASSI

unread,
Oct 8, 2025, 10:25:15 AMOct 8
to ring...@googlegroups.com

Hi Bert,

Thank you for sharing your program, nice work!

As a matter of challenge, I wanted to see if I can accomplish similar implementation using AI from scratch.
I decided to use GPT-5 High (API) because it is the strongest at reasoning and coding in general.

I started by asking GPT-5 High to implement a CLI program in C for a Lunar eclipse calendar generator to have an output similar to NASA data at https://eclipse.gsfc.nasa.gov/LEcat5/LE2001-2100.html.

After few iterations where I shared NASA eclipse data, it wrote a self-contained C program that matches NASA output exactly (few minutes difference only).

Thank I asked it to convert this C program to Ring. The Ring program created had 19 syntax errors that I had to fix manually (not difficult).

Once fixed, the output of the Ring program matched the NASA data like the C version. 
Afterwards, I modified the Ring code to output the same columns as your program as a matter of comparison.

In total, it took less than 45 minutes. 

The strength of GPT-5 High is an important factor but I think the fact to ask to write the algorithms in C then translate to Ring provides better results than asking directly to write in Ring.

I'm attaching the source code of the program (Lunar_Eclipse_Calendar_Generator.ring). I also published it at https://github.com/idrassi/LunarEclipseCalendarGenerator-Ring (with a static Windows binary built with latest unreleased Monoring).

Below is the output for the range 2022-2030:

----
Lunar Eclipse Calendar Generator
Enter start year: 2022
Enter end year: 2030
Lunar Eclipse Calendar Generator
----------------------------------------------------------------------------------------------------------------------------------------
Range: 2022 to 2030
Classification uses dynamic shadow sizes and center-axis separation Rho (deg).
----------------------------------------------------------------------------------------------------------------------------------------
#     Date        Time   Type          Rho (deg)  NodeSep_deg   Lat_deg  LunarRadius_deg   Umbra_deg  Penumbral_deg     Dist_km
----------------------------------------------------------------------------------------------------------------------------------------
1     2022-05-16  04:12  Total             0.260        6.000    -0.258            0.275       0.746         1.273      362095
2     2022-11-08  11:00  Total             0.243        1.883     0.241            0.255       0.666         1.205      390650
3     2023-05-05  17:24  Penumbral         0.996       16.467    -0.991            0.262       0.697         1.226      380195
4     2023-10-28  20:14  Partial           0.937        6.401     0.931            0.269       0.720         1.257      369685
5     2024-03-25  07:14  Penumbral         0.955        9.597     0.951            0.246       0.634         1.169      405420
6     2024-09-18  02:44  Partial           1.004       10.482    -1.001            0.278       0.757         1.288      357459
7     2025-03-14  06:59  Total             0.317        6.538     0.317            0.248       0.642         1.178      401495
8     2025-09-07  18:13  Total             0.274        1.242    -0.272            0.269       0.724         1.253      369678
9     2026-03-03  11:35  Total             0.361        0.821    -0.359            0.260       0.686         1.224      382604
10    2026-08-28  04:13  Partial           0.463        9.949     0.460            0.255       0.672         1.200      390371
11    2027-02-20  23:14  Penumbral         1.055        8.800    -1.052            0.274       0.736         1.275      363335
12    2027-07-18  16:05  Penumbral         1.420       17.200    -1.412            0.245       0.638         1.162      406026
13    2027-08-17  07:13  Penumbral         1.155       14.794     1.148            0.246       0.639         1.165      405115
14    2028-01-12  04:13  Partial           0.997        8.917     0.992            0.276       0.743         1.285      360295
15    2028-07-06  18:22  Partial           0.732       12.752    -0.728            0.253       0.665         1.190      393944
16    2028-12-31  16:49  Total             0.319        1.219     0.319            0.264       0.697         1.239      377642
17    2029-06-26  03:24  Total             0.015        4.587     0.012            0.267       0.717         1.241      373264
18    2029-12-20  22:41  Total             0.348        7.638    -0.346            0.250       0.647         1.189      398133
19    2030-06-15  18:34  Partial           0.767        6.965     0.763            0.277       0.756         1.281      358754
20    2030-12-09  22:26  Penumbral         0.963       10.697    -0.958            0.245       0.629         1.170      406344
----------------------------------------------------------------------------------------------------------------------------------------
Summary:  Total     : 8  Partial   : 6  Penumbral : 6  All       : 20
----------------------------------------------------------------------------------------------------------------------------------------
Note: Times are near greatest eclipse by minimizing Moon-shadow-axis separation.
---

Cheers,

Mounir IDRASSI

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/605fed32-207b-4cc8-8e94-81f71a771844n%40googlegroups.com.
Lunar_Eclipse_Calendar_Generator.ring

Bert Mariani

unread,
Oct 8, 2025, 1:15:18 PMOct 8
to The Ring Programming Language
Hello Mounir

Thanks for sharing your experience and code.

I see GPT-5 High used Meeus calculations for accuracy.
The  func moon_llb_distance(jde)  uses some ~ 90 parameters as per Meeus to refine to position of the Moon.
Thanks to the Astronomer Meeus who figured it all out about the +- 7 hours variation in the Moon Synodic cycle.
It reflects in the Time accuracy of the Eclipse.

I had noticed that All these AI 's get confused by Ring Coding.
When I asked them to test their Code. They could not.
Claimed they did not have access to a "Ring Environment"
But they could Test Python !
It looks like from your experience they have access to a "C Environment" to test with !
You made an interesting point -- Ask to Write C Code and Test it. 
Then convert it to Ring and correct all the Syntax and wrong Functions.

Note: 
In your code   GPT-5 High  uses "abs" and defines it as a function, whereas Ring has "fabs"
Same where Ring can define a string of repetitive chars,  GPT-% High writes its own function
     - copy(string,nCount) ---> string replicated nCount times

Beautiful  GitHub page documentation !

Best Regards
Bert Mariani

Bert Mariani

unread,
Oct 8, 2025, 1:22:42 PMOct 8
to The Ring Programming Language
Hello ALL

Question to GPT-5 High
if you write in C Code to calculate Lunar Eclipses can you test your code internally first
ChatGPT said:

===============

Good question — no, I can’t directly execute or simulate C code in my own environment.

Here’s what I can do:

  • Write, debug, and logically verify C code line by line.

  • Simulate numeric results (like eclipse geometry or time outputs) using an internal Python sandbox — i.e., I can re-implement the math and test the algorithm’s correctness that way.

  • I cannot compile or run C code natively, so runtime errors, compiler warnings, or environment-specific behavior would need to be checked on your system.

If you want, I can:

  1. Write a complete C program that predicts lunar eclipses (Meeus-style or geometric bisection like your Ring version).

  2. Simulate the algorithm numerically in Python to verify results.

  3. Then give you the final C source ready to compile and test locally.

Would you like me to do that — and should it match your 2022–2028 time window and the Meeus-based method?


Mounir IDRASSI

unread,
Oct 8, 2025, 7:46:47 PMOct 8
to The Ring Programming Language
Hi Bert,

Thank you for the feedback. It was interesting to learn about Meeus and his amazing formulas.

Concerning the generated Ring code, it is indeed not optimal as you found out. GPT-5 used only basic Ring constructs because it lacked knowledge about the standard library. But it is possible to share part of Ring documentation and ask it to optimize the code.

Concerning simulating C code:

LLMs develop new capabilities with more training data and more size: this is a mysterious fact that still has no scientific explanation.

One of such capabilities is ability to simulate running code and performing debug without actually running the code.

All LLMs are trained on huge size of C/C++ code dataset and so they are naturally strong at simulating and debugging C code.

This is also true for Python.

This explains why asking an LLMs to write an algorithm in C leads to better results: it is able to better simulate its behavior than Ring which is not well represented in its training data.

I personally used GPT-5 to help me debug some complex issues in C++ code: just by sharing the affected code, the detailed about the flow and inputs, it was able to find root cause of the issues and propose fixes.

Sometimes it feels like magical but sometimes it can be really dumb! So unfortunately this technology is not 100% reliable yet.

On 9 Oct 2025, at 02:22, Bert Mariani <bert.m...@gmail.com> wrote:

Hello ALL

Bert Mariani

unread,
Oct 10, 2025, 4:19:53 PMOct 10
to The Ring Programming Language
Hello Mounir et ALL

After playing with GPT-5  
Had it write some C-code for a program
Asked it to convert the C-Code to Ring-Code.
The usual result -- Many Syntax Errors, Many Non-existent Functions
It really gets Languages confused.

If you correct the Syntax and Functions yourself, you will make progress.

If you ask GPT-5 to make the corrections, it get Worst and Worst at the Syntax.
Even chunk of Code Disappear !!  ( 450 lines ->  218 lines -> 165 lines)
It just seems to get Dumber.
Don't know why but it does Not Learn when you point out the Corrections.

I even asked it to Read the Ring Documentation - Left Panel 

Its a toss up with Claude 4.5 

Ilir Liburn

unread,
Oct 10, 2025, 6:05:12 PMOct 10
to The Ring Programming Language
Hello Bert,

>> Don't know why but it does Not Learn when you point out the Corrections

article which explains disadvantages of GPT.


Greetings,
Ilir
Reply all
Reply to author
Forward
0 new messages