EXC/ x<>Rn for stack efficiency
07-20-2022, 07:03 PM
Post: #44
 Thomas Klemm Senior Member Posts: 2,069 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
This looks like an XY problem to me.
Here is a program to calculate the great circle distance between two points A and B on a sphere.
Since no registers are used, the initial question X is not relevant.
All you ever wanted is a solution for Y.

Program

This program works for most HP calculators:

HP-25
Code:
01: 21       : x<->y 02: 22       : Rv 03: 41       : - 04: 14 05    : f COS 05: 21       : x<->y 06: 01       : 1 07: 14 09    : f ->R 08: 21       : x<->y 09: 22       : Rv 10: 61       : * 11: 21       : x<->y 12: 01       : 1 13: 14 09    : f ->R 14: 21       : x<->y 15: 22       : Rv 16: 61       : * 17: 22       : Rv 18: 61       : * 19: 21       : x<->y 20: 22       : Rv 21: 51       : + 22: 15 05    : g COS-1

HP-15C
Code:
   001 {          34 } x↔y    002 {          33 } R⬇    003 {          30 } −    004 {          24 } COS    005 {          34 } x↔y    006 {           1 } 1    007 {       42  1 } f → R    008 {          34 } x↔y    009 {          33 } R⬇    010 {          20 } ×    011 {          34 } x↔y    012 {           1 } 1    013 {       42  1 } f → R    014 {          34 } x↔y    015 {          33 } R⬇    016 {          20 } ×    017 {          33 } R⬇    018 {          20 } ×    019 {          34 } x↔y    020 {          33 } R⬇    021 {          40 } +    022 {       43 24 } g COS⁻¹

HP-42S
Code:
00 { 24-Byte Prgm } 01 X<>Y 02 R↓ 03 - 04 COS 05 X<>Y 06 1 07 →REC 08 X<>Y 09 R↓ 10 × 11 X<>Y 12 1 13 →REC 14 X<>Y 15 R↓ 16 × 17 R↓ 18 × 19 X<>Y 20 R↓ 21 + 22 ACOS 23 END

Example

This is the example provided for the SR-56:

Point A: $$33^\circ 54.5'$$ N, $$94^\circ 56.2'$$ W
Point B: $$33^\circ 59.6'$$ S, $$151^\circ 25.6'$$ E

DEG

33.5430 →HR
33.908333

94.5612 →HR
94.936667

-33.5936 →HR
-33.993333

-151.2536 →HR
-151.426667

R/S
125.999888

If we want to get the result in nautical miles we can multiply the result by 60:

60
×

7559.993276

Or then we could convert degrees to radians and multiply the result by earth's radius.

Formula

(06-15-2017 10:29 AM)Paul Dale Wrote:  It ought to be possible to calculate the distance using the modified Vincenty formula on the 25:

These programs use the same formula as the original program for the SR-56:

$$\Delta \sigma =\arccos \left ( \sin \phi _{1}\sin \phi _{2}+\cos \phi _{1}\cos \phi _{2}\cos(\Delta \lambda ) \right )$$

Conversion

(06-15-2017 09:01 AM)Dieter Wrote:  This will for instance show that the complete routine in the first steps (which is called several times as SBR 00) is obsolete since it does a simple d.ms to decimal degrees conversion (e.g. it turns 42°50' into 42,8333°). The 25 and 33 have a dedicated function for this.

Well, not exactly.
Therefore we have to convert e.g. $$94^\circ {56.2}'$$ to $$94^\circ {56}' {12}''$$ in our heads.

References
The original link to this document appears to be broken.

(06-15-2017 09:01 AM)Dieter Wrote:  But I am sure that HP25 great circle programs already exist. ;-)
Cf. Programs/Library1/HP25-AP24.25:
Code:
01: 24 00    : RCL 0 02: 14 04    : f SIN 03: 24 01    : RCL 1 04: 14 04    : f SIN 05: 61       : * 06: 24 00    : RCL 0 07: 14 05    : f COS 08: 24 01    : RCL 1 09: 14 05    : f COS 10: 61       : * 11: 24 02    : RCL 2 12: 14 05    : f COS 13: 61       : * 14: 51       : + 15: 23 03    : STO 3 16: 15 05    : g COS-1 17: 23 04    : STO 4 18: 06       : 6 19: 00       : 0 20: 61       : * 21: 74       : R/S 22: 24 01    : RCL 1 23: 14 04    : f SIN 24: 24 00    : RCL 0 25: 14 04    : f SIN 26: 24 03    : RCL 3 27: 61       : * 28: 41       : - 29: 24 00    : RCL 0 30: 14 05    : f COS 31: 71       : / 32: 24 04    : RCL 4 33: 14 04    : f SIN 34: 71       : / 35: 15 05    : g COS-1 36: 24 02    : RCL 2 37: 14 04    : f SIN 38: 15 41    : g x<0 39: 13 47    : GTO 47 40: 22       : Rv 41: 03       : 3 42: 06       : 6 43: 00       : 0 44: 21       : x<->y 45: 41       : - 46: 13 00    : GTO 00 47: 22       : Rv 48: 13 00    : GTO 00 49: 13 00    : GTO 00
 « Next Oldest | Next Newest »

 Messages In This Thread EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 08:58 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-11-2017, 10:07 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 10:23 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-11-2017, 11:08 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 11:57 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-12-2017, 12:08 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-12-2017, 07:48 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-12-2017, 08:51 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 11:54 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-12-2017, 03:50 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-13-2017, 07:26 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 10:19 AM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-14-2017, 06:39 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 07:38 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-14-2017, 08:46 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 09:40 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-14-2017, 10:36 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 03:04 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-14-2017, 06:23 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 11:31 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-15-2017, 09:01 AM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-15-2017, 09:09 AM RE: EXC/ x<>Rn for stack efficiency - SlideRule - 06-16-2017, 12:39 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-16-2017, 06:59 PM RE: EXC/ x<>Rn for stack efficiency - rprosperi - 06-16-2017, 09:12 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 07:17 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-15-2017, 11:05 AM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-15-2017, 10:29 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-16-2017, 06:32 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-17-2017, 06:03 AM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 11:46 AM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 12:49 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-18-2017, 12:59 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-15-2017, 05:28 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-16-2017, 02:57 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-16-2017, 05:25 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-17-2017, 05:38 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 06:10 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-17-2017, 08:00 PM RE: EXC/ x<>Rn for stack efficiency - GrampaDave - 06-19-2017, 05:44 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-27-2017, 09:42 PM RE: EXC/ x<>Rn for stack efficiency - Thomas Okken - 06-28-2017, 12:42 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-28-2017, 01:37 AM RE: EXC/ x<>Rn for stack efficiency - Thomas Klemm - 07-20-2022 07:03 PM

User(s) browsing this thread: 1 Guest(s)