Post Reply 
Most mind-blowing program for your favorite calculator
06-18-2022, 01:53 AM (This post was last modified: 06-18-2022 06:10 AM by pauln.)
Post: #1
Most mind-blowing program for your favorite calculator
I'm more specifically thinking in terms of memory constraints (steps/registers): a program that, at first sight, could not possibly fit in the given calculator.

My choice for the TI-59 would be "1287 digits of pi".

In order to achieve this, one needs to use all the digits (including the hidden ones) of 99 of the 100 available registers using 160 steps or less. I have never tried to run the program but I'm guessing the last 5 digits or so are incorrect because of accumulating rounding errors.

What about for your favorite calculator?
Find all posts by this user
Quote this message in a reply
06-18-2022, 03:29 AM (This post was last modified: 06-18-2022 03:38 AM by Steve Simpkin.)
Post: #2
RE: Most mind-blowing program for your favorite calculator
I don’t know if this qualifies but in retrospect it seems kind of far fetched by today’s standards.

I bought my HP-25 in 1977 and used it though high school, four years of college, and my first two years of work as an engineer. While I wrote many small programs to automate tasks, the most complex one was for a project at work around 1984.

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. At the time I didn't have access to a computer with a printer. The "company" computer filled a LARGE room, used punch cards and no one, including the people who manned it, knew how to write new programs for it. The latitude/longitude locations were provided for selected cities in the U.S. that I would have had to enter manually anyway. The HP-25 did the job in a fraction of the time and effort any other method would have required.

You really could do a lot with 49 steps of program memory. HP product do "fill real needs, and provide lasting value".
Find all posts by this user
Quote this message in a reply
06-18-2022, 04:18 AM
Post: #3
RE: Most mind-blowing program for your favorite calculator
(06-18-2022 03:29 AM)Steve Simpkin Wrote:  You really could do a lot with 49 steps of program memory.

Certainly: 49 fully-merged program steps, RPN and the ability to go to an arbitrary step without declaring a label. I'm not sure how programmers were dealing without subroutines though.

Does anybody know why 49 steps and not 50? Seems like a really odd number to me.
Find all posts by this user
Quote this message in a reply
06-18-2022, 04:49 AM (This post was last modified: 06-18-2022 04:51 AM by Steve Simpkin.)
Post: #4
RE: Most mind-blowing program for your favorite calculator
(06-18-2022 04:18 AM)pauln Wrote:  
(06-18-2022 03:29 AM)Steve Simpkin Wrote:  You really could do a lot with 49 steps of program memory.

Certainly: 49 fully-merged program steps, RPN and the ability to go to an arbitrary step without declaring a label. I'm not sure how programmers were dealing without subroutines though.

Does anybody know why 49 steps and not 50? Seems like a really odd number to me.

The HP-25 had an external data chip with sixteen 56-bit registers. Each 56-bit register could hold one BCD number or 7 steps (bytes) of program memory. One register was used for LAST x, 8 for memory registers and 7 for program memory. Thes last 7 registers with 7 bytes each made a total of 49 program steps.

See the Nov 1975 issue of HP Journal for more information.
https://www.hpl.hp.com/hpjournal/pdfs/Is...975-11.pdf
Find all posts by this user
Quote this message in a reply
06-18-2022, 05:44 AM
Post: #5
RE: Most mind-blowing program for your favorite calculator
Thanks, that makes a lot of sense.

For reference, the TI-57 had a little bit more memory with sixteen 64-bit registers, which explains the 11-digit mantissas in the TI-57 as opposed to the 10-digit mantissas in the HP-25.
Find all posts by this user
Quote this message in a reply
06-18-2022, 06:38 AM
Post: #6
RE: Most mind-blowing program for your favorite calculator
Weakest calculator/pocket computer that can do Tower of Hanoi?

(08-11-2018 06:52 PM)Dave Britten Wrote:  Now that would be impressive to see it running on a 25.

Solution



(HP-65) N-Queens

