Favorite HP-41 programs and techniques
01-28-2021, 03:55 PM
Post: #1
 smartin Member Posts: 59 Joined: Jan 2017
Favorite HP-41 programs and techniques
Hello,

After many years of inactivity using the HP-41, I'm getting back into RPN FOCAL programming on the DM41X. To brush up on my skills, I'd like to look at good programming examples. What are your favorite well-crafted FOCAL programs?

Thanks,
Steve
01-28-2021, 04:49 PM
Post: #2
 JMBaillard Junior Member Posts: 27 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
Hi,
well, please take a look at http://hp41programs.yolasite.com
Best regards,
Jean-Marc.
01-28-2021, 04:51 PM
Post: #3
 Dave Britten Senior Member Posts: 2,074 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
Bill Duncan's Time Manager is quite nice:

https://www.hpmuseum.org/software/41/41tmgr15.htm

Requires a CX or Time Module.
01-28-2021, 06:31 PM
Post: #4
 C.Ret Member Posts: 165 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
(01-28-2021 03:55 PM)smartin Wrote:  What are your favorite well-crafted FOCAL programs?

The Greatest Common Divisor & Lowest Common Multiple routine that computes GCD(a,b) & LCM(a,b) and calculates a' = a/GCD(a,b) & b' = b/GCD(a,b) without the use of any flag, registre, subroutine or specific module in no more than sixteen steps.

Code:
  01  LBL "GCD"  02    RCL Y  RCL Y  04    LBL 01  MOD  LASTX  X<>Y  X#0?  GTO 01  10    +  ST/ T  /  ST* Y  X<>Y  LASTX  16  END   ( 29 bytes / SIZE 000 )

Code:
     STACK           INPUTS         OUTPUTS            T                /       a'= a/gcd(a,b)            Z                /       b'= b/gcd(a,b)            Y                a           lcm(a,b)            X                b           gcd(a,b)            L                /           gcd(a,b)
01-28-2021, 11:15 PM
Post: #5
 rprosperi Super Moderator Posts: 5,254 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
Read through the PPC ROM User Manual. There is almost certainly no better single source for clever and well-crafted and extremely well-documented FOCAL programs. These days, lots of people assume the PPC ROM must have been written in MCODE, especially to accomplish many of the advanced functions included, but the PPC ROM created before MCODE was available.

A copy of the complete manual (500+ 8.5x11 pages) is included in the MoHPC Document set, so you may very well already own this; if not, you should get it. Anyone with your interest should have this, it's full of hundreds of great manuals, guides, books, etc.

--Bob Prosperi
01-28-2021, 11:37 PM (This post was last modified: 01-28-2021 11:38 PM by Valentin Albillo.)
Post: #6
 Valentin Albillo Senior Member Posts: 811 Joined: Feb 2015
RE: Favorite HP-41 programs and techniques
(01-28-2021 03:55 PM)smartin Wrote:  To brush up on my skills, I'd like to look at good programming examples. What are your favorite well-crafted FOCAL programs?

Congratulations on your rekindled interest in the HP-41, if you're after non-trivial programs for it you might be interested in some of the ones I wrote for it, namely these 11:

pdf HP Program VA411 - HP-41C Finding Roots of Equations
• 4-page paper featuring a 42-step RPN program for the HP-41C to find real roots of an arbitrary user-supplied equation f(x)=0 using Newton’s method and a user-given initial guess. Interactive and non-interactive versions provided. Five worked examples included.

pdf HP Program VA412 - HP-41C Finding Extrema of Functions
• 3-page paper featuring a 28-step RPN program for the HP-41C to find extrema (maxima and/or minima) of an arbitrary user-supplied function y=f(x) by calling program RF (Root Finder) internally as part of the computation. Two worked examples are included.

pdf HP Program VA413 - HP-41C 3-point Gaussian Integration
• 3-page paper featuring a 55-step RPN program for the HP-41C to evaluate the definite integral between given limits of an arbitrary user-supplied function f(x) using the fast 3-point Gauss-Legendre quadrature formula applied over a number of subintervals. Three worked examples included.

pdf HP Program VA414 - HP-41C Dice Rolling with Graphics
• 3-page paper featuring a 90/62-step RPN program for the HP-41C programmable calculator series to simulate randomly throwing two dice, which are printed graphically followed by their sum.

It includes a subroutine which can be globally called from other programs or from the keyboard to accumulate in the printer buffer the graphics for any single die face. Both Standard and Synthetic Programming versions are included.
pdf HP Program VA415 - HP-41C Systems of 1st-order Differential Equations
• 7-page paper featuring a 137-step program for the HP-41C programmable calculator to obtain quickly and accurately an approximate numerical solution for a system of N simultaneous first-order differential equations or, conversely, a single differential equation of the Nth-order, using a fourth-order Runge-Kutta method. It will also run in the HP-41CV, HP-41CX and the HP42S. Two worked examples included.

