E-Code

Least squares with matrices (Vandermonde) — a TI-89 Titanium program

By E-Code · updated

MFIT89 is a TI-89 BASIC program for the TI-89 Titanium. X and Y lists and a degree 1-3: builds the Vandermonde matrix V and solves (VᵀV)c = VᵀY — exact coefficients for exact data — with R² and a prediction.

What it asks for and what it shows

It asks for 4 values at its prompts. In the example below it shows C0, C1, C2, R², YHAT.

Example run

One of its oracle test cases: “exact parabola y = 2x²+1”. The inputs are typed in order, and the results are the values the case expects on the screen.

StepValue
You enter
Input 1{0,1,2,3}
Input 2{1,3,9,19}
Input 32
Input 44
The screen shows
C0=1
C1=0
C2=2
R²=1
YHAT=33

How it's checked

6 test cases, each checked against an independent method. Replayed key by key on a virtual TI-89 Titanium, they make 43 checks.

How E-Code checks every program

Run it or put it on your calculator

Related programs

All TI-89 Titanium statistics programs · All TI-89 Titanium programs