(01-13-2022 10:49 PM)Dave Britten Wrote:  I've been thinking over whether I can cram this onto the HP 25, but it's not coming to me so far. If anybody can manage that, I'll be really impressed...

(25) N-Queens



(29C) Prime numbers up to 10'000

(09-04-2018 12:04 AM)Archilog Wrote:  A guy called C.Ret did an awesome work which can be found there: Silicium ... In French. But the most interesting is easily readable.



How about a pocket / hand held RPL calc?

Quote:Still, if you want to really impress me and, at the same time, make me a true believer of the 17's programming capability, write a version of the N-queens benchmark program for the 17bII+, execute it, and submit the time. ;^) As of yet, nobody has done this. Personally, I think this is a golden opportunity to prove all the naysayers wrong - if possible.

Equation for the 8-queens problem



And then we have this pearl: Gaussian integration for the HP-11C
Find all posts by this user
Quote this message in a reply
06-18-2022, 04:35 PM
Post: #7
RE: Most mind-blowing program for your favorite calculator
Thanks for the list. To me, the N-Queens for the HP-25 is especially mind-blowing in the sense that, if I had to bet, I would have said "no way, that's not possible".
Find all posts by this user
Quote this message in a reply
06-19-2022, 06:06 PM
Post: #8
RE: Most mind-blowing program for your favorite calculator
The HP-25 solution of N-queens is one of my favorites. Very impressive.

The most challenging program on my very first programmable calculator, the FX-180P, was the Collatz conjecture. First I thought, that it's not possible to write a program
for the output of the number of interations and the maximum. But after some effort I managed to do it.

Code:
 01  2
 02  Kin/1
 03  Kout1
 04  -
 05  1
 06  Kin+3
 07  =
 08  1/x
 09  Kout1
 10  Kin2
 11  FIX0
 12  RND
 13  NORM
 14  Kin-2
 15  .
 16  5
 17  Kin+2
 18  Kout2
 19  x>0
 20  6
 21  Kin*1
 22  1
 23  Kin+1
 24  Kout1
 25  x<=M
 26  Min
 27  RTN


Usage example:

KAC Min 27 Kin1 P1

program stops with error

Kout3 -> 111

MR -> 9232

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
06-19-2022, 06:34 PM
Post: #9
RE: Most mind-blowing program for your favorite calculator
I had a TI-59 program in about 1983 with around 1500 steps. Since the '59 didn't have that much memory, I had it prompt for different cards when needed, kind of like disc-swapping. I don't remember anymore what the program was for.

http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, http://wilsonminesco.com/links.html )
Visit this user's website Find all posts by this user
Quote this message in a reply
06-30-2022, 07:34 AM
Post: #10
RE: Most mind-blowing program for your favorite calculator
The "smallest but workable" is more hard task and required more effort to produce, I guess. Here are three from my head during last decade:

1.) Factorial (3 steps) for HP-12C for 1, 2, ..., 69 integers: Factorial (3 steps) HP-12C
2.) GCD (8 steps) for HP15C without MOD: GCD (Greatest Common Divisor) for HP-15C (8 steps) without MOD
3.) Linear regression coefficients (7 steps) for HP-12C: Linear regression coefficients (7 steps) for HP-12C

+1 Bonus) Secant methon on CASIO fx-50F (14 steps)

Code:

The problem:
------------
Solving equations in f(x)=0 form


The solver equation:
--------------------
x[i+1]:= x[i]-f[i]×(x[i]-x[i-1])÷(f[i]-f[i-1])


The variables:
--------------
K1: x[i] (and then x[i+1])
K2: f[i]
K3: x[i-1]
K4: f[i-1]


The program:
------------
a.) The original version used the variables M, K1, K2, K3 and Kout/Kin commands instead of x<->K. This version was 17 steps and can be used for calculating inverse Normal distribution together with the built-in formulas. This shorter version use the K4 like the built-in Normal distribution, therefore it can not to use for calculating inverses (but easy to modify to M, K1, K2, K3 version).

b.) If you use only K variables and x<->K  commands, the length can be reduced by 3 steps (-18% of program and 10% of total memory!):

P1: The secant step
P2: The f(x)

P1:
-----------
01:  Kout1
     -
     x<->K3
     )
     ×
     Kout2
     ÷
     (
     Kout2
     -
     x<->K4
     )
     =
14:  Kin-1
-----------


Usage:
------
a.) Type f(x) into P2
b.) Store x[0] into K1 and K3
c.) Run P2, with this step the f[0] calculated, store it into K4
d.) Store x[1] into K1
e.) Run P2, with this step the f[1] calculated and stored in K2
f.) Run P1, then P2. The display shows the f(x[i]) values
g.) Repeat f.) until the display shows a small or 0 value


Example 1:
==========

The problem:
------------
x^x=10^100; x=?

P2:
-----------
01:  Kout1
     ×
     log
     -
     100
     =
     Kin2      // The result f(x) must to store
-----------

Preparation:
------------
10 Kin1 Kin3 P2 Kin4 100 Kin1 P2

Running:
--------
P1 P2 on the display: -92.6
P1 P2 on the display: -10.1
P1 P2 on the display:   1.66
P1 P2 on the display:  -0.014
P1 P2 on the display:  -1.8E-05
P1 P2 on the display:   0

The result:
-----------
The result is in K1, the previous iteration in K3.
(Unfortunately K1 a little higher than the root, the K1^K1 is overflows, but K3 is OK.)

Kout1: 56.96124843(23)
Kout3: 56.96124013(76)



Example 2:
==========

The problem:
------------
x^3=3^x and x<3; x=?

P2:
-----------
01:  Kout1
     x^y
     3
     -
     3
     x^y
     Kout1
     =
     Kin2
-----------

Preparation:
------------
2.5 Kin1 Kin3 P2 Kin4 2 Kin1 P2

Running:
--------
P1 P2 on the display:  7.3E-3
P1 P2 on the display:  1.4E-3
P1 P2 on the display: -6.2E-6
P1 P2 on the display:  5.1E-9
P1 P2 on the display:  0

The result:
-----------
Kout1: 2.478052680(32)
Kout3: 2.478052683(32)

nJoy!
Cs.
Find all posts by this user
Quote this message in a reply
06-30-2022, 03:40 PM (This post was last modified: 06-30-2022 03:41 PM by Maximilian Hohmann.)
Post: #11
RE: Most mind-blowing program for your favorite calculator
Hello!

(06-19-2022 06:34 PM)Garth Wilson Wrote:  I had a TI-59 program in about 1983 with around 1500 steps. Since the '59 didn't have that much memory, I had it prompt for different cards when needed, kind of like disc-swapping. I don't remember anymore what the program was for.

I still have four cards for my Ti59 that were required to numerically solve a system of differential equations. This must have been around the same year, 1982 or 83, part of an excercise for a university course "numerical methods for solving differential equations in engineering" (or similar).
The alternative to swapping cards on my Ti59 at home would have been to queue in front of a keypunch at the university computer center.

That was probably the most intense thing I ever did with a programmable calculator, although I would not call it "mind blowing" as in the thread title. Rather brute force or "not using the right tool for the job".

Regards
Max
Find all posts by this user
Quote this message in a reply
06-30-2022, 04:36 PM
Post: #12
RE: Most mind-blowing program for your favorite calculator
(06-30-2022 03:40 PM)Maximilian Hohmann Wrote:  although I would not call it "mind blowing" as in the thread title. Rather brute force or "not using the right tool for the job".

