Post Reply 
Most mind-blowing program for your favorite calculator
07-01-2022, 06:38 AM
Post: #21
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 05:38 AM)pauln Wrote:  The non-mod version of Euclid's algorithm is prohibitively slow but you cannot argue against the elegance of this 5-step solution.

Hi, if you read that REMARK under that magical 5 steps, you can realize, that 5 steps are truly 8 steps and you got totally same as my code, but there are people who wants became Neil Armstrong instead of Buzz Aldrin, but I'm Neil Armstrong Big Grin Big Grin Big Grin

And today I have a bad day, so...

Cs.
Find all posts by this user
Quote this message in a reply
07-01-2022, 07:01 AM
Post: #22
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 06:23 AM)Csaba Tizedes Wrote:  If you remove "LBL/RTN" and "GTO to first line" from my code, you got totally same...

So it is not a really improvement, just looks-like improvement.

(06-30-2022 07:34 AM)Csaba Tizedes Wrote:  The "smallest but workable" is more hard task and required more effort to produce, I guess.

Choose one or the other.

To me it is surprising that it works at all.
I stumbled upon this feature some time ago: HP-15C Bug with MATRIX 5
Find all posts by this user
Quote this message in a reply
07-01-2022, 07:42 AM
Post: #23
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 07:01 AM)Thomas Klemm Wrote:  
(06-30-2022 07:34 AM)Csaba Tizedes Wrote:  The "smallest but workable" is more hard task and required more effort to produce, I guess.

Choose one or the other.

To me it is surprising that it works at all.

Smile Because it was most clever response, than I expected, I'll be patient Big Grin and I'll try to hide my Hungarian temperament...

Cs.
Find all posts by this user
Quote this message in a reply
07-01-2022, 08:07 AM
Post: #24
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 05:38 AM)pauln Wrote:  The non-mod version of Euclid's algorithm …

This mod version program for the HP-15C uses one register but only 8 steps:
Code:
001 -    44  0  STO 0       
002 -       34  x<>y        
003 -       36  ENTER       
004 - 45,10, 0  RCL/ 0      
005 -    43 44  INT         
006 - 45,20, 0  RCLx 0      
007 -       30  -           
008 -    43 20  x=0

Example

CLEAR PRGM

112
ENTER
63
R/S
R↓

7.0000


You are free to add LBL, GTO, R↓ and RTN if you feel like this is cheating.
Find all posts by this user
Quote this message in a reply
07-01-2022, 02:12 PM (This post was last modified: 07-01-2022 02:15 PM by Pälzer.)
Post: #25
RE: Most mind-blowing program for your favorite calculator
I have a (probably stupid?) question about GCD calculation:
is such a calculation also possible with a solver like the HP-17bII ?

I'm not a programmer, mathematician or similar (see also signature) => it should be feasible, I have no idea how that should work?

Edit: typo

8years elementary school and 2y business school, no bachelor or master;
but always interested in simple mathematics and calculators
Find all posts by this user
Quote this message in a reply
07-01-2022, 04:51 PM
Post: #26
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 02:12 PM)Pälzer Wrote:  I have a (probably stupid?) question about GCD calculation:
is such a calculation also possible with a solver like the HP-17bII ?

Yes. Not a stupid question, it's not obvious how this might be done without some math background and experience using the Pioneer Solver.

Download the "Step-by-Step Solutions: Technical Applications (27S/19B)" manual here:

https://literature.hpcalc.org/items/1143

and read the beginning of Chapter 2.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-01-2022, 09:11 PM
Post: #27
RE: Most mind-blowing program for your favorite calculator
(06-18-2022 03:29 AM)Steve Simpkin Wrote:  I had to create a table of elevations and compass headings used to aim a portable 5 foot satellite dish at the Galaxy II geostationary television satellite from about 200 latitude/longitude locations across north America. I obtained the required formulas from a library book, wrote the program, entered it into my HP-25, plugged it into AC power and away I went.

In the early 80's, I too made a program to locate geosynchronous satellites and find their Azimuth And Elevation. But for the 41C. I used the formulas form an old astronomy book.
Find all posts by this user
Quote this message in a reply
07-01-2022, 10:06 PM (This post was last modified: 07-03-2022 01:32 PM by Thomas Klemm.)
Post: #28
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 02:12 PM)Pälzer Wrote:  is such a calculation also possible with a solver like the HP-17bII ?

I came up with the following equation:

GCD:GCD=0×(A+B+Σ(I:1:LN(SQRT(5)×A)÷LN((SQRT(5)+1)÷2):1:IF(B<>0:L(R:MOD(A:B))+L(A:B)+L(B:G(R)):0)))+A

To make it more readable we can format it like so:

GCD:GCD=0×(
  A+B+Σ(
    I:
    1:
    LN(SQRT(5)×A)÷LN((SQRT(5)+1)÷2):
    1:
    IF(B<>0:
      L(R:MOD(A:B))+L(A:B)+L(B:G(R)):
      0
    )
  )
)
+A

We can use the Σ function instead of a for-loop.
But gcd is usually implemented with a while-loop:
Code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

What should be used as limits in the for-loop?
Of course we could just loop from 1 to a.
But can we do better?

The worst case is to have two consecutive Fibonacci numbers.
From this we can make a better estimate for the needed number of loops.

There's a closed formula:

\(
F_{n}=\frac{\varphi^{n}-\psi^{n}}{\sqrt {5}},
\)

where

\(
\varphi = \frac{1+\sqrt{5}}{2}\approx 1.61803\,39887\ldots
\)

is the golden ratio, and \(\psi\) is its conjugate:

\(
\psi = \frac{1-\sqrt {5}}{2}=1-\varphi =-{1 \over \varphi }\approx -0.61803\,39887\ldots .
\)

But for \(n\) big enough we can ignore \(\psi^{n}\) as it goes to \(0\).

We end up with:

\(
a=\frac{\varphi^{n}}{\sqrt {5}},
\)

This can be solved for \(n\):

\(
n = \frac{\log(\sqrt{5} a)}{\log(\varphi)}
\)

Only if \(B \ne 0\) the remainder \(R\) is calculated:

    IF(B<>0:
      L(R:MOD(A:B))+L(A:B)+L(B:G(R)):
      0
    )

The equivalent code in Python would be:
Code:
if b != 0:
    r = a % b
    a = b
    b = r

But we are not interested in that sum, but only in A.
Thus the expression is multiplied by \(0\) and we end up with:

GCD=0×(…)+A

After verifying the equation you should end up with a menu like this:

[ GCD ][  A  ][  B  ]

Examples

112 A
63 B

GCD
CALCULATING...
GCD=7


144 A
89 B

GCD
CALCULATING...
GCD=1
Find all posts by this user
Quote this message in a reply
07-02-2022, 01:48 AM
Post: #29
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 07:42 AM)Csaba Tizedes Wrote:  Smile Because it was most clever response, than I expected, I'll be patient Big Grin and I'll try to hide my Hungarian temperament...

Cs.

You mean you're not one of the Merry Magyars? Big Grin

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
07-02-2022, 09:24 AM
Post: #30
RE: Most mind-blowing program for your favorite calculator
@ rprosperi
@ Thomas Klemm

Thank you very much for the answers.

I didn't know until now that you can also include loops in an equation (in the solver). The manual of the HP-17bII+ says nothing about it.

So far I have only created short equations, like ...
"Gross'Net: Gross = Net + (Net * ST% / 100)"
[ GROSS ][ NET ][ ST% ]

I briefly looked at pages 32-35 of the "Technical App" = too difficult for me.
I will deal with pages 18-27 though, very interesting.
After that I will read in detail the answer of Thomas.

I don't have the mathematical background. Only had 2 years of "simple algebra" as an elective in school (alternatively: office technology/stenography). It was by chance that I had chosen "mathematics" ;-)

further question 1:
is there a thread known which had the topic HP 17b/HP19b + Solver with explanations ?
my search did not find anything, but I may have used the wrong search words.

further question 2.
is there an equation with loop that is "shorter" that I can look at

Thank you for your patience with me

(Translated)

8years elementary school and 2y business school, no bachelor or master;
but always interested in simple mathematics and calculators
Find all posts by this user
Quote this message in a reply
07-02-2022, 10:02 AM (This post was last modified: 07-03-2022 02:26 PM by Thomas Klemm.)
Post: #31
RE: Most mind-blowing program for your favorite calculator
(07-02-2022 09:24 AM)Pälzer Wrote:  further question 1:
is there a thread known which had the topic HP 17b/HP19b + Solver with explanations ?
my search did not find anything, but I may have used the wrong search words.

further question 2.
is there an equation with loop that is "shorter" that I can look at

These two just came to my mind: Meanwhile I also found these: In the attached PDF of the 2nd link on page 4 you can find a description How LET and GET Change an Equation.
This let's us use the following formula iteratively to calculate the GCD:

B=0×(L(R:MOD(A:G(B)))+L(A:G(B))+G(R)

After verifying the equation you should end up with a menu like this:

[  B  ][  A  ]

After entering A and B just keep hitting the B key until the result is 0.
The GCD can then be found in A.

Example

112 A
63 B

B
CALCULATING...
B=49

B
CALCULATING...
B=14

B
CALCULATING...
B=7

B
CALCULATING...
B=0

RCL A
A=7

HTH
Find all posts by this user
Quote this message in a reply
07-02-2022, 11:13 AM (This post was last modified: 07-02-2022 05:42 PM by jonmoore.)
Post: #32
RE: Most mind-blowing program for your favorite calculator
Reading through this thread has reminded me of the classic 70's book Computational Analysis with the HP25 Pocket Calculator (Peter Henrici).

I was fortunate enough to pick up a digital version of this on my travels (print copies command a very high price) and it inspired many a routine on a variety of HP calculators. The link above provides a downloadable PDF copy of the book.

As it happens, Peter Henrichi was responsible for a number of classic computational complex analysis books published by Wiley from the sixties through to the nineties. Three volumes with various reprints were published (due to their popularity), and he published another more general numerical analysis tome titled Elements of Numerical Analysis (Peter Henrici). This last link provides a downable version of the book in many formats via archive.org. It's surprisingly accessible, considering it was first published at a time when math textbooks were particularly inaccessible by modern pedagogic standards.
Find all posts by this user
Quote this message in a reply
07-02-2022, 11:43 AM
Post: #33
RE: Most mind-blowing program for your favorite calculator
(07-02-2022 11:13 AM)jonmoore Wrote:  Reading through this thread has reminded me of the classic 70's book Computational Analysis with the HP25 Pocket Calculator (Peter Henrici).

I was fortunate enough to pick up a digital version of this on my travels (print copies command a very high price) and it inspired many a routine on a variety of HP calculators. The link about provides a downloadable PDF copy of the book.

As it happens, Peter Henrichi was responsible for a number of classic computational complex analysis books published by Wiley from the sixties through to the nineties. Three volumes with various reprints were published (due to their popularity), and he published another more general numerical analysis tome titled Elements of Numerical Analysis (Peter Henrici). This last link provides a downable version of the book in many formats via archive.org. It's surprisingly accessible, considering it was first published at a time when math textbooks were particularly inaccessible by modern pedagogic standards.

Thank you or theseSmile I noticed that the book, Computational Analysis with the HP25 Pocket Calculator, came out in 1977, the same year I bought my HP-25.
Visit this user's website Find all posts by this user
Quote this message in a reply
07-02-2022, 03:38 PM
Post: #34
RE: Most mind-blowing program for your favorite calculator
(07-02-2022 11:13 AM)jonmoore Wrote:  Reading through this thread has reminded me of the classic 70's book Computational Analysis with the HP25 Pocket Calculator (Peter Henrici).

[snip]... and he published another more general numerical analysis tome titled Elements of Numerical Analysis (Peter Henrici). T

Thanks for posting these. I've been tempted when seeing them on eBay, but always too much, just to have in case I find the time.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-02-2022, 05:39 PM
Post: #35
RE: Most mind-blowing program for your favorite calculator
(07-02-2022 03:38 PM)rprosperi Wrote:  
(07-02-2022 11:13 AM)jonmoore Wrote:  Reading through this thread has reminded me of the classic 70's book Computational Analysis with the HP25 Pocket Calculator (Peter Henrici).

[snip]... and he published another more general numerical analysis tome titled Elements of Numerical Analysis (Peter Henrici). T
r

Thanks for posting these. I've been tempted when seeing them on eBay, but always too much, just to have in case I find the time.


1 ENTER +
Find all posts by this user
Quote this message in a reply
07-03-2022, 08:36 AM
Post: #36
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 04:51 PM)rprosperi Wrote:  Download the "Step-by-Step Solutions: Technical Applications (27S/19B)" manual here:

https://literature.hpcalc.org/items/1143

and read the beginning of Chapter 2.

I should have done that before implementing it myself.

Quote:Of particular importance is a formula that gives the maximum number of divisions \(M\) needed to arrive at a zero remainder. This formula is given as:

For \(n > a > b \geq 0\), \(M \approx 2.078 \ln(n) - .328\)

Let's see:

\(
\begin{align}
\frac{1}{\log\left(\varphi\right)} \approx 2.07809
\end{align}
\)

So I assume the same reasoning is being used.
Therefore, you rather use the formula from this manual.
In addition to the GCD, you will also receive the LCM.

Quote:Reference
Knuth, Donald E., The Art of Computer Programming, Vol. 2, Addison-Wesley, Reading, MA, 1969.

I don't have access to this book right now, but I'll check it out next week.
Find all posts by this user
Quote this message in a reply
07-03-2022, 10:14 AM (This post was last modified: 07-03-2022 10:32 AM by xerxes.)
Post: #37
RE: Most mind-blowing program for your favorite calculator
(06-30-2022 05:22 PM)Dan C Wrote:  Isnt the FX-180P the same machine as the FX-3600P, but in a different housing?

Yes. I prefer the FX-3900PV, because it has a nice editor and 300 steps in 4 areas.

GCD on the FX-180P:
Code:
01  x<->y
02  =
03  x^2
04  SQRT
05  x>0
06  x<->y

Usage example: 861 - - 615 P1

And just for fun, the factorial in 4 steps:
Code:
01  Kin*1
02  =
03  x>0
04  Kout1

Usage example: 1 Kin1 - - 69 P1

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
07-03-2022, 12:42 PM
Post: #38
RE: Most mind-blowing program for your favorite calculator
For me it would have to be the humongous Star Trek programs attempted on 70's era machines. "Star Trek Advanced" for the HP-67 in 3-D space no less. And the TI-59 Star Trek game that took IIRC 13 mag cards and was essentially the same as the various Trek games in BASIC at the time.

Personally, I'm a strong proponent of 'use the right tool for the job' philosophy. So I never really saw these as more than just an intellectual exercise. If I wanted to write a similar program, I would have used MS BASIC on an Altair or something similar in those days.

-John
Find all posts by this user
Quote this message in a reply
07-21-2022, 08:41 PM
Post: #39
RE: Most mind-blowing program for your favorite calculator
Valentin's reversi (aka othello) for the 41C. It kicked my 17-year-old butt when I first got it. I was so amazed by it's talent that I spent an evening going through the source code to figure out how it worked.
Find all posts by this user
Quote this message in a reply
07-23-2022, 12:49 AM
Post: #40
RE: Most mind-blowing program for your favorite calculator
.
Hi, David,

(07-21-2022 08:41 PM)David Hayden Wrote:  Valentin's reversi (aka othello) for the 41C. It kicked my 17-year-old butt when I first got it. I was so amazed by it's talent that I spent an evening going through the source code to figure out how it worked.

Thank you very much for your appreciation, I wasn't much older at the time I wrote it. For those interested, these are some relevant links (PDF documents):

HP Program VA428 - UPL PS - HP-41C Othello (00903C)

This is my original submittal to the Hewlett-Packard Users' Program Library (USA) of my HP-41C program Othello at the request of HP UPL's Sandy Canning. Besides my original 15-page submittal, I've also included here four pages of good-quality barcode to allow for fast, error-free entry of the long program into the calculator using the wand.


HP Article VA019 - 25 years of Othello

8-page article to commemorate (2005) the 25th Anniversary of my HP-41C "Othello"-playing program. For those of you who feel nostalgic about the golden past of classic HP calculators, this article reminisces on those wonderful times back when the HP-41C was brand-new and everything seemed possible and everyone was in awe at it.

The article tells the whole story about how my HP-41C "Othello" program came to be, with its downs and its ups (like being featured at the time in an issue of the "Wall Street Journal" magazine), and including previously unpublished letters sent from HP Corvallis to me ("The program has generated a lot of interest in our division"), asking me to submit it to the HP-41C User's Library and awarding me a special "Certificate for Outstanding Contributions" in return.

Also included is a recreation of the original HP-41C "Othello" for the HP-71B with a few minor improvements, which is a 43-line program with full instructions and sample run so that you can test your wits playing this challenging 8x8 board game against it, to try and feel what HP-41C users felt at the time when seeing it for the first time 25 years ago.


HP Letter 1980-08-01 - Letter from Valentin Albillo to Richard Nelson

This August 1980 9-page letter I sent to Richard Nelson includes the very first version for any machine of my Othello program, which was a long, optimized, polished program which would play quite fast a non-trivial game against the user, optionally printing a nice labeled board if a printer was available. Despite there being nothing remotely like it at the time, to my utter disbelief it was never published in Mr. Nelson's PPC Calculator Journal, no reasons given whatsoever, so I wasted one full year waiting for its publication before ultimately getting fed up and looking for greener pastures.

Thanks again, David, and best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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