251 lines
8.7 KiB
Plaintext
251 lines
8.7 KiB
Plaintext
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
|
|||
|
F O R M U L A S
|
|||
|
|
|||
|
|
|||
|
Here are a few interesting formulas which I have gleaned from
|
|||
|
some 20 years in computers. Some of these will be familiar to
|
|||
|
you, some may not.
|
|||
|
|
|||
|
All of these formulas work properly. The calendar functions
|
|||
|
have been tested for all dates from 1/1/1 through 12/31/5000.
|
|||
|
Even though these dates are meaningless, you cam depend on the
|
|||
|
formulas for precision on real dates.
|
|||
|
|
|||
|
If you are interested in other constants, or constants to much
|
|||
|
greater precision, you might want to try my BIGCALC program
|
|||
|
which emulates a Hewlett-Packard calculator on screen. BIGCALC
|
|||
|
has a four register stack and 10 memory registers. You can
|
|||
|
specify the precision from 3 to 1000 digits. The constants pi
|
|||
|
and e are provided to full precision. BIGCALC was used to
|
|||
|
derive the following constants. BIGCALC is available on the
|
|||
|
IBM Software and Microsoft Systems Forums on Compuserve. The
|
|||
|
file is named BCALxx.ARC where xx is the revision number.
|
|||
|
|
|||
|
The file FORMULAS.TXT is in ASCII form. The file FORMULAS.PRN
|
|||
|
is in form suitable for IBM compatible printers and uses the
|
|||
|
extended character set for pi, powers, etc. Looks better.
|
|||
|
|
|||
|
I would be happy to recieve comments on this stuff, especially
|
|||
|
any new formulas or algorithms! Enjoy.
|
|||
|
|
|||
|
|
|||
|
Judson D. McClendon
|
|||
|
Sun Valley Systems
|
|||
|
844 Sun Valley Road
|
|||
|
Birmingham, AL 35215
|
|||
|
205-853-8440
|
|||
|
Compuserve [74415,1003]
|
|||
|
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
MATHEMATICAL FORMULAS:
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
|
|||
|
Some Important Constants:
|
|||
|
|
|||
|
|
|||
|
<20>: 3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510
|
|||
|
58209 74944 59230 78164 06286 20899 86280 34825 34211 70679 82
|
|||
|
|
|||
|
1/<2F>: 0.31830 98861 83790 67153 77675 26745 02872 40689 19291 48091
|
|||
|
28974 95334 68811 77935 95268 45307 01802 27605 53250 61719 12
|
|||
|
|
|||
|
<20><>: 9.86960 44010 89358 61883 44909 99876 15113 53136 99407 24079
|
|||
|
06264 13349 37622 00448 22419 20524 30017 73403 71855 22318 24
|
|||
|
|
|||
|
<20>/180: 0.01745 32925 19943 29576 92369 07684 88612 71344 28718 88541
|
|||
|
72545 60971 91440 17100 91146 03449 44368 22415 69634 50948 22
|
|||
|
|
|||
|
180/<2F>: 57.29577 95130 82320 87679 81548 14105 17033 24054 72466 56432
|
|||
|
15491 60243 86120 28471 48321 55263 24409 68995 85111 09441 86
|
|||
|
|
|||
|
e: 2.71828 18284 59045 23536 02874 71352 66249 77572 47093 69995
|
|||
|
95749 66967 62772 40766 30353 54759 45713 82178 52516 64274 27
|
|||
|
|
|||
|
1/e: 0.36787 94411 71442 32159 55237 70161 46086 74458 11131 03176
|
|||
|
78345 07836 80169 74614 95744 89980 33571 47274 34591 96437 46
|
|||
|
|
|||
|
e<>: 7.38905 60989 30650 22723 04274 60575 00781 31803 15570 55184
|
|||
|
73240 87127 82252 25737 96079 05776 33843 12485 07912 17947 73
|
|||
|
|
|||
|
<20>2: 1.41421 35623 73095 04880 16887 24209 69807 85696 71875 37694
|
|||
|
80731 76679 73799 07324 78462 10703 88503 87534 32764 15727 35
|
|||
|
|
|||
|
<20>3: 1.73205 08075 68877 29352 74463 41505 87236 69428 05253 81038
|
|||
|
06280 55806 97945 19330 16908 80003 70811 46186 75724 85756 75
|
|||
|
|
|||
|
Golden Ratio: 1.61803 39887 49894 84820 45868 34365 63811 77203 09179 80576
|
|||
|
<EFBFBD> = (<28>5+1)/2 28621 35448 62270 52604 62818 90244 97072 07204 18939 11374 84
|
|||
|
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
|
|||
|
Newton's Method:
|
|||
|
|
|||
|
|
|||
|
Newton's Method for extracting positive integral roots of positive numbers
|
|||
|
is as follows:
|
|||
|
|
|||
|
|
|||
|
The Rth root of the positive number A is obtained as a root of the function:
|
|||
|
|
|||
|
f(X) = XS0RT - N
|
|||
|
|
|||
|
|
|||
|
by means of the iterated equation:
|
|||
|
|
|||
|
Xj = Xi - (XiS0RT - N) / (R * XiS0(R-1)T)
|
|||
|
|
|||
|
= Xi * (1 - 1/R) + (N / (R * XiS0(R-1)T))
|
|||
|
|
|||
|
|
|||
|
For square root, the equation simplifies to
|
|||
|
|
|||
|
Xj = (Xi + (N / Xi)) / 2
|
|||
|
|
|||
|
|
|||
|
Where: Xi = previous approximation
|
|||
|
|
|||
|
Xj = next approximation
|
|||
|
|
|||
|
R = root
|
|||
|
|
|||
|
N = number
|
|||
|
|
|||
|
|
|||
|
This method converges very rapidly if a reasonable first approximation is
|
|||
|
obtained.
|
|||
|
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
CALENDAR FORMULAS:
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
|
|||
|
Zeller's Congruence:
|
|||
|
|
|||
|
|
|||
|
Zeller's Congruence is used to determine the day of the week of any date in
|
|||
|
the Gregorian calendar, which was instituted October 15, 1582. The formula,
|
|||
|
good for any date since October 15, 1582 is as follows:
|
|||
|
|
|||
|
|
|||
|
weekday = ( day + 1
|
|||
|
+ (month * 2)
|
|||
|
+ INT((month + 1) * 3 / 5) Note: or INT((month + 1) * .6)
|
|||
|
+ year
|
|||
|
+ INT(year / 4)
|
|||
|
- INT(year / 100)
|
|||
|
+ (year / 400)
|
|||
|
) MOD 7
|
|||
|
|
|||
|
|
|||
|
Where: weekday = (0=Sun, 1=Mon, 2=Tue, 3=Wed, 4=Thu, 5=Fri, 6=Sat)
|
|||
|
|
|||
|
day = day of the month
|
|||
|
|
|||
|
month = month of year (Jan & Feb = 13 & 14 of prev year)
|
|||
|
|
|||
|
year = year (year - 1 if month is Jan or Feb)
|
|||
|
|
|||
|
INT = integer part (eg: INT(3.5) = 3)
|
|||
|
|
|||
|
MOD = modulus or remainder part (eg: (10 MOD 7) = 3)
|
|||
|
|
|||
|
|
|||
|
Example: Feb 12, 1809 day = 12, month = 14, year = 1808 (weekday = 0 Sun)
|
|||
|
|
|||
|
Jul 4, 1776 day = 4, month = 7, year = 1776 (weekday = 4 Thu)
|
|||
|
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
|
|||
|
Date Day Number:
|
|||
|
|
|||
|
|
|||
|
Date Day Number is used to determine the number of days between any two dates
|
|||
|
in the Gregorian calendar, which was instituted October 15, 1582. Date day
|
|||
|
number calculates a number which is one greater for each succeeding date.
|
|||
|
The formula, good for any date since October 15, 1582 is as follows:
|
|||
|
|
|||
|
|
|||
|
dateday = ( (year * 365)
|
|||
|
+ INT(year / 4)
|
|||
|
- INT(year / 100)
|
|||
|
+ INT(year / 400)
|
|||
|
+ INT(month * 306001 / 10000) Note: or INT(month * 30.6001)
|
|||
|
+ day
|
|||
|
)
|
|||
|
|
|||
|
|
|||
|
Where: dateday = Date Day Number (Note that dateday can be 6 digits or more)
|
|||
|
|
|||
|
day = day of the month
|
|||
|
|
|||
|
month = month + 13 (Jan & Feb)
|
|||
|
month + 1 (Mar - Dec)
|
|||
|
|
|||
|
year = year - 1 (Jan & Feb)
|
|||
|
year (Mar - Dec)
|
|||
|
|
|||
|
INT = integer part (eg: INT(3.5) = 3)
|
|||
|
|
|||
|
|
|||
|
Example: Feb 12, 1809 day = 12, month = 15, year = 1808 (dateday = 660,730)
|
|||
|
|
|||
|
Jul 4, 1776 day = 4, month = 8, year = 1776 (dateday = 648,801)
|
|||
|
|
|||
|
(days between = 11,929)
|
|||
|
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|
|||
|
|
|||
|
Easter Computation:
|
|||
|
|
|||
|
|
|||
|
Easter falls on the first Sunday following the arbitrary Paschal Full Moon,
|
|||
|
which does not necessarily coincide with a real or astronomical full moon.
|
|||
|
The date of the Paschal Full Moon is obtained by dividing the year by 19
|
|||
|
and applying the remainder to the following table:
|
|||
|
|
|||
|
|
|||
|
0: Apr 14 5: Apr 18 10: Mar 25 15: Mar 30
|
|||
|
1: Apr 3 6: Apr 8 11: Apr 13 16: Apr 17
|
|||
|
2: Mar 23 7: Mar 28 12: Apr 2 17: Apr 7
|
|||
|
3: Apr 11 8: Apr 16 13: Mar 22 18: Mar 27
|
|||
|
4: Mar 31 9: Apr 5 14: Apr 10
|
|||
|
|
|||
|
|
|||
|
Thus, for the year 2000 the key is 5 or April 18. Since April 18th in the
|
|||
|
year 2000 is a Tuesday, Easter Sunday is April 23rd. CAUTION - If the
|
|||
|
Paschal Full Moon falls on a Sunday, Easter is the following Sunday. The
|
|||
|
earliest Easter can fall is March 23rd and the latest is April 25th.
|
|||
|
|
|||
|
|
|||
|
Lent begins on Ash Wednesday which comes 40 days before Easter, excluding
|
|||
|
Sundays, or 45 days overall.
|
|||
|
|
|||
|
|
|||
|
==============================================================================
|
|||
|
|