LOL. Well, I got the TI-58c in Dec '81 for $100 at Jewelcor (remember those stores, which sold jewelry, electronics, cameras, etc.?), and perhaps a year later was in the right place at the right time to trade it and another $100 for a 59 and printer and some extra modules. I have a friend who paid $3K for an Apple II and extra memory and accessories probably a little before that, and the Commodore 64 would come out just after that for $600 (and monitor, disc drives, etc. were extra). There were no laptops yet, and the home computers were not portable like a calculator that took only a corner in the attache case. I took a class in FORTRAN IV in '82 at the local community college, and of all our assignments, I could get results much faster with my calculator than I could writing out the FORTRAN on coding sheets, going to the computer lab at school and sitting at the card-punch machine, then rubber-banding the set, along with my account number, and putting it in a cubby and coming back a couple of hours later hoping they had run it, only to find a printout of all the reasons it wouldn't run, and have to repeat this non-interactive process. It was kind of like in the movie "The Computer Wore Tennis Shoes" (the original from 1969, not the later 1995 one), where Medfield College was given this computer, free, because it was already so outdated.

http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, http://wilsonminesco.com/links.html )
Visit this user's website Find all posts by this user
Quote this message in a reply
06-30-2022, 05:22 PM (This post was last modified: 06-30-2022 05:51 PM by Dan C.)
Post: #13
RE: Most mind-blowing program for your favorite calculator
(06-19-2022 06:06 PM)xerxes Wrote:  The most challenging program on my very first programmable calculator, the FX-180P, was the Collatz conjecture. First I thought, that it's not possible to write a program
for the output of the number of interations and the maximum. But after some effort I managed to do it.

I must try this, the FX-180P was my first real technical calculator!
I used it in the "Gymnasiet" in Sweden, and FX-180P was a very popular machine in Sweden at that time.
I have the FX-180P still, and its in a good working condition.

edit: Isnt the FX-180P the same machine as the FX-3600P, but in a different housing?
Find all posts by this user
Quote this message in a reply
06-30-2022, 07:59 PM
Post: #14
RE: Most mind-blowing program for your favorite calculator
(06-19-2022 06:34 PM)Garth Wilson Wrote:  I had a TI-59 program in about 1983 with around 1500 steps. Since the '59 didn't have that much memory, I had it prompt for different cards when needed, kind of like disc-swapping. I don't remember anymore what the program was for.

Could that have been the program to calculate speaker crossover networks?
Find all posts by this user
Quote this message in a reply
06-30-2022, 08:57 PM
Post: #15
RE: Most mind-blowing program for your favorite calculator
(06-30-2022 07:59 PM)KeithB Wrote:  Could that have been the program to calculate speaker crossover networks?

No, but it seems to be missing from my files, so I can't find what it might have been. It might have had to do with my amateur-radio hobby.

http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, http://wilsonminesco.com/links.html )
Visit this user's website Find all posts by this user
Quote this message in a reply
07-01-2022, 03:00 AM
Post: #16
RE: Most mind-blowing program for your favorite calculator
(06-30-2022 04:36 PM)Garth Wilson Wrote:  
(06-30-2022 03:40 PM)Maximilian Hohmann Wrote:  although I would not call it "mind blowing" as in the thread title. Rather brute force or "not using the right tool for the job".

LOL. Well, I got the TI-58c in Dec '81 for $100 at Jewelcor (remember those stores, which sold jewelry, electronics, cameras, etc.?), and perhaps a year later was in the right place at the right time to trade it and another $100 for a 59 and printer and some extra modules. I have a friend who paid $3K for an Apple II and extra memory and accessories probably a little before that, and the Commodore 64 would come out just after that for $600 (and monitor, disc drives, etc. were extra). There were no laptops yet, and the home computers were not portable like a calculator that took only a corner in the attache case. I took a class in FORTRAN IV in '82 at the local community college, and of all our assignments, I could get results much faster with my calculator than I could writing out the FORTRAN on coding sheets, going to the computer lab at school and sitting at the card-punch machine, then rubber-banding the set, along with my account number, and putting it in a cubby and coming back a couple of hours later hoping they had run it, only to find a printout of all the reasons it wouldn't run, and have to repeat this non-interactive process. It was kind of like in the movie "The Computer Wore Tennis Shoes" (the original from 1969, not the later 1995 one), where Medfield College was given this computer, free, because it was already so outdated.

Ha! I took a Fortran class at Cal Poly Pomona, California in 1983 and it was the same exact process! Sometimes my batch did not get run until the following day. It took forever to debug a program this way. It really encouraged you write it carefully the first time so you wouldn't have to go through those time consuming steps. I had bought an Ohio Scientific Challenger 1P computer in 1979 ($350) and had written a number of BASIC programs before this class. Using punch cards and waiting for your program to be run seemed like a huge step backwards compared to my rather primitive Challenger (which I still have). I understand they got rid of the card-punch machines at that college the following year. I also remember Jewelcor. I bought my HP-11C at one in 1987 ($56). I think they went out of business a few years after that.
Find all posts by this user
Quote this message in a reply
07-01-2022, 05:02 AM
Post: #17
RE: Most mind-blowing program for your favorite calculator
(06-30-2022 07:34 AM)Csaba Tizedes Wrote:  2.) GCD (8 steps) for HP15C without MOD: GCD (Greatest Common Divisor) for HP-15C (8 steps) without MOD

These programs to calculate the GCD use only 5 steps:

HP-11C
Code:
001 -    42 20  x>y       
002 -       34  x<>y      
003 -       30  -         
004 -    43 36  LSTx      
005 -    42 40  x=y

HP-15C
Code:
001 - 43,30, 7  TEST 7      
002 -       34  x<>y        
003 -       30  -           
004 -    43 36  LSTx        
005 - 43,30, 5  TEST 5

Example

CLEAR PRGM

112
ENTER
63
R/S

7.0000



Remark: These steps must be the only ones in memory.
Otherwise the program will not jump to the first line if the condition in line 005 is false.
Find all posts by this user
Quote this message in a reply
07-01-2022, 05:38 AM
Post: #18
RE: Most mind-blowing program for your favorite calculator
The non-mod version of Euclid's algorithm is prohibitively slow but you cannot argue against the elegance of this 5-step solution.
Find all posts by this user
Quote this message in a reply
07-01-2022, 06:23 AM (This post was last modified: 07-01-2022 06:31 AM by Csaba Tizedes.)
Post: #19
RE: Most mind-blowing program for your favorite calculator
(07-01-2022 05:02 AM)Thomas Klemm Wrote:  
Remark: These steps must be the only ones in memory.
Otherwise the program will not jump to the first line if the condition in line 005 is false.

And what is the whole program if I want to use the calculator for other valuable tasks also, not only for stupid number theory?!? Smile
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. Like give a blanket a homeless, instead of improving social circumstances.

Thanks!
Cs.
Find all posts by this user
Quote this message in a reply
07-01-2022, 06:35 AM
Post: #20
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

Well, it depends.
The worst case for the mod version is using two consecutive Fibonacci numbers.
E.g. 144 and 89.

\(
\begin{matrix}
a & b & n = \lfloor a \div b \rfloor & r = a - n \times b \\
144 & 89 & 1 & 55 \\
89 & 55 & 1 & 34 \\
55 & 34 & 1 & 21 \\
34 & 21 & 1 & 13 \\
21 & 13 & 1 & 8 \\
13 & 8 & 1 & 5 \\
8 & 5 & 1 & 3 \\
5 & 3 & 1 & 2 \\
3 & 2 & 1 & 1 \\
2 & 1 & 2 & 0 \\
\end{matrix}
\)

The non-mod version uses the same amount of steps but avoids division and multiplication.
Thus it is even faster.

However with something like 9,999,999,999 and 2 I totally agree.
But in such cases you may calculate the remainder once manually to bring both numbers into the same ballpark.
Of course you could still end up with a pathological case like 9,999,999,999 and 99,998 where that has to be repeated.
But that is usually not the case.
Find all posts by this user
Quote this message in a reply
Post Reply 




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