Arbitrary Function

This is an interesting program.  You put a function in the subroutine “curve” that you think approimates the shape of the curve that your data lies on. You then make guesses concerning the constant coefficients of your function, add the data points and crank!  The program will spit the curve coeffcients out and allow you to interpolate! The smaller the max error the better the results are, and of course, the longer the program runs (that was a problem on the Apple II).

Downloads:

Basic program (liberty basic) - arbitreg.bas

 

Test case;

The straight line function, y=a(1)+a(2)*x was used.

Arbitrary Function Regression
program will fit data to a general curve supplied in program
an example is: y=a(1)+a(2)*x
place the equation in the subroutine 'function'
you must provide guesses for the coefficients a1...an
you must specify a max error (start with something large like .01)

desired max error? .0001
number of coefficients (a1...an)? 2

estimate of a(1)=  2
estimate of a(2)=  3

number of points to input? 5
x(1)=  1
y(1)=  7
x(2)=  2
y(2)=  11
x(3)=  3
y(3)=  15
x(4)=  4
y(4)=  19
x(5)=  5
y(5)=  23

coefficient a(1)= 3.00019887
coefficient a(2)= 3.99994576

root mean square error= 0.85780714e-4

Interpolation (enter x=q to end program) x= 0
y= 3.00019887

Interpolation (enter x=q to end program) x= 100
y= 402.994775

Interpolation (enter x=q to end program) x= q