With the collection of sinus functions $a_1\sin(x)+a_2\sin(2x)+a_3\sin(3x)$ in $[0,\pi]$ I am to approximate $f(x)=e^{-x} $ in the same interval.
My first idea was to find the area under the 2nd function and try approximate that value by changing $a_1, a_2, a_3$ but obviously there's a billion ways to do that, without any of them looking like the desired function.
We have received a tip to use the trapezoidal rule, but I am unsure about how to do this. Hope someone can push me into the right direction.
You are correct: there are many possible ways of defining what the "best fit" between two functions means.
The most common criterion for judging goodness-of-fit is least-square error (LSE). This means that if your approximating function is $g(x)$ and your target function is $f(x)$ and the interval is $[a, b]$ then you adjust the parameters in $g(x)$ to minimise the error function $$E=\int_a^b [f(x)-g(x)]^2 dx$$
For each free parameter $a_1, a_2, a_3...a_n$ of $g(x)$ you set $\partial E / \partial a_j =0$. You then have $n$ simultaneous equations to solve for the $n$ unknown parameters $a_1, a_2, a_3... a_n$.
When the error function $E$ has been minimised it is called the residual error $R$. This provides a figure of merit indicating the goodness of fit, so that $g(x)$ can for example be compared with an alternative fitting function $h(x)$.
In the case of discrete data points the integral becomes a summation and the method reduces to the usual least-squares regression.