WP34s program submission: Quadratic fit



#2

This is an implementation of quadratic fit for WP-34s. If only 3 points are entered, this may be used for quadratic interpolation.
Similar function was implemented in HP30b, if you missed it, here it is.

// (C) 2013 Andrew Nikitin
// Fit quadratic polynomial to empirical data

// program operates in stack size 4
// uses regJ and regK to accumulate [SIGMA]x^3 and [SIGMA]x^4
// uses stat registers to accumulate other sums
// stores coefficients of quadrature fit in regA, regB, regC

// Initialize:
// XEQ'QF'
// Clears sums, but not coefficients

// Enter point:
// y ENTER x R/S (or [A])
// Result:
// number of points entered so far

// Calculate coefficients (needs at least 3 points):
// [B]
// Result:
// a=regA=regZ
// b=regB=regY
// c=regC=regX
// (order compatible with SLVQ)

// Evaluate Ax[^2]+Bx+C polynomial:
// x [C]
// Result:
// Ax[^2]+Bx+C

LBL'QF'
SSIZE4
CL[SIGMA]
CLx
STO J
STO K
XEQ 00
STOP
XEQ A
BACK 002
// Accumulate sums, including [SIGMA]x^3 and [SIGMA]x^4
LBL A
[SIGMA]+
RCL L
ENTER
x^3
STO+ J
*
STO+ K
LBL 00
CLx
n[SIGMA]
RTN

// delete point
LBL 65 // XEQ -
[SIGMA]-
RCL L
ENTER
x^3
STO- J
*
STO- K
GTO 00

// Fit quadratic
LBL B
LocR 016
RCL K
STO .03
RCL J
STO .02
STO .06
# 002
n[SIGMA]
x<=? Y
ERR 15
STO .07
[SIGMA]x
STO .04
STO .08
[SIGMA]x[^2]
STO .01
STO .05
STO .09
[SIGMA]y
STO .12
[SIGMA]xy
STO .11
[SIGMA]x[^2]y
STO .10
1
1
3
.
0
3
0
3
ENTER
1
2
2
.
0
3
0
1
# 125
LINEQS
RCL .15
STO A
RCL .14
STO B
RCL .13
STO C
RTN

// Evaluate Ax^2+Bx+C polynomial at regX
LBL C
ENTER
RCL* A
RCL+ B
*
RCL+ C
RTN

END


#3

Hi Andrew,

nice submission. :-)

It will find its way into the library if Pauli or I find the time to integrate it.


#4

It is in the library now :)

I've not included it in the standard library in flash.


- Pauli


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,738 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  Best statistical fit Richard Berler 8 2,565 10-30-2013, 11:25 PM
Last Post: Walter B
  Quadratic & Cubic Regression RPN progs Matt Agajanian 9 2,995 09-17-2013, 11:37 AM
Last Post: Jeff O.
  program print in wp34s Andrew Nikitin 13 3,372 07-22-2013, 10:11 PM
Last Post: Andrew Nikitin
  New empirical fit for ln(x) Namir 0 836 12-11-2012, 12:49 PM
Last Post: Namir
  [WP34S] WP34S firmware on the AT91SAM7L-STK dev kit? jerome ibanes 1 1,232 10-04-2012, 04:59 PM
Last Post: Paul Dale
  New Quadratic Lagrangian Interpolation Method Namir 2 1,393 07-20-2012, 04:32 PM
Last Post: Namir
  Fast Quadratic Formula for the HP-41C Gerson W. Barbosa 21 6,397 07-18-2012, 08:53 AM
Last Post: Gerson W. Barbosa
  Quadratic formula program help Chris C 18 5,044 06-16-2012, 12:14 AM
Last Post: Matt Agajanian
  WP34S program question Mike Maiorana 12 3,266 04-05-2012, 03:09 AM
Last Post: Steve Simpkin

Forum Jump: