The Museum of HP Calculators

HP Forum Archive 19

 Kepler Orbits for the 42SMessage #1 Posted by Les Wright on 13 Aug 2009, 2:34 a.m. Even though I know this won't advance the space program, I thought I would share this little routine I have put together that really seems to make excellent use of the 42S/Free42: ```00 { 152-Byte Prgm } 01>LBL "KEPORB" 02 MVAR "PER" 03 MVAR "ECC" 04 MVAR "PH" 05 MVAR "T" 06 VARMENU "KEPORB" 07 RAD 08 STOP 09 EXITALL 10 PI 11 RCL× "T" 12 RCL÷ "PER" 13 STO+ ST X 14 STO "MA" 15 PGMSLV "KEPEQ" 16 STO "EA" 17 SOLVE "EA" 18 0.5 19 RCL× "EA" 20 TAN 21 1 22 RCL+ "ECC" 23 1 24 RCL- "ECC" 25 ÷ 26 SQRT 27 × 28 ATAN 29 STO+ ST X 30 ENTER 31 ->DEG 32 X<>Y 33 COS 34 RCL× "ECC" 35 1 36 + 37 1 38 RCL+ "ECC" 39 X<>Y 40 ÷ 41 RCL× "PH" 42 RTN 43>LBL "KEPEQ" 44 RCL "MA" 45 RCL- "EA" 46 RCL "EA" 47 SIN 48 RCL× "ECC" 49 + 50 .END. ``` The routine returns the heliocentric polar coordinates of a planet's orbit given the orbital PERiod, ECCentricity, and PeriHelion (i.e, nearest to the Sun) distance at a given time T (with the understanding the T=0 is at perihelion). The program returns the distance from the sun in the X register and the angle of rotation in degrees (with the understand that the angle is zero at perihelion) in the Y register. To use XEQ KEPORB, enter the orbital parameters for your planet (easily found all over the place--I use Wikipedia) into the menu variables PER, ECC, and PH, enter the desired T into that menu variable, hit R/S, and the result is returned as described. Units obviously must be consistent. If the PERiod entered is in days, the T entered should also be in days. The distance returned will be in the same units as that of PeriHelion distance provided. I like the internal programmed use of the Solver to numerically solve the transcendental Kepler equation. Those who know about this stuff will see that I use the known Mean Anomaly as a reasonable initial guess to the desired Eccentric Anomaly. In our solar system this is a pretty good approximation since the elliptical orbits are actually almost circular in most cases, and even in the exceptions like Pluto and Mercury things are still pretty close. Info on the math is [link:http://en.wikipedia.org/wiki/Kepler's_laws_of_planetary_motion]here[/link]. The RAW file, for Free42 users, is here. Hope someone else also finds this amusing. Les Edited: 13 Aug 2009, 10:01 p.m. after one or more responses were posted

 Re: Kepler Orbits for the 42SMessage #2 Posted by Les Wright on 13 Aug 2009, 7:15 p.m.,in response to message #1 by Les Wright I took the time to enter the steps in my real 42S. It runs well, return a result in a couple of seconds, but isn't quite as accurate as on Free42 as there is usually some accuracy loss (a digit or two usually) due to rounding.

 Re: Kepler Orbits for the 42SMessage #3 Posted by Gerson W. Barbosa on 13 Aug 2009, 9:27 p.m.,in response to message #2 by Les Wright Quote: but isn't quite as accurate as on Free42 as there is usually some accuracy loss (a digit or two usually) due to rounding. It's nice chain calculations on Free42 are carried out internally with 20 or more digits. On the other hand this is quite contrary to HP rounding philosophy (at least on real HP calculators) - please read the first message in this thread. For the sake of replicating the real 42S as faithfully as possible, I think Free42 should provide the classic rounding method as an option. Of course, Free42 is just great the way it is and I am glad Free42Decimal has been available since the first versions. Edited: 13 Aug 2009, 9:28 p.m.

 Re: Kepler Orbits for the 42SMessage #4 Posted by Reth on 13 Aug 2009, 11:19 p.m.,in response to message #3 by Gerson W. Barbosa I disagree with the idea Free42 should copy the original. Free42 is already superior to it in every possible aspect so it should go further adding more features to address the needs of the modern world calculator users. Probably that's the only way we get (sort of) Walter's HP-43S. Or should program storage for example be taken off to match the original?. Regards,Reth

 Re: Kepler Orbits for the 42SMessage #5 Posted by Gerson W. Barbosa on 14 Aug 2009, 11:44 a.m.,in response to message #4 by Reth I didn't mean Free42 should be crippled just to match the original 42S. It just happens sometimes original features are more desirable than the enhanced ones. For instance, Free42BCD is way faster than the Decimal version but programs that depend on decimal arithmetic will not work properly on the former. I cannot think of any original HP-42S program, however, that won't work due to the extra internal digits. Best regards, Gerson.

 Re: Kepler Orbits for the 42SMessage #6 Posted by Les Wright on 15 Aug 2009, 11:58 p.m.,in response to message #3 by Gerson W. Barbosa Gerson, for folks who want authentic emulation of the original I think Emu42 is the better solution. I use Free42 in all of its incarnations precisely because its capabilities supersede the original. I have a 42S in fair condition as my collectible, but Free42 on my handhelds and PCs is what I actually use. The Achilles heal of the original is the absence of fast and convenient I/O. Les

Go back to the main exhibit hall