hp41 howto do simple linear regression?


HI. I have the stat pac for hp41, and neither of the linear regressions sets seems to do what I need. I need something that I can input my data (x and y) and from that get R, slope, and y (y=mx+b). Thanks for any guidance .


Well, David, you can always do it the semi-hard way - with just the '41 itself.

If you use the sigma+ button (top left on the keypad)(after clearing the summation registers using the CLSigma button - shift x<>y key, just below the sigma+ key), you can accumulate the sums of x, x^2, y, y^2, and xy in memory registers 11 through 15 respectively, while register 16 will get the value of n (the number of x,y pairs). To put in your numbers, enter y first, then "ENTER", and then enter your x value - then hit the sigma+ key.

After you have entered all you pairs of values, you need to remember (or be told - or, left as an exercise for the student, derive!) the least-squares fitting expressions for slope, intercept, and correlation coefficient. In case you are rusty:

the slope is (n*SUMxy - SUMx*Sumy)/(n*SUMx^2 - (Sumx)^2)

the intercept has the numerator SUMy*SUMx^2 - SUMxy*SUMx
(with the same denominator as for the slope)

r is (n*SUMXY - SUMx*SUMy) / ( SQRT(n*SUMx^2 - (SUMx)^2) * SQRT(n*SUMy^2 - (SUMy)^2) )

I hope my notation is clear. SUMx means the summation of x, and (SUMx)^2 means to square this sum (whereas SUMx^2 means the summation of x-squared).

Have fun.


Boy, that scares me just looking at it. lol. maybe i will try to write a prog for that.



Citation from Dave's append: "After you have entered all you pairs of values, you need to remember (or be told - or, left as an exercise for the student, derive!) the least-squares fitting expressions for slope, intercept, and correlation coefficient."

To ease the exercise for the student just take the values of X as free of error. My little (basic) routine is based on this assumption. Next step in students exercise would be
to take Y values for true and the fault is in X :-)

And if you have some time and piles of paper left, just take X as faulty as Y ;-)




Dave Shaffer's post contains ALL information you need, but you can do it in the "easy way" by using the STAT pack programs.

Get your Stat Pack manual and open it on page 32, under "Curve Fitting". On page 33, top left, you'll see your Y = a + bX expression. Now go to page 34 and you'll see that you should [XEQ] [SIGMA]LIN program for a straight line sample (or any of the other three: LOG, EXP or POW), being [SIGMA] the summation symbol. You should enter each pair in the REVERSED orther (why do some applications are against Y and X registers?), say:

 X [ENTER^] Y [A]
for each pair; to correct any mistakes:
 X [ENTER^] Y [C]
After the last (x,y) pair, simply press [E] and you'll have:

R2 = (corr. coef.) [R/S]
a = (intercept) [R/S]
b = (slope)

Hope this is waht you want. BUT if you really want to know the mechanics, read D. Shaffer's post. It is complete reference.



hi i'm trying to operate my 42s rpn scietific and i can't do a simple problem with it, i don't have a manual or instructions on how to operate it can you help me?


Here is a quick primer







I hope this helps. Depending on how the numbers are set in the stack, you can load the stack with you numbers and the perform the operations all at once.

As in



Have fun.


The HP42S is a tricky beast to master, and much harder without the manual.

Best thing to do is pop it in the post to me and I'll return a much easier to use calculator in exchange... how about a Casio FX580?

But seriously:
The HP42S is a nice tool, once you have mastered it (doesn't take long) you will wonder how you got along without it.

To start using it this site has a brief introduction on RPN.

To get a manual buy the DVD/CD's from this web site, it will be well worth it in the long run.


I just did an 'edit/copy-edit/paste' from my emulator on the IBM-host, so the § stands for Sigma:

01·LBL "§" 
02 §REG 10
03 CL§
05 X<>Y
06 RCL 10
07 ST* Z
08 *
09 RCL 14
10 -
11 X<>Y
12 RCL 11
13 -
14 /
15 STO 04
18 *
19 -
20 STO 05
21 RCL 04
24 RCL 04
25 *
26 X<>Y
27 /
28 END

That's the minimum code, to make life easier just use the Alpha capabilities of the HP-41 and add some literals and prompts.




I did not load the program and run it, but I am curious about one sequence: CL§ and MEAN. How can you compute MEAN if CL§ clears all statistic data?

As you change the §REGS to R10 instead of original R16 and you execute CL§, I thought you created a buffer to compute partial data and return to §REG 16 before using MEAN. But right after that you clear statistic data and execute MEAN with all registers down to zero.

Is that what you want? Did I miss something?

If I am wrong, sorry. I just want to understand.



No, you did not miss something. I gave no clear explanation. This is my LinReg prgm that fits in every HP-41, independent what other BIG routines use up all memory.

There are no literals and no prompts to ease the user input and result output. After line 03 you may add the two lines "Y enter X §+" PROMPT. Without it you just see DATA ERROR and must know that this is the point to enter data.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP prime: linear solver app Alberto Candel 1 1,423 11-21-2013, 01:57 AM
Last Post: Michael Carey
  Simple Tetris. free for you to improve on cyrille de Brébisson 3 1,918 11-20-2013, 05:43 PM
Last Post: Erwin Ried
  HP Prime: Linear Solver app bug BruceH 0 1,133 11-15-2013, 06:36 PM
Last Post: BruceH
  [HP-Prime] Simple Game (Bugs) CompSystems 1 1,416 11-01-2013, 10:18 AM
Last Post: Han
  Quadratic & Cubic Regression RPN progs Matt Agajanian 9 2,921 09-17-2013, 11:37 AM
Last Post: Jeff O.
  New article on a new type of neo linear equations Namir 0 1,269 08-11-2013, 10:27 AM
Last Post: Namir
  Simple Math Question Namir 2 1,394 08-09-2013, 06:13 PM
Last Post: Eddie W. Shore
  Linear Optimization/Programming fhub 14 4,055 08-04-2013, 06:27 AM
Last Post: fhub
  HP-42S with Electroluminescent screen and simple I/O port Jose Poyan 8 2,692 03-27-2013, 07:11 PM
Last Post: Jose Poyan
  Simple sample programs for the HP-41CX? Tom Lewis 5 2,038 03-25-2013, 07:11 PM
Last Post: Allen

Forum Jump: