The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

35s Quadratic Regression
Message #1 Posted by J Noël on 2 Feb 2011, 11:32 a.m.

I am new to HP programming and recently acquired a 35s. I was surprised to see it cannot do Quadratic Regression, so I wrote a basic program that will develop the twelve inputs necessary to use the built in 3*3 lin. solve equation.

Q001 LBL Q

Q002 CLVARS

Q003 CLSTK

Q004 SF 10

Q005 (eqn) QUADREG

Q006 (eqn) TOTAL SETS

Q007 PSE

Q008 INPUT N

Q009 STO N

Q010 1

Q011 STO M

Q012 (eqn) X

Q013 PSE

Q014 INPUT X

Q015 STO X

Q016 (eqn) Y

Q017 PSE

Q018 INPUT Y

Q019 STO Y

Q020 STO +D

Q021 RCL X

Q022 *

Q023 STO +H

Q024 RCL Y

Q025 RCL X

Q026 (X SQUARED)

Q027 *

Q028 STO +L

Q029 RCL X

Q030 STO +B

Q031 STO +E

Q032 (X SQUARED)

Q033 STO +C

Q034 STO +F

Q035 STO +I

Q036 RCL X

Q037 3

Q038 (Y to the X)

Q039 STO +G

Q040 STO +J

Q041 RCL X

Q042 4

Q043 (Y to the X)

Q044 STO +K

Q045 RCL M

Q046 STO +A

Q047 RCL N

Q048 RCL A

Q049 X<Y

Q050 GTO Q012

Q051 RTN

When it is finished, there will be values stored in memory locations A through L. Launch and Solve the 3*3 lin. solve built-in EQN and R/S your way through the already-saved values. It will return the X, Y, and Z results of the Quadratically Regressed X,Y inputs from the program.

If anyone knows a better way to do this, please share!

JN

REPLACE THIS TEXT WITH YOUR LISTING
      
Re: 35s Quadratic Regression
Message #2 Posted by Namir on 2 Feb 2011, 12:05 p.m.,
in response to message #1 by J Noël

You can download my free HP-35S Stat Pac from here (the download link is near the bottom of that web page), and look for program NCS_POLY1. This program performs quadratic fitting.

Namir

Edited: 2 Feb 2011, 12:06 p.m.

            
Re: 35s Quadratic Regression
Message #3 Posted by J Noël on 2 Feb 2011, 12:47 p.m.,
in response to message #2 by Namir

So if I may ask a newbie question, how do I use the solver to solve for various values of Y (or x) in the equation y=ax^2+bx+c?

                  
Re: 35s Quadratic Regression
Message #4 Posted by Chris Randle (UK) on 2 Feb 2011, 3:39 p.m.,
in response to message #3 by J Noël

Press [EQN]
Type "Y=A*X^2+B*X+C" [ENTER], pressing [RCL] before each letter.
Press (right-shift) [SOLVE]
Type the letter of the unknown - no [RCL] needed this time
Provide a value for each prompted unknown followed by [R/S]
After the final [R/S] the value of the unknown will be calculated and displayed.

This is covered in the user's guide, chapter 7. Pay special attention to the bit about initial guesses in 7-8 as that is of particular importance with a quadratic.

                        
Re: 35s Quadratic Regression
Message #5 Posted by J Noël on 2 Feb 2011, 4:55 p.m.,
in response to message #4 by Chris Randle (UK)

Boy, I feel dumb. I did not put the * symbols between the A and X.

Thank you for the help!

      
Re: 35s Quadratic Regression
Message #6 Posted by Csaba Tizedes (Hungary) on 2 Feb 2011, 4:39 p.m.,
in response to message #1 by J Noël

Years before I wrote this - It wasn't too popular (I dunno whi... :P ;) )

Cs.

            
Re: 35s Quadratic Regression
Message #7 Posted by Norman Dziedzic on 3 Feb 2011, 2:55 p.m.,
in response to message #6 by Csaba Tizedes (Hungary)

I just noticed the 30b has this built in. Another + for the 30b.

From the linked post:

   Excel      HP32SII
A  -2.133E-3  -2.139E-3
B  +6.956E-2  +7.017E-2
C  +9.000E+1  +9.000E+1

for the 30b

A -2.1329E-3
B +6.9560E-2
C +9.0000E+1

                  
Re: 35s Quadratic Regression
Message #8 Posted by Katie Wasserman on 3 Feb 2011, 3:58 p.m.,
in response to message #7 by Norman Dziedzic

The 20b has this as well.

                        
Re: 35s Quadratic Regression
Message #9 Posted by Mark Harman on 3 Feb 2011, 5:22 p.m.,
in response to message #8 by Katie Wasserman

I thought that quadratic regressions were only limited to the 30b. The manual confirms this.

Mark

Edited: 3 Feb 2011, 5:30 p.m.

                              
Re: 35s Quadratic Regression
Message #10 Posted by Katie Wasserman on 4 Feb 2011, 10:14 a.m.,
in response to message #9 by Mark Harman

Mark,

You're right, I stand corrected. I misread the statistics section in the combined 20b/30b manual on this.

Thanks! -Katie

                  
Re: 35s Quadratic Regression
Message #11 Posted by Csaba Tizedes (Hungary) on 4 Feb 2011, 3:29 a.m.,
in response to message #7 by Norman Dziedzic

I hope, you're realized that, my program uses just LINEAR regression to fit quadratic function.

                        
Re: 35s Quadratic Regression
Message #12 Posted by Dieter on 4 Feb 2011, 8:19 a.m.,
in response to message #11 by Csaba Tizedes (Hungary)

Quote:
I hope, you're realized that, my program uses just LINEAR regression to fit quadratic function.
Yes, that's a quite clever approach - though not exactly a strict least-square regression. ;-)

Hmm... since some calculators seem to offer a preprogrammed quadratic regression your idea might be used to fit a cubic function on these models...?

Dieter


[ Return to Index | Top of Index ]

Go back to the main exhibit hall