pdf HP Program VA416 - HP-41C Mate w King Bishop Knight Practice
• 7-page, 13-diagram paper featuring a 285-step program for the HP-41C programmable calculator (will also run as-is in the HP-41CV or the HP-41CX and with trivial changes in the HP42S as well as in compatible devices or emulators). The program is intended to help the user practice in order to achieve the difficult basic checkmate of King, Bishop and Knight (controlled by the user) vs. King alone (controlled by the program) within a specified number of moves. The user must try and checkmate before the allotted moves elapse while the program does its best to avoid being checkmated.

Two worked examples included, one of them against the world-class chess engine Stockfish 9 (released in 2018 and rated at more than 3,300 ELO), the other against a human user.

pdf HP Program VA417 - HP-41C Systems of Linear Equations - Gauss-Seidel
• 4-page paper featuring a 129-step RPN program for the HP-41C programmable calculator (will also run as-is in the HP-41CV/CX and in the HP42S with trivial changes) to obtain a numerical solution for a system of N algebraic linear equations in N unknowns using the iterative method of Gauss-Seidel, a relaxation/overrelaxation method.

A system of up to 15 equations can be solved if using all 4 memory modules (HP-41C) and the input matrix is left unchanged by the procedure so it can be reused for further processing. Also, full details are given to modify it to use synthetic instructions to save registers, if desired. Two worked examples included.

pdf HP Program VA418 - HP-41C Memory Game and Trainer
• 3-page paper featuring a 142-step fun game RPN program for the HP-41C to challenge your memory by testing your ability to remember what you’ve just seen and offering afterwards an accurate comment on your performance.

pdf HP Program VA419 - HP-41C ESP Tester
• 2-page paper featuring an 85-step fun RPN program for the HP-41C to test your “ESP” (Extra-Sensorial Powers) by conducting a series of 10 tests, after which it reports the % of success and an evaluation of your alleged extrasensorial abilities (if any). One sample run included.

pdf HP Program VA420 - HP-41C Eigenvalues of Symmetric Matrices - Jacobi
• 5-page paper featuring a 215-step RPN program for the HP-41C programmable calculator (will also run as-is in the HP-41CV/CX and in the HP42S with trivial changes) to find all eigenvalues of a real symmetric NxN matrix using the iterative method of Jacobi, which is fast and always converges.

Matrices up to 22x22 can be treated and full details are given about the algorithm and on how to modify the program to use synthetic instructions to save registers, if desired. One worked example and two test cases with solutions included.

pdf HP Program VA421 - HP-41C NxN Matrix Inversion
• 4-page paper featuring a 170-step RPN program I wrote in 1980 for the HP-41C programmable calculator (will also run as-is in the HP-41CV/CX) to compute the inverse of a real NxN matrix (no Advantage module back then), where N ranges from 1 up to 16, using a non-gaussian interchange method.

V.

All My Articles & other Materials here:  Valentin Albillo's HP Collection

01-29-2021, 12:35 AM
Post: #7
 Bill Duncan Member Posts: 85 Joined: Jan 2016
RE: Favorite HP-41 programs and techniques
(01-28-2021 04:51 PM)Dave Britten Wrote:  Bill Duncan's Time Manager is quite nice:

https://www.hpmuseum.org/software/41/41tmgr15.htm

Requires a CX or Time Module.

Thank you Dave! Nice to get some feedback on that as it took a little bit of sweat and, gosh, it was about 2 decades ago.. lol.

I did a similar program a few years ago.

Cheers.
01-29-2021, 12:49 AM
Post: #8
 smartin Member Posts: 59 Joined: Jan 2017
RE: Favorite HP-41 programs and techniques
(01-28-2021 11:15 PM)rprosperi Wrote:  Read through the PPC ROM User Manual. There is almost certainly no better single source for clever and well-crafted and extremely well-documented FOCAL programs. These days, lots of people assume the PPC ROM must have been written in MCODE, especially to accomplish many of the advanced functions included, but the PPC ROM created before MCODE was available.

Even with the DM41X and easy access to the PPC ROM, I haven't dug into it yet and as you correctly pointed out my assumption was that it was heavy MCODE.

I have the manual on the MoHPC doc set. Thanks for the suggestion!

Steve
01-29-2021, 12:54 AM
Post: #9
 smartin Member Posts: 59 Joined: Jan 2017
RE: Favorite HP-41 programs and techniques
(01-28-2021 04:49 PM)JMBaillard Wrote:  Hi,
well, please take a look at http://hp41programs.yolasite.com
Best regards,
Jean-Marc.

I like the understatement at the top of your web site: "This website contains several programs that I've written for this wonderful pocket-calculator: the HP-41C/CV/CX ".

All I can say is Wow!

Lots to look through.

Much appreciated!
Steve
01-29-2021, 01:03 AM
Post: #10
 smartin Member Posts: 59 Joined: Jan 2017
