# Approximate a function using another function

Problem
Find the best approximation of $f(t)=t^2$ with $h(t)=ae^t+be^{2t}+c$ everywhere on the interval $[0,4]$.

Attempt
I know how to solve this problem given sample points, by using least squares, but I am having a hard time figuring out how to setup this problem. I know that I need to use the inner product, $\int_0^4f(t)h(t)dt$. The issue I'm having is with putting this problem in the form of $Ax=b$. Normally I would construct the Gram matrix using the inner product and basis vectors, but no basis vectors were given.

How do I proceed with setting this up?

-

You are asked to approximate $f$ by functions in the form of $h$, so you are already given three basis "vectors" $e^t, e^{2t}$ and $1$ in the function space endowed with an inner product $\langle p,q\rangle = \int_0^4 p(t)q(t)dt$. Since $1, e^t, e^{2t}$ do not form an orthonormal basis, you should first apply the Gram-Schmidt process to find an orthonormal basis $\{g_1,g_2,g_3\}$ for the function space spanned by $1, e^t, e^{2t}$. Then the required approximation is just the projection of $f$ into $\operatorname{span}\{g_1,g_2,g_3\}$, i.e. $\langle f,g_1\rangle g_1+\langle f,g_2\rangle g_2+\langle f,g_3\rangle g_3$.