00 { 196-Byte Prgm } 01▸LBL "ASINIT" 02 ABS 03 IP 04 STO ST Y 05 8 06 × 07 2 08 + 09 1 10 NEWMAT 11 STO "ASTACK" 12 CLX 13 R↓ 14 INDEX "ASTACK" 15 STOEL 16 RTN 17▸LBL 10 18 CLX 19 SF 25 20 INDEX "ASTACK" 21 FC?C 25 22 -1 23 RTN 24▸LBL "APOP" 25 XEQ 10 26 X≠0? 27 RTN 28 RCLEL 29 I+ 30 RCLEL 31 X≠0? 32 GTO 01 33 -2 34 RTN 35▸LBL 01 36 8 37 × 38 5 39 - 40 1 41 STOIJ 42 CLA 43 8 44▸LBL 11 45 RCLEL 46 I+ 47 ARCL ST X 48 R↓ 49 DSE ST X 50 GTO 11 51 FS?C 01 52 GTO 04 53 2 54 1 55 STOIJ 56 RCLEL 57 1 58 - 59 STOEL 60▸LBL 04 61 CLST 62 RTN 63▸LBL "APUSH" 64 XEQ 10 65 X≠0? 66 RTN 67 RCLEL 68 I+ 69 RCLEL 70 X=Y? 71 GTO 02 72 1 73 + 74 STOEL 75 8 76 × 77 5 78 - 79 1 80 STOIJ 81 8 82 R↑ 83▸LBL 09 84 ASTO ST X 85 STOEL 86 I+ 87 ASHF 88 DSE ST Y 89 GTO 09 90 SF 01 91 GTO "APOP" 92 END
31 December 2018
Alpha stack on the HP-41C and HP-42S
The "N Queens" problem
10 DESTROY ALL @ DELAY 0
20 OPTION BASE 1 @ STD
30 INTEGER R,C,S,T,F,N,K 40 REAL WOK, let's set up a few variables.
50 INPUT "Board size 1-9: ";S 60 IF S>9 OR S<1 THEN 50
70 INTEGER B(S) @ DISP "Working..." 80 R=0 @ F=0 @ N=0 @ W=TIME
90 R=R+1 @ IF R>S THEN 190 100 C=0
110 C=C+1 @ IF C>S THEN 170
120 T=0 130 N=N+1
140 T=T+1 @ IF T>=R THEN 160
150 IF B(T)=C OR ABS(B(T)-C)=R-T THEN 110 ELSE 140
160 B(R)=C @ GOTO 90
170 R=R-1 @ IF R=0 THEN 230 180 C=B(R) @ GOTO 110
190 F=F+1 200 F$ = "Found " @ FOR K=1 TO S @ F$ = F$ & STR$(B(K)) @ NEXT K 210 F$ = F$ & " (" & STR$(F) & ")" @ DISP F$
220 R=R-1 @ GOTO 110
230 W=TIME-W @ IF W<0 THEN W=W+86400
240 DISP "SOLUT:" & STR$(F) & ", NODES:" & STR$(N)
10 DESTROY ALL @ DELAY 0 20 OPTION BASE 1 @ STD 30 INTEGER R,C,S,T,F,N,K 40 REAL W 50 INPUT "Board size 1-9: ";S 60 IF S>9 OR S<1 THEN 50 70 INTEGER B(S) @ DISP "Working..." 80 R=0 @ F=0 @ N=0 @ W=TIME 90 R=R+1 @ IF R>S THEN 190 100 C=0 110 C=C+1 @ IF C>S THEN 170 120 T=0 130 N=N+1 140 T=T+1 @ IF T>=R THEN 160 150 IF B(T)=C OR ABS(B(T)-C)=R-T THEN 110 ELSE 140 160 B(R)=C @ GOTO 90 170 R=R-1 @ IF R=0 THEN 230 180 C=B(R) @ GOTO 110 190 F=F+1 200 F$ = "Found " @ FOR K=1 TO S @ F$ = F$ & STR$(B(K)) @ NEXT K 210 F$ = F$ & " (" & STR$(F) & ")" @ DISP F$ 220 R=R-1 @ GOTO 110 230 W=TIME-W @ IF W<0 THEN W=W+86400 240 DISP "SOLUT:" & STR$(F) & ", NODES:" & STR$(N)
29 December 2018
Numerical solver - Newton-Raphson method
The three zeroes are therefore $x=-3, x=1$ and $x=4$.
And here is the equivalent in BASIC for HP-71:
10 DESTROY ALL @ DELAY 0 20 REAL X,Y,Y1,E @ INTEGER P,M 30 P=FLAG(-17)+2*FLAG(-18)+4*FLAG(-19)+8*FLAG(-20) @ E=10^(-P) @ M=2*P+8 40 INPUT "GUESS? ";X 50 Y=FNF(X) @ IF ABS(Y)<E THEN 120 60 "X=" & STR$(X) 70 Y1=(FNF(E+X)-FNF(X))/E 80 IF Y1=0 THEN "CONSTANT?" @ END 90 X=X-Y/Y1 100 IF M>0 THEN M=M-1 @ GOTO 50 110 "NO CONVERGENCE" @ END 120 "ZERO: " & STR$(X) @ END 130 DEF FNF(X) = (X+3)*(X-1)*(X-4)
27 December 2018
Numerical Integration - Simpson's Rule
\[ \int_a^{a+2h} \! f(x) \, \partial{x} \approx \frac{h}{3}(f(a)+4\cdot f(a+h)+f(a+2h)) \]
In this example, I'm getting all four machines to calculate:
\[ \int_0^1 \! (x^4-3x^3+x^2+1) \, \partial x \]
The exact answer to this is $ \frac{47}{60} \approx 0.7833333 $
In all examples I'm using 4 as the number of steps/divisions to use, which actually equates to $2^4=16$, i.e. I broke the [0;1] interval down into 16 smaller intervals (hence the progress counting up in increments of $\frac 1 {16} $= 6.25%).
26 December 2018
Is it really a Hewlett Packard?
25 December 2018
HP Prime benchmark
You can download the benchmark app from here: Benchmark.hpappdir.zip
Egg timer in a 41CX
- Set the alpha register as you would if creating an alarm manually. So, that's with a message, blank, or with a global label (refer to the Time Module manual for details).
- Enter the time to count down in the form HH.MMSS (e.g. 0.0530 for 5m30s)
- Run CDOWN (either XEQ it or assign it to a USER key)
The archive contains a text listing of the program that's compatible with hp41uc and dm41.swissmicros.com, a .raw file and a printable PDF with wand bar codes.
Times are a-changing
The first post on this blog goes back to September 2009 and we are now about to go into 2019. So many things have changed since then.
The original idea behind this blog was to publish periodical tips and tricks mainly related to GNU/Linux and other POSIX operating systems on one hand, and Symbian mobile phones on the other. Guess what... I no longer use GNU/Linux as my main operating system because I'm no longer self-employed and the work that I now do means that using MS-Windows is my only real option. I still use Linux on a handful of Amazon Web Services EC2 machines and on virtual machines at home and at work, but my main workstations are Windows 10 machines.
So, what about mobile phones and Symbian? We all know what happened to that. Nokia discontinued Symbian and switched to Microsoft's Windows Mobile platform, and sold the mobile division to Microsoft, who promptly killed it off. A Chinese manufacturer took out a license to build and sell mobile phones under the Nokia brand and that is what's on sale now, although it has very little to do with the Nokia brand of yesteryear.
Not only that but, no longer being self-employed, I don't have the freedom to organise myself as I want, which has left me little time to post anything here for a number of years, although I'm hoping to be able to start posting again in the not too far future given that I will be far less involved in 41 Club in just over 3 months from now, when I step down from the Association's National Executive.
If you've seen my previous post on this blog from nearly 18 months ago (although I have kept it up to date since then!) then you'll know that I've revived a collection that I started when I was in my early '20s living in France, a collection of calculators. Not just any calculators, though. There is so much Chinese crap flooding the market, cheap "4-bangers" (calculators with the 4 basic operations) that cost pennies and flimsy, plasticky scientific machines that look like they'll break if you look at them wrong. I don't want any of that. What I want is well-built machines that feel solid and are programmable and I have a distinct preference for stuff that was popular in the '70s and '80s. I am also involved, on an entirely voluntary basis (I'm not a member of their staff and I don't get paid!), with a Zürich-based company called "SwissMicros", who build calculators that behave like some of the popular models made by Hewlett Packard in the '80s.
Edit: November 2020. I have been working part time for SwissMicros as an independent contractor since July this year.
So, that is how my interests have shifted over the past 10 years. You can now expect a few blog entries about vintage calculators :)
If this is of interest to you then another blog you might want to consider following is Eddie Shore's Math and Calculator Blog.