RE: Favorite HP-41 programs and techniques
Thanks everyone else for your suggestions:
C.Ret for the short and sweet GCD,
Bill Duncan's time manager (beautifully documented code, don't see that much),
V. Albillo's targeted list of math solvers (can't wait to see how fast these run on a DM41X).

Steve
01-29-2021, 07:04 AM (This post was last modified: 01-29-2021 07:11 AM by C.Ret.)
Post: #11
 C.Ret Member Posts: 165 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
Thanks,

But just to be clear, I am not the author of the GCD program, I found it a while ago on the http://hp41programs.yolasite.com site.

We all have to congratulate Jean Marc Baillard for sharing all his collection of great HP-41C codes !
01-29-2021, 07:34 AM
Post: #12
 Sukiari Member Posts: 165 Joined: Dec 2014
RE: Favorite HP-41 programs and techniques
(01-28-2021 06:31 PM)C.Ret Wrote:
(01-28-2021 03:55 PM)smartin Wrote:  What are your favorite well-crafted FOCAL programs?

The Greatest Common Divisor & Lowest Common Multiple routine that computes GCD(a,b) & LCM(a,b) and calculates a' = a/GCD(a,b) & b' = b/GCD(a,b) without the use of any flag, registre, subroutine or specific module in no more than sixteen steps.

Code:
  01  LBL "GCD"  02    RCL Y  RCL Y  04    LBL 01  MOD  LASTX  X<>Y  X#0?  GTO 01  10    +  ST/ T  /  ST* Y  X<>Y  LASTX  16  END   ( 29 bytes / SIZE 000 )

Code:
     STACK           INPUTS         OUTPUTS            T                /       a'= a/gcd(a,b)            Z                /       b'= b/gcd(a,b)            Y                a           lcm(a,b)            X                b           gcd(a,b)            L                /           gcd(a,b)

Wow, that’s a neat one. Thanks.
01-29-2021, 08:11 AM (This post was last modified: 01-29-2021 08:23 AM by Peet.)
Post: #13
 Peet Member Posts: 137 Joined: Oct 2020
RE: Favorite HP-41 programs and techniques
I think it's important consider the level of your own knowledge when choosing programs to (re)learn FOCAL.

Unless you have a clue about astronomy or industrial engineering, programs in these areas are certainly not easy to understand and not a good place to start.
Beginners should start with less tricky programs and without or less synthetics, you also should be interested in the topic of the programs.

When I bought the HP-41CV about 40 years ago, the included standard application collection was a very good source and help for me to start with programming the HP41.

HP made an excellent choice of the programs in the collection. All programs were well documented and interesting for most users (no special interest).
At that time I did not only entered them all in, but also modified them to my taste (e.g. I don't like global labels if they don't make sense outside the program).

After I bought the DM41X, I first looked at my old programm collection (I had printed out a lot of the old listings). I tried to understand the usage again (unfortunately I hadn't documented the programs at all at the time) and then even added new subroutines or optimized some of them for the DM41X. So after a long break I got back to a little FOCAL programming.

My advice is to start with programs that interest you on the topic, with easily comprehensible code (e.g. the HP41 Standard Applications) or which you wrote yourself back then.

My calculators - former: CBM PR100, HP41CV, HP11C, HP28S - current: HP48G, HP35S, Prime, DM41X, DM42
01-30-2021, 04:59 PM
Post: #14
 JMBaillard Junior Member Posts: 27 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
I create most of these programs by myself, but there are a few exceptions:
For example, "GCD" is a small modification
of a program created by Philippe Descamps & Jean-Jacques Dhenin
in "Programmer HP-41"
Best wishes,
JM.
02-02-2021, 09:11 PM
Post: #15
 armandine2 Junior Member Posts: 3 Joined: Jan 2021
RE: Favorite HP-41 programs and techniques
(01-28-2021 03:55 PM)smartin Wrote:  look at good programming

Not sure if it is such good programming but I was impressed the other day with a line in the HP41C Math Pac - page 31 Example 1 LBL FX program - it solves for a differential equation which has both arctan(y/x) and root of x^2 +y^2 with a R-P keystroke.
02-02-2021, 09:48 PM
Post: #16
 David Hayden Senior Member Posts: 391 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
HP Key Notes, also in the museum files, has lots of interesting RPN routines.
02-05-2021, 06:03 AM
Post: #17
 Ángel Martin Senior Member Posts: 1,319 Joined: Dec 2013
RE: Favorite HP-41 programs and techniques
(01-28-2021 11:37 PM)Valentin Albillo Wrote:
(01-28-2021 03:55 PM)smartin Wrote:  To brush up on my skills, I'd like to look at good programming examples. What are your favorite well-crafted FOCAL programs?

Congratulations on your rekindled interest in the HP-41, if you're after non-trivial programs for it you might be interested in some of the ones I wrote for it, namely these 11:

Such a collection is claiming for a dedicated ROM image ;-)
 « Next Oldest | Next Newest »

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