/-\ /-\ /   \ / /-\ /|\ /T\
P-/ O | |    Y  |    I   |
|   | | |    |  F-   |   |
\   \-/ L-/  |  \   \|/  |

Files

POLYFIT.8xp is the program.
POLYINFO.8xp is the documentation.
POLYFIT.8xg is both grouped.

Instructions

Put X values in L3 and Y values in L4. Run Polyfit to put the polynomial of least degree with the points in Y1. The terms and coefficients in [A] are reversed.

Used Variables

A
B
C
Str1
Str2
L1
L2
L3
L4
[A]
[B]
Y1

Display Idea

Float
Func
Connected
Full
CoordOff
GridOff
AxesOff
LabelOff
ExprOff
FnOff
FnOn 1
PlotsOff
Plot1(Scatter,L3,L4,o)
Append ZoomStat to Polyfit code.

Note

Polyfit fails if any X values are equal and on no, incomplete, and too many points. ZoomStat fails if all Y values are 0.

Code

dim(L3->A
(Ans,And->dim([A]
List|>matr(L4,[B]
{0,1->L1
{0->L2
For(B,1,A
 1->[A](B,1
 For(C,1,A-1
  L3(B)^C->[A](B,C+1
 End
End
[A]^-1[B]->[A]
Ans(1,1->L2(2
LinReg(ax+b) Y1
Equ|>String(Y1,Str1
sub(Str1,1,length(Str1)-3->Str1
For(B,2,A
 [A](B,1->L2(2
 LinReg(ax+b) Y1
 Equ|>String(Y1,Str2
 B-1->L2(2
 Str1+"+"+sub(Str2,2,length(Str2)-3->Str1
 LinReg(ax+b) Y1
 Equ|>String(Y1,Str2
 Ans+"X^"+sub(Str2,1,length(Str2)-3->Str1
End
String|>Equ(Ans,Y1