# HP 50g User Manual Page 628

Graphing calculator.

«
x y p
«
x SIZE
n
«
x VANDERMONDE
IF 'p<n-1' THEN
n
p 2 +
FOR j
j COL DROP
-1 STEP
ELSE
IF 'p>n-1' THEN
n 1 +
p 1 +
FOR j
x j ^
OBJ
j COL+
NEXT
END
END
y OBJ
ARRY
MTREG
NUM
"
"
"
Save it into a variable called POLY (POLYnomial fitting).
As an example, use the following data to obtain a polynomial fitting with p =
2, 3, 4, 5, 6.
Open program
Enter lists x and y, and p (levels 3,2,1)
Open subprogram 1
Determine size of x list
Open subprogram 2
Place x in stack, obtain V
This IF implements step 3 in algorithm
Place n in stack
Calculate p+1
Start loop j = n-1, n-2, ..., p+1, step = -1
Remove column and drop it from stack
Close FOR-STEP loop
Calculate n+1
Calculate p+1
Start a loop with j = n, n+1, ..., p+1.
Calculate x
ARRY
Convert list to array
Close FOR-NEXT loop
Ends second IF clause.
Ends first IF clause. Its result is X
Convert list y to an array
X and y used by program MTREG
Convert to decimal format
Close sub-program 2
Close sub-program 1
Close main program
n
j
, as a list
Page 18-61