EXC/ x<>Rn for stack efficiency
06-15-2017, 09:01 AM (This post was last modified: 06-15-2017 10:36 AM by Dieter.)
Post: #21
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-14-2017 11:31 PM)Matt Agajanian Wrote:  Great Circle Navigation

This is a classic example for what I said earlier. Try to understand how the program works and recode it. 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.

Regarding the EXC instruction: that's obsolete as well. Take a look at the code. In line 84/85 an inverse cosine is calculated and stored in R2 while the previous content oF R2 is recalled and checked whether its sine is > 0. If not, 360 minus the previous result is returned. You could replace the EXC instruction with the code in my first post, so a literal translation would look this way:

Code:
... COS^-1 RCL 2 X<>Y STO 2 R↓ SIN X>0? GTO nn  // jump to the final RCL 2 3 6 0 RCL 2 - STO 2 RCL 2   // jump target RTN

But this is not required. In RPN this can be done more elegantly since the previous result is still on the stack:

Code:
... COS^-1 RCL 2 SIN X>0? GTO nn  // jump to the final R↓ R↓ CHS 3 6 0 + ENTER R↓      // jump target RTN

The complete program can be turned into a more compact HP25/33 version. But I am sure that HP25 great circle programs already exist. ;-)

Edit: a direct translation of the 100-step SR56 program is hard to do in 49 steps. However, if the final 360–x procedure is omitted it will fit. Otherwise a few more steps are required.

Edit2: I see the SR56 program calculates the great circle distance in nautical miles which is diplayed in step 62. But what is the angle that is calculated afterwards and returned as the second result? Matt, can you post the instructions and an example for this program?

Dieter
06-15-2017, 09:09 AM
Post: #22
 Paul Dale Senior Member Posts: 1,839 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-15-2017 09:01 AM)Dieter Wrote:  But I am sure that HP25 great circle programs already exist. ;-)

There is one in the 25's Applications Programs book.

Pauli
06-15-2017, 10:29 AM
Post: #23
 Paul Dale Senior Member Posts: 1,839 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
It ought to be possible to calculate the distance using the modified Vincenty formula on the 25:

->P will calculate the square root of the sum of squares in the numerator and ->R will calculate the arctangent of the ratio.

- Pauli
06-15-2017, 11:05 AM (This post was last modified: 06-17-2017 07:23 PM by Dieter.)
Post: #24
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-14-2017 11:31 PM)Matt Agajanian Wrote:  General Aircraft Weight and Balance

A strange program – I'm not sure at all what it does.

But there are lots of EXC instructions between line 10 and 27. There are even consecutive EXC commands that neutralize each other. #-) If you take a closer look at this you will realize that the sequence with all these obscured EXC commands simply does this: Store an entry in R4, then check if R0 is zero. If yes, add the previous entry to R2, otherwise add R3*entry to R2. At the end R0 is left unchanged.

Of course this can be coded much more effectively and simpler:

Code:
... STO 4 RCL 0 X=0? GTO nn  -----+ R↓           | RCL 3        | x            | ENTER        | R↓      <----+ STO+2

That's shorter and less obscure.
BTW, the STO 4 is not required, neither in the SR56 program nor in the translation above: R4 is not used elsewhere in the program.

Edit: the instructions for this program say that the previous entry may be recalled by RCL 4, e.g. for correcting the last entry, so this is the reason why the input is stored in R4 although this register is not recalled in the program itself.

While I am still not sure what the program is supposed to do (what are these 3, 4 and 5 prompts for?) I think it can be done in 30 steps on an HP25 or 33. Or three more if the program initially resets R1 and R2 to zero, which I think it should do. Here is an experimental, completely untested first attempt at this:

Code:
01  STO 0 02  CLX 03  STO 1 04  STO 2 05  3 06  R/S 07  STO 3 08  4 09  R/S 10  RCL 0 11  X=0? 12  GTO 17 13  R↓ 14  RCL 3 15  x 16  ENTER 17  R↓ 18  STO+2 19  RCL 3 20  STO+1 21  5 22  R/S 23  X≠0? 24  GTO 07 25  RCL 1 26  R/S 27  RCL 2 28  R/S 29  RCL 2 30  RCL 1 31  / 32  R/S 33  GTO 21

And finally in the original SR56 program all these obscure EXC-sequences could be avoided like this:

Code:
... 10  STO 11  4 12  CP 13  RCL 14  0 15  x=t? 16  2 17  2 18  RCL 19  3 20  PRD 21  4 22  RCL 23  4 24  SUM 25  2

That's even four steps shorter.

Dieter
06-15-2017, 05:28 PM (This post was last modified: 06-15-2017 05:29 PM by Matt Agajanian.)
Post: #25
 Matt Agajanian Senior Member Posts: 1,079 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
Dieter,

Thanks for the extra effort. Although I started challenging myself to translate my SR-56 programs into RPN since I got an HP-34C and TI-58C in '78, (already had an SR-56 in 77) yes it was more of a part of my hobby to translate these just for the challenge and to engulf myself in my hobby. I would opt for the opportunity to test myself and translate rather than make it easier to find an identical/similar program in an HP solution book/application library instead.

Creature of old habits in Pasadena.
06-16-2017, 02:57 AM
Post: #26
 Matt Agajanian Senior Member Posts: 1,079 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
Dieter, here are the App Library pages to complete the documentation.

Great Circle Navigation (Intro page)

Great Circle Navigation (User Instructions)

Great Circle Navigation (example)
06-16-2017, 12:39 PM
Post: #27
 SlideRule Senior Member Posts: 1,488 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-15-2017 09:01 AM)Dieter Wrote:  ... post the instructions and an example...

The source can also be viewed at V. Toth's TI site under the sub-heading
SR-56 Applications
at pages;
T to π & π to T Transformations (142-147)
Great Circle Navigation (159-162)
General Aviation Weight & Balance (176-179)

BEST!
SlideRule
06-16-2017, 05:25 PM
Post: #28
 Matt Agajanian Senior Member Posts: 1,079 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
Yes, I know. Rather than have members scroll through 100+ pages in the PDF there, I took a snapshot of the pages directly from my Dropbox folder.
06-16-2017, 06:32 PM
Post: #29
 Matt Agajanian Senior Member Posts: 1,079 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(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:

->P will calculate the square root of the sum of squares in the numerator and ->R will calculate the arctangent of the ratio.

- Pauli

So, Pauli, If I were to use this formula correctly, what are the inputs for the ->P and ->R operations? It seems obvious, but to avoid mistakes, how should I interpret the X and Y registers for both ->P and ->R operations? Thanks.
06-16-2017, 06:59 PM
Post: #30
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-16-2017 12:39 PM)SlideRule Wrote:  The source can also be viewed at V. Toth's TI site under the sub-heading
SR-56 Applications
at pages;
...

Ah, great – thank you very much.

It's a real flashback to the early times of programmable calculators. A program for solving linear equations with two unknowns that flashes "SOS" (i.e. 505) when the determinant is zero, a quadratic solver where the program works slightly different from what the instructions say, prompting for input data by displaying "1", "2" and "3", the choice of simplified algorithms that fit into merely 100 unmerged steps... those were the days. ;-)

Dieter
06-16-2017, 09:12 PM
Post: #31
 rprosperi Super Moderator Posts: 6,393 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-16-2017 06:59 PM)Dieter Wrote:  It's a real flashback to the early times of programmable calculators. A program for solving linear equations with two unknowns that flashes "SOS" (i.e. 505) when the determinant is zero, a quadratic solver where the program works slightly different from what the instructions say, prompting for input data by displaying "1", "2" and "3", the choice of simplified algorithms that fit into merely 100 unmerged steps... those were the days. ;-)

The thing about nostalgia is we always remember things better or worse than they really were. It's just hard to tell which applies here...

--Bob Prosperi
06-17-2017, 06:03 AM
Post: #32
 Paul Dale Senior Member Posts: 1,839 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-16-2017 06:32 PM)Matt Agajanian Wrote:  So, Pauli, If I were to use this formula correctly, what are the inputs for the ->P and ->R operations? It seems obvious, but to avoid mistakes, how should I interpret the X and Y registers for both ->P and ->R operations? Thanks.

I'd recommend reading the manual for a RPN calculator

Pauli
06-17-2017, 11:46 AM (This post was last modified: 06-17-2017 11:47 AM by Dieter.)
Post: #33
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-17-2017 06:03 AM)Paul Dale Wrote:  I'd recommend reading the manual for a RPN calculator

That's always a good advice. ;-)

(06-15-2017 10:29 AM)Paul Dale Wrote:  ->P will calculate the square root of the sum of squares in the numerator and ->R will calculate the arctangent of the ratio.

I'd say that ->P calculates both the sqrt of the sum of squares and the arctan of the ratio.

Dieter
06-17-2017, 12:49 PM
Post: #34
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-16-2017 06:32 PM)Matt Agajanian Wrote:  So, Pauli, If I were to use this formula correctly, what are the inputs for the ->P and ->R operations? It seems obvious, but to avoid mistakes, how should I interpret the X and Y registers for both ->P and ->R operations? Thanks.

This is a basic info which you will find in any manual of you RPN calculators. However, in this case the ->R function is not required, instead ->P does both calculations.

The ->P function takes two rectangular coordinates in X and Y and converts them to polar coordinates, i.e. a distance and an angle:

Code:
input        output ----------------------   y        arctan(y/x)   x        √(x² + y²)

Now take a look at the nominator of the posted formula. There are two terms that are squared and then the sqrt of the sum is calculated. That's exactly what the ->P function returns in X. Try 3 ENTER 4 and a simple ->P returns 5, which is shorter and faster than 3 x² 4 x² + √.

Then take a look at the whole fraction. The arctangent of a quotient has to be calculated. That's what the ->P function returns in Y. Actually the result may be slightly different from a simple arctan(y/x) as there is a certain sign convention for the angle, but let's neglect this here.

So you may calculate the two terms under the square root in the nominator first (without squaring them), then ->P returns the result of the complete nominator. Then calculate the denominator (with the previous result still in y) and another ->P returns the arctan of the quotient in Y. Since ->P x<>y is not shorter than a division and arctan (two steps in both cases) the only advantage of the ->P method may be that if the denominator is negative the returned angle is positive: arctan(1/–1) returns –45° while 1 ENTER –1 ->P yields +135°.

Dieter
06-17-2017, 05:38 PM
Post: #35
 Matt Agajanian Senior Member Posts: 1,079 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
I'm sorry. It seems my earler post was quite unclear.

Yes, I've rather aware that R->P operations return both numerator and denominator for the revised GCN formula. But, I intended to ask about the four latitude, longitude, and delta values.
06-17-2017, 06:10 PM (This post was last modified: 06-17-2017 06:11 PM by Dieter.)
Post: #36
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-17-2017 05:38 PM)Matt Agajanian Wrote:  I'm sorry. It seems my earler post was quite unclear.

Yes, I've rather aware that R->P operations return both numerator and denominator for the revised GCN formula.

Not quite. While R–>P can be used to calculate the nominator it does not help with the denominator. OTOH it can be used to determine the arctan of the quotient.

(06-17-2017 05:38 PM)Matt Agajanian Wrote:  But, I intended to ask about the four latitude, longitude, and delta values.

OK – sorry if I have to ask again, English is not my native language, but... what do you want to ask about these values?

Phi1 and 2 are the two latitudes and Lambda1 and 2 are the longitudes, resp. ΔLambda their difference.

Dieter
06-17-2017, 07:17 PM (This post was last modified: 06-17-2017 09:07 PM by Dieter.)
Post: #37
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-16-2017 09:12 PM)rprosperi Wrote:  The thing about nostalgia is we always remember things better or worse than they really were. It's just hard to tell which applies here...

While we're at it:

Quote:"Herman the moonshiner makes a weekly delivery to the Hogs Haven Pub. Normally it takes 1 hour, 27 minutes, and 52 seconds to go from his still to Possum Flats and 2 hours, 3 minutes, and 17 seconds from there to Hogs Haven. How long does the trip take?"

Ah, this sounds familiar. A short story that introduces a problem which is then solved by means of your new calculator. May this be a quote from the HP-25 manual? Or from the 67's?

You won't believe it, but this is the introduction to the hour, minute, second arithmetics program for the TI SR–56 (!). Obviously TI liked the HP style so much that they decided to do something similar in their own Applications Library manual. ;-)

Dieter
06-17-2017, 08:00 PM
Post: #38
 Matt Agajanian Senior Member Posts: 1,079 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-17-2017 06:10 PM)Dieter Wrote:
(06-17-2017 05:38 PM)Matt Agajanian Wrote:  I'm sorry. It seems my earler post was quite unclear.

Yes, I've rather aware that R->P operations return both numerator and denominator for the revised GCN formula.

Not quite. While R–>P can be used to calculate the nominator it does not help with the denominator. OTOH it can be used to determine the arctan of the quotient.

(06-17-2017 05:38 PM)Matt Agajanian Wrote:  But, I intended to ask about the four latitude, longitude, and delta values.

OK – sorry if I have to ask again, English is not my native language, but... what do you want to ask about these values?

Phi1 and 2 are the two latitudes and Lambda1 and 2 are the longitudes, resp. ΔLambda their difference.

Dieter

Thank you. Dieter, your language skills are excellent. It's my misunderstanding of the equation that caused confusion. Now I understand the variables.
06-18-2017, 12:59 AM
Post: #39
 Paul Dale Senior Member Posts: 1,839 Joined: Dec 2013
RE: EXC/ x<>Rn for stack efficiency
(06-17-2017 12:49 PM)Dieter Wrote:  However, in this case the ->R function is not required, instead ->P does both calculations.

Oops

Quote:Since ->P x<>y is not shorter than a division and arctan (two steps in both cases) the only advantage of the ->P method may be that if the denominator is negative the returned angle is positive: arctan(1/–1) returns –45° while 1 ENTER –1 ->P yields +135°.

There is also an advantage when the denominator is zero. This alone makes it worthwhile I think.

Pauli
06-19-2017, 05:44 PM
Post: #40
 GrampaDave Junior Member Posts: 6 Joined: Jan 2017
RE: EXC/ x<>Rn for stack efficiency
Quote:Herman the moonshiner

But HP had better names, whose sly humor made them memorable, at least to native English speakers.

Radio Engineer Ann Tenor
Arctic explorer Jean-Claude Coulaire
Logistics specialist Justin Tyme

(I confess I made up that last one, but it's exactly in the HP style.)
 « Next Oldest | Next Newest »

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