# HP Forums

You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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

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
```

Namir

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

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?

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.

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

Cs.

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

Thank you for the help!

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

```   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
```

The 20b has this as well.

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

Mark

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

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

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

Mark,

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

Thanks!
-Katie