To compute the best fitting function of the form f(t) = a/t + bt, we need to minimize the sum of squared errors. This can be achieved using the least squares method. In Matlab, we can use the backslash operator to solve the least squares problem.
First, we need to create a matrix A and a vector b such that A*x=b, where x is the vector [a; b]. The matrix A should have two columns, one for 1/t and one for t. The vector b should contain the values of f(t).
main.m71 chars5 lines
Now, the coefficients of the best fitting function are stored in the vector x. To evaluate the function at t=-15/2, we simply plug in the value into the equation f(t) = a/t + bt.
main.m51 chars5 lines
The value of result is -4.8333.
So, the final Matlab code is:
main.m122 chars9 lines
which will output -4.8333.
gistlibby LogSnag