Polynomial regression: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 470:
3.0000
</pre>
 
=={{header|freebasic}}==
<lang freebasic>
 
Sub GaussJordan(matrix() As Double,rhs() As Double,ans() As Double)
Dim As Integer n=Ubound(matrix,1)
Line 514:
Next z
End Sub
'Interpolate through points.
Sub Interpolate(x_values() As Double,y_values() As Double,p() As Double)
Line 529:
GaussJordan(matrix(),rhs(),p())
End Sub
'Evaluate a polynomial at x by Horner method
Function polyeval(Coefficients() As Double,byval x As Double) As Double
Line 538:
Return acc
End Function
'======================== SET UP THE POINTS ===============
Dim As Double x(1 To ...)={0,1,2,3,4,5,6,7,8,9,10}
Dim As Double y(1 To ...)={1,6,17,34,57,86,121,162,209,262,321}
Redim As Double Poly(0)
'Get the polynomial Poly()
Interpolate(x(),y(),Poly())
'print coefficients to console
print "Polynomial Coefficients:"
Line 558:
End If
Next z
sleep
</lang>
Console output:
<pre>
Polynomial Coefficients:
 
Line 575 ⟶ 576:
x^ 9 = 0
x^ 10 = 0
 
 
</pre>
 
 
 
Anonymous user