Post Reply 
Multiple Curve Fitting Program HP-41
01-12-2018, 05:39 AM
Post: #1
Multiple Curve Fitting Program HP-41
Hello

Just came over the book(pdf): Curve Fitting for Programmable Calculators by William M. Colb. In the book is a multiple curve fitting program for HP-41 that seems interesting. I was thinking to convert it to HP42 code, if possible, and then use it with my DM42. The program is 927 lines however and the pdf is not selectable text so copying the program is not that easy. Guess I could do an OCR.
Anyone has this program in selectable text format?

/Andreas
Find all posts by this user
Quote this message in a reply
01-12-2018, 07:06 AM
Post: #2
RE: Multiple Curve Fitting Program HP-41
I had contributed to Tom Okken's library a program that uses matrix commands to perform multiple linear regression. Check it out.
Find all posts by this user
Quote this message in a reply
01-12-2018, 08:48 AM (This post was last modified: 01-12-2018 08:48 AM by Graan.)
Post: #3
RE: Multiple Curve Fitting Program HP-41
Hello Namir

Is it under HP-42S/Free42 Programs? I cannot se it there. What's the name? Or is it in the DM42 Calculator?
Find all posts by this user
Quote this message in a reply
01-12-2018, 01:43 PM
Post: #4
RE: Multiple Curve Fitting Program HP-41
Ok Nice.

Checking the program I find some code I dont recognize (have a 41CX but never used it):
RESZFL
SEEKPTA
FLSIZE
PRAXIS
and some other...
Have to check if there is some equal code in 42S
Find all posts by this user
Quote this message in a reply
01-12-2018, 03:53 PM
Post: #5
RE: Multiple Curve Fitting Program HP-41
(01-12-2018 01:43 PM)Graan Wrote:  Ok Nice.

Checking the program I find some code I dont recognize (have a 41CX but never used it):
RESZFL
SEEKPTA
FLSIZE
PRAXIS
and some other...
Have to check if there is some equal code in 42S

Those first three would be functions for working with files in extended memory (I'm guessing this program stores the stat data there, rather than just accumulating sums). There's no direct equivalent on the 42S, but you can get similar results by using a matrix to store stat data. There's a program which does this in chapter 6 of HP 42S Programming Examples and Techniques. Combining that with the program in Kolb's book would probably be the simplest approach.
Visit this user's website Find all posts by this user
Quote this message in a reply
01-12-2018, 04:17 PM
Post: #6
RE: Multiple Curve Fitting Program HP-41
(01-12-2018 08:48 AM)Graan Wrote:  Hello Namir

Is it under HP-42S/Free42 Programs? I cannot se it there. What's the name? Or is it in the DM42 Calculator?

Look for "mlran" (at, yes, http://thomasokken.com/free42/42progs/).
Visit this user's website Find all posts by this user
Quote this message in a reply
01-12-2018, 04:24 PM
Post: #7
RE: Multiple Curve Fitting Program HP-41
(01-12-2018 01:43 PM)Graan Wrote:  Ok Nice.

Checking the program I find some code I dont recognize (have a 41CX but never used it):
RESZFL
SEEKPTA
FLSIZE
PRAXIS
and some other...
Have to check if there is some equal code in 42S

PRAXIS is a command for the HP-82143A and HP-82162A printers. It prints an axis, and is used as part of the built-in PRPLOT program. It sounds like the program you're looking at can plot its results; translating that functionality to the HP-42S / Free42 / DM42 is not going to be easy, but plotting programs for the 42S do exist, including the PLOT and DPLOT programs from the HP-42S manual, and the slightly fancier versions plot_thomas and dplot_thomas on my web site.
Visit this user's website Find all posts by this user
Quote this message in a reply
01-12-2018, 04:54 PM
Post: #8
RE: Multiple Curve Fitting Program HP-41
I was just thinking to do some simple curvfit since I use to do it in excel for different sensors like NTC resistors etc. connected to microcontrollers. Namirs program seems quite advance. I just need to analyze say 10 to 15 X Y values.
Looking at Colbs program it seems not that hard to translate to HP42 code.
Im not familiar to curvfit theory just a user.
Find all posts by this user
Quote this message in a reply
01-12-2018, 06:04 PM
Post: #9
RE: Multiple Curve Fitting Program HP-41
(01-12-2018 04:54 PM)Graan Wrote:  I was just thinking to do some simple curvfit since I use to do it in excel for different sensors like NTC resistors etc. connected to microcontrollers. Namirs program seems quite advance. I just need to analyze say 10 to 15 X Y values.
Looking at Colbs program it seems not that hard to translate to HP42 code.
Im not familiar to curvfit theory just a user.

Maybe you should now explain what exactly you are looking for. The term "multiple" in your subject line is a bit misleading here.

If you say you have only X and Y-values you are obviously NOT looking for a program that does a multiple (sic!) linear regression. The latter means that the result is a linear combination of multiple independent variables, i.e. y = a + b·x1 + c·x2 + d·x3 + ...

So it looks like you need a program that calculates multiple styles of regression functions, e.g. linear, logarithmic, an exponential or power function, etc. Such a program is included in the HP-41 Standard Applications booklet that comes with the calculator. And it is also listed on this website (but without documentation and instructions).

Dieter
Find all posts by this user
Quote this message in a reply
01-13-2018, 09:42 AM (This post was last modified: 01-13-2018 09:49 AM by Graan.)
Post: #10
RE: Multiple Curve Fitting Program HP-41
Yes thats more what Im looking for.

When working in excel I feed in some measured X and Y values and then select what regression fits the values best. Then I can use the function to get values from different sensors etc.

What I thought however when looking at Kolb's program was that I could feed in X and Y values and the program would select the function with best fit automatically. Is this the case?
Find all posts by this user
Quote this message in a reply
01-13-2018, 11:17 AM (This post was last modified: 01-13-2018 12:31 PM by Dieter.)
Post: #11
RE: Multiple Curve Fitting Program HP-41
(01-13-2018 09:42 AM)Graan Wrote:  Yes thats more what Im looking for.
...
What I thought however when looking at Kolb's program was that I could feed in X and Y values and the program would select the function with best fit automatically. Is this the case?

Of course I can't say anything about the program in the Kolb book, but if you only want to fit an XY-curve with two parameters and choose between a linear, logarithmic, exponential and power fit, and you already have a DM42, why do you think you need a special program? The HP42s (and I suppose DM42 as well) can do this on their own, including the selection of the best fitting model:

Clear the summation registers with CLΣ
For all data pairs: enter Yi ENTER Xi and press Σ+
Press STAT > CFIT > MODL > BEST and see the best-fitting model marked with a "▪"
Of course you can also select a different model if you prefer
Return to the previous menu with EXIT
SLOPE and YINT show the two regression coefficients
CORR shows the correlation coefficient (indicates how well the model fits the data)
FCSTY calculates the y-estimate for a given x
FCSTX calculates the x-estimate for a given y

Example:

Code:
X:  1   3   5   8
Y:  1   5   10  20

CLEAR > CLΣ
 1 ENTER 1  Σ+
 5 ENTER 3  Σ+
10 ENTER 5  Σ+
20 ENTER 8  Σ+

STAT > CFIT > MODL > BEST 
=>  LINF  LOGF  EXPF  PWR▪

So the best fit is a power function.

Code:
EXIT

SLOPE => 1,4367...
YINT  => 1,0073...

CORR  => 0,9999...

So the regression function is  y = 1,007 · x1,437.
And the correlation coefficient shows that this is a very good fit.

Now check how well this model fits the given data:

Code:
1 FCSTY =>  1,007...
3 FCSTY =>  4,883...
5 FCSTY => 10,172...
8 FCSTY => 19,985...

Is this what you are looking for?

Dieter
Find all posts by this user
Quote this message in a reply
01-13-2018, 02:15 PM
Post: #12
RE: Multiple Curve Fitting Program HP-41
Are you familiar with ALSTAT2 Algorithmen der Statistik für Hewlett-Packard HP-41C and the KURV algorithm/program contained in chapter 6 (pgs. 92-107)? Perhaps a member can share this specific content, if it has utility for your purpose(s). You may even be inclined to purchase a personal copy for your continued edification.
[attachment=5557] [attachment=5558]
BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
01-13-2018, 07:50 PM
Post: #13
RE: Multiple Curve Fitting Program HP-41
Dieter, that looks good. Will try it. Thanks!
Find all posts by this user
Quote this message in a reply
01-14-2018, 05:59 PM (This post was last modified: 01-14-2018 06:05 PM by Dieter.)
Post: #14
RE: Multiple Curve Fitting Program HP-41
(01-14-2018 09:04 AM)Mike (Stgt) Wrote:  I suppose you are fit in theory of your subject you messure. So you do know what correlation theoretically exists for the x and y values of your messured points. In this case you don't need a program that tells you 'for this cloud of points (linear | logarithmic | exponential | power) fits best'.

These were also my thoughts. I assume that – for his particular application – Graan will know what kind of physical relation between his X- and Y-values exists. And maybe this is completely different from the standard models that Excel or the 42s CFIT function offer. In this case one could set up an dedicated program for a special regression function.

Dieter
Find all posts by this user
Quote this message in a reply
01-14-2018, 08:52 PM
Post: #15
RE: Multiple Curve Fitting Program HP-41
I have used curvfit for adapting signals from sensors to microprocessors. In simplest case a linear position potentiometer giving position readouts and also tried fitting non linear values from a NTC resistor giving temperature readouts. So its not anything special. I used excel for this trying different models.
Getting my DM42 I just wanted to see if I can do a curvefit on the calculator. Its nothing I have to do, but just of interest. Dieter pointed out the built in functions for curvfit in HP42S.

In Excel there is polynomial curvfit. I have used it some times. I dont know if there is a program for polynomial curvfit for calculators?

Guess I was a bit unclear with my intent. I just found the program by Kolb in a PDF and thought it looked useful, but seems there are other ways as well.
Find all posts by this user
Quote this message in a reply
01-14-2018, 09:26 PM (This post was last modified: 01-14-2018 09:40 PM by SlideRule.)
Post: #16
RE: Multiple Curve Fitting Program HP-41
(01-14-2018 08:52 PM)Graan Wrote:  … I just wanted to see if I can do a curvefit on the calculator … if there is a program for polynomial curvfit for calculators … other ways as well.
You might reference Linear Regression Analysis Using a Programable Pocket Calculator by Paul Evanson (1978) from South Dakota State University for the HP-97 desktop calculator (yes, the title has a typo). This publication might be of some interest/utiltiy, is only 9 pages and has excellent documentation with legible program listing; enjoy.

BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
01-14-2018, 09:52 PM
Post: #17
RE: Multiple Curve Fitting Program HP-41
(01-14-2018 08:52 PM)Graan Wrote:  In Excel there is polynomial curvfit. I have used it some times. I dont know if there is a program for polynomial curvfit for calculators?

Most probably, yes. Fitting a k-degree polynomial does not require much more than solving a linear equation system with k+1 unknowns. The 42s can do this with its built-in matrix functions. The program would accumulate all sums of x0 to x2k as well as y·x0 to y·xk, generate a symmetric matrix from this and the rest is trivial.

Dieter
Find all posts by this user
Quote this message in a reply
01-15-2018, 11:25 AM
Post: #18
RE: Multiple Curve Fitting Program HP-41
Found this Pascal program regarding Akima spline fitting:

http://jean-pierre.moreau.pagesperso-ora...ma_pas.txt

Since I do some Pascal programming I will check it out.
Find all posts by this user
Quote this message in a reply
08-21-2019, 12:10 AM (This post was last modified: 08-21-2019 01:56 AM by PedroLeiva.)
Post: #19
RE: Multiple Curve Fitting Program HP-41
(01-12-2018 05:39 AM)Graan Wrote:  Hello

Just came over the book(pdf): Curve Fitting for Programmable Calculators by William M. Colb. In the book is a multiple curve fitting program for HP-41 that seems interesting. I was thinking to convert it to HP42 code, if possible, and then use it with my DM42. The program is 927 lines however and the pdf is not selectable text so copying the program is not that easy. Guess I could do an OCR.
Anyone has this program in selectable text format?

/Andreas

Graan, I also have this PDF and a BASIC version under going for DOS. One independent variable only but 25 alternative fit options, automatic best fit selection. I will like to have this on my HP 35s calculator that accepts unlimited program steps (almost). Maybe you were intersted in some kind of joint effort? I know nothing about HP41C coding. Pedro
Find all posts by this user
Quote this message in a reply
12-11-2021, 12:25 PM
Post: #20
RE: Multiple Curve Fitting Program HP-41
(01-14-2018 09:26 PM)SlideRule Wrote:  Linear Regression Analysis Using a Programmable Pocket Calculator by Paul Evanson (1978) from South Dakota State University for the HP-97 desktop calculator.

I tried to find this on the school website, but I failed. Can you share a copy with me?
Find all posts by this user
Quote this message in a reply
Post Reply 




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