Polynomial regression: Difference between revisions

Content added Content deleted
(→‎{{header|TI-89 BASIC}}: add explanation)
Line 487: Line 487:


=={{header|TI-89 BASIC}}==
=={{header|TI-89 BASIC}}==
<lang ti-89>seq(x,x,0,10)→xs
<lang ti-89>DelVar x
seq(x,x,0,10) → xs
{1,6,17,34,57,86,121,162,209,262,321}→ys
{1,6,17,34,57,86,121,162,209,262,321} → ys
QuadReg xs,ys
QuadReg xs,ys
Disp regeq(x)</lang>
Disp regeq(x)</lang>

<code>seq(''expr'',''var'',''low'',''high'')</code> evaluates ''expr'' with ''var'' bound to integers from ''low'' to ''high'' and returns a list of the results. <code> →</code> is the assignment operator. <code>QuadReg</code>, "quadratic regression", does the fit and stores the details in a number of standard variables, including <var>regeq</var>, which receives the fitted quadratic (polynomial) function itself. We then apply that function to the (undefined as ensured by <code>DelVar</code>) variable x to obtain the expression in terms of x, and display it.


Output: <code>3.·x<sup>2</sup> + 2.·x + 1.</code>
Output: <code>3.·x<sup>2</sup> + 2.·x + 1.</code>