/** This tests the least-squares fitting routines in LeastSquares.frink */ use LeastSquares.frink points = [[1,1], [2,3], [3,3], [4,5], [6,4]] xvalues = new array yvalues = new array for [x,y] = points { xvalues.push[x] yvalues.push[y] } println["xvalues is $xvalues"] println["yvalues is $yvalues"] // Fit the values to a polynomial of the specified degree ls = LeastSquares.fitDegree[xvalues, yvalues, 2] println[ls.toMatrix[].formatMatrix[]] symbolicMode[true] println[ls.toExpression[]] println[ls.toArray[]] println["Residual is " + ls.residual[]]