--- title: "Moonphase Astrology" id: 55119 type: "computer_media" slug: "moonphase-astrology" url: "http://localhost/computer_media/moonphase-astrology/" markdown_url: "http://localhost/computer_media/moonphase-astrology.md" published_at: "2024-06-16T23:17:56+00:00" modified_at: "2026-03-30T21:44:09+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/06/SCR-20240616-qwon.png" excerpt: "Enter any calendar date and this program calculates the Moon's ecliptic longitude in degrees using a multi-term astronomical polynomial expansion." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Astronomy" slug: "astronomy" taxonomy: "genre" url: "http://localhost/type/astronomy/" - name: "Entertainment" slug: "entertainment" taxonomy: "genre" url: "http://localhost/type/entertainment/" media_contents: - id: 54965 title: "ISTUG Public Domain Library 5" type: "computer_media" url: "http://localhost/computer_media/istug-public-domain-library-5/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/06/SCR-20240616-qwon.png" media_type_tags: "Astronomy, Entertainment" --- # Moonphase Astrology This program calculates the Moon’s ecliptic longitude in degrees for a user-supplied calendar date, producing a numerical “moon phase” value from 0 to 359 degrees. The core calculation converts the Gregorian date to a Julian Day Number offset (subtracting 694038 to produce a reduced epoch), divides by 36525 to obtain Julian centuries, then applies a polynomial expansion of the Moon’s mean longitude including secular terms. The January/February adjustment at line 170 (decrementing the year and adding 12 to the month) is a standard technique for Julian Day Number conversion. Results are displayed as a rounded integer representing the Moon’s longitude, and the program loops continuously for new date entries. *** ## Program Analysis ### Program Structure The program is organized into four clearly separated subroutines, each introduced by a `REM` block, with a main control loop at line 1000. Flow is entirely driven by `GO SUB` and `GO TO`: 1. **Lines 100–180:** Date input and January/February correction 2. **Lines 200–280:** Julian Day conversion and lunar longitude calculation 3. **Lines 300–350:** Result display and keypress wait 4. **Lines 1000–1040:** Main loop, calling subroutines in sequence and repeating indefinitely The `GO TO 1000` at line 20 skips the subroutine definitions, ensuring they are never accidentally fallen into on program start. ### Date Normalization (Lines 170–180) When the input month is January or February (`m<3`), the month is increased by 12 and the year decremented by 1. This is the standard pre-processing step required before Julian Day Number arithmetic, treating January and February as months 13 and 14 of the previous year. Without this step the `INT(30.6*(m+1))` term in line 210 would produce incorrect day counts for the first two months of any year. ### Astronomical Calculation (Lines 210–270) The calculation proceeds in two stages. First, a Julian Day count offset is computed at line 210: - `INT(365.25*y)` — integer days in whole years (Julian calendar approximation) - `INT(30.6*(m+1))` — integer days in whole months using the 30.6 coefficient - `dd - 694038` — day of month minus a fixed epoch offset, reducing to a compact integer near J2000 This value is then divided by 36525 (days per Julian century) at line 220 to produce `t`, the time in Julian centuries from the epoch. Lines 230–260 compute the Moon’s mean ecliptic longitude `la` as a polynomial in `t`, accumulating terms: | Line | Term added | Astronomical meaning | | --- | --- | --- | | 230 | 350.737486 + 1236·t·360 | Mean longitude epoch value plus full-revolution secular motion | | 240 | 307·t + 6·t/60 | Additional linear and arcminute-scaled secular terms | | 250 | 51.18·t/3600 − 5.17·t²/3600 | Arcsecond-scaled linear and quadratic correction terms | | 260 | `−INT(la/360)*360` | Reduction modulo 360° | | 270 | `INT(la+.5)` | Round to nearest integer degree | The large `1236*t*360` term at line 230 encodes the approximately 1,236 complete lunar revolutions per century. The division by 60 and 3600 at lines 240–250 suggest the original formula may have been specified with some coefficients in arcminutes and arcseconds respectively, converted inline. ### Key BASIC Idioms - **Busy-wait keypress:** Line 340 uses `IF INKEY$="" THEN GO TO 340` — a standard polling loop to pause until any key is pressed. - **Accumulating into a variable:**`la` is built up across lines 230–270 by repeated `LET la=la+...` assignments, a common technique to work around the lack of multi-line expressions. - **Infinite main loop:** Line 1040 (`GO TO 1010`) creates an unconditional loop back to the input subroutine; the only exit is the `STOP` at line 9997, reachable only by direct `GO TO` or breaking program execution. ### Notable Techniques The epoch offset of 694038 in line 210 corresponds to a Julian Day Number chosen to place the zero-point conveniently near a known lunar longitude reference. Using a reduced JDN rather than the full Julian Day Number (~2.4 million) keeps intermediate integer arithmetic within manageable bounds for BASIC’s floating-point. ### Bugs and Anomalies - Line 130 contains a typographical error: `"DETERNINATION OF MOONPHASE"` should read `"DETERMINATION OF MOONPHASE"`. This is a display-only issue and does not affect computation. - The program outputs only the Moon’s mean ecliptic longitude, not a conventional phase (New/First Quarter/Full/Last Quarter) or illumination percentage. The title “MOONPHASE” is therefore somewhat misleading; the result is more precisely the Moon’s mean longitude in degrees. - No input validation is performed on `dd`, `m`, or `y`, so out-of-range dates will silently produce erroneous results. ## Source Code ``` 10 REM MOONPHASE ASTROLOGY 20 GO TO 1000 100 REM input date 110 CLS 130 PRINT "DETERNINATION OF MOONPHASE" 135 PRINT 140 INPUT "DAY (dd): ";dd: PRINT "Day : ";dd 150 INPUT "Month (mm): ";m: PRINT "Month: ";m 160 INPUT "Year (yyyy): ";y: PRINT "Year: ";y 170 IF m<3 THEN LET m=m+12: LET y=y-1 180 RETURN 200 REM calculation 210 LET t=INT (365.25*y)+INT (30.6*(m+1))+dd-694038 220 LET t=t/36525 230 LET la=350.737486+1236*t*360 240 LET la=la+307*t+6*t/60 250 LET la=la+51.18*t/3600-5.17*t*t/3600 260 LET la=la-INT (la/360)*360 270 LET la=INT (la+.5) 280 RETURN 300 REM display result 310 PRINT : PRINT 320 PRINT "Moonphase=";la;" degrees" 330 PRINT : PRINT "Press any key" 340 IF INKEY$="" THEN GO TO 340 350 RETURN 1000 REM main program 1010 GO SUB 100: REM input date 1020 GO SUB 200: REM calculation 1030 GO SUB 300: REM display result 1040 GO TO 1010 9997 STOP 9998 SAVE "MOONPHASE" LINE 1 ```