Mario Hilgemeier

SOLUNA - find approximate period coincidence

#!/usr/bin/python
#
# SOLUNA -------
# 2003 - 2004 by Mario Hilgemeier http://hilgemeier.gmxhome.de
#
# Task: find approximate period coincidence
#       of two periods (given in days)
#       here: the tropical year (ty) 356.2424
#       and the synodic month (sm) 29.530589
#
# To make a very exact calendar that lasts more than
# one or two thousand years, the period changes of the
# celestial bodies must be accounted for.
# These periods change slowly over time - and the laws
# of change are not fully predictable.
#
# This program uses the simple approach
# that does not account for period changes.
#
# usage: ./soluna ty sm
#
# For a test period of 6000 years, soluna produces this
# result: 5705 ty = 70561 sm, where the moons fall short of the
# years by only 10 minutes. So this is a calendar that is good
# enough for the next millennium. The time of the full moon
# can be off to about eight hours, due to celestial mechanics
# (= mean lunar calendars can be off plus or minus a day).
# 70561 = 41 * 1721
#  5705 = 5 * 7 * 163
#
# For smaller test periods, some good calendars are
#
# sunsum  = 128930.5672
# moonsum = 128930.551574 delta   = 0.0156259939249
# years: 352.999957217
# moons: 4366.0
#
# sunsum  = 780523.0088
# moonsum = 780522.997859 delta   = 0.0109414446633
# years: 2136.99997004
# moons: 26431.0
#
# sunsum  = 1432115.4504
# moonsum = 1432115.44414 delta   = 0.00625563692302
# years: 3920.99998287
# moons: 48496.0
#
# sunsum  = 2083707.892
# moonsum = 2083707.89043 delta   = 0.00156885781325
# years: 5704.99999571
# moons: 70561.0000001
#
# up to 60000 years, there is only one better calendar
# than that:
# sunsum  = 6902716.1176
# moonsum = 6902716.11759 delta   = 4.81680035591e-06
# years: 18899.0
# smoons: 233748.000001



#import re
import sys
import string
#import commands

ty = string.atof(sys.argv[1])
sm = string.atof(sys.argv[2])

if ((ty <= 0.0) or (sm <= 0)) :
  ty = 365.2424
  sm = 29.530589

print "tropical year: ", ty
print "synodic month", sm

moonsum = sm
sunsum = ty

years = 0
olddelta = 1.0
while (years < 6000):
  delta = sunsum - moonsum
  years = moonsum / ty
  if (delta < 0.05):
    if (delta < olddelta) :
      olddelta = delta
      print "*** improvement ***"
    print "sunsum  =", sunsum
    print "moonsum =", moonsum,"delta   =", delta
    print "years:", years
    print "moons:", moonsum/sm
    print " --- "
  if (moonsum < sunsum):
    moonsum = moonsum + sm
  if (sunsum < moonsum):
    sunsum = sunsum + ty

#  print "delta =",delta


--------------------------------------

Download Python code soluna01.py


Algorithms and Program Codes


© Copyright 2001-2004 Mario Hilgemeier, email: contact
homepage stylized apple blossom