I have to find a least squares approximations to the functions cos(x) and exp(x), each on the interval [0,1].
How do I do this??!
to fit cos(x) and exp(x) with, and what is the maximum order of basis
function do you want to use?
For instance do you want a least squares linear approximation, quadratic,
cubic, fourier sin series, cosin series, gaussian sum,...
OK, so those are the answers - but am I going about this the right way?
Take the cosx example - I've written down three equations:
(int stands for integral, from 0 to 1)
and then performed the integrations, done some simultaneous equations and come out with values for a0, a1, and a2; these are the co-efficients for the x^0, x^1 and x^2 terms respectively.
Is this the right method?
what you have been covering in the course that this is a question from.
The most elegant is to use orthonormal polynomials on (0,1), which we may
call P_0(x), P_1(x), and P_3(x), then the coefficients of these polynomials in
the expansion of cos(x) are:
a_0 = integral P_0(x) cos(x) dx x=0,1
a_1 = integral P_1(x) cos(x) dx x=0,1
a_2 = integral P_2(x) cos(x) dx x=0,1
Then the required quadratic polynomial is:
a_0 * P_0(x) + a_1 * P_1(x) + a_2 * P_2(x).
(Note P_0(x) is a constant polynomial the x is just for consistency with
If you don't know the first three orthonormal polynomials on (0,1) you
can find them by applying the Gramm-Schmit process to: 1, x, x^2.