Q:

Compute $ \min_{a,b,c \in \mathbb{R}} \int_{-1}^1 |e^x-a-bx-cx^2|^2dx $

The question is the following:

Compute 
  $$ \min_{a,b,c \in \mathbb{R}} \int_{-1}^1 |e^x-a-bx-cx^2|^2dx $$

I tried to expand the integral, and it gives me:
$$
\int_{-1}^1 |e^x-a-bx-cx^2|^2dx=  2a^2+\frac{2}{3}(2ac+b^2)+\frac{2}{e}(a-2b+5c)-2e(a+c)+\frac{2}{5}c^2+\frac{1}{2}(e^2-e^{-2}) 
$$
Here I have no idea how to proceed.
I also consider the following: we can rewrite
$$ \min_{a,b,c \in \mathbb{R}} \int_{-1}^1 |e^x-f(x)|^2dx $$
where
$$
f(x) = a+bx+cx^2
$$
So the question is basically to find a degree 2 polynomial to approximate $e^x$ as close as possible. But  this idea seems to be off the subject I learned. Thanks for any help and hint. 

A:

You are looking for the closest point of $\exp$ to the span of the fuctions $x\mapsto x^k$, $k=0,1,2$ with the norm $\|f\|^2= \int_{-1}^1 |f(x)|^2 dx$
and associated inner product.
The Legendre polynomials $P_n$ are orthogonal, and $P_0,P_1,P_2$ have
the same span as $x\mapsto x^k$, $k=0,1,2$, so the closest point will be
$\sum_{k=0}^2 {1 \over \|P_n\|^2} \langle P_n, \exp \rangle P_n $.

A:

Hint.
You can compute the derivative of $f(a,b,c):=\int_{-1}^{1} | e^x - a - bx - cx^2 |^2 dx$ with respect to $a$, $b$ and $c$ and set them to zero to find the values of $a,b$ and $c$ that minimise that expression.
Values for comparison

 We have $\frac{df(a,b,c)}{da} = 4 a + \frac{4c}{3} - 2( e - e^{-1})$ and $\frac{df(a,b,c)}{db} = \frac{4 b}{3} - 4 e^{-1}$. The latter gives us $b = 3 e^{-1}$. Finally, $\frac{df(a,b,c)}{dc} = \frac{4 a}{3} + \frac{4 c}{5} - 2 e + 10e^{-1}$. According to WolframAlpha we have $a = \frac{3 (11 - e^2)}{4 e}$ and $c = \frac{15 (e^2 - 7)}{4 e}$. This yields $f(a,b,c) =  36 - \frac{259}{2 e^2} - \frac{5 e^2}{2} \approx 0.00144$.

Edit Notice that we have $a \approx 0.996$, $b \approx 1.104$ and $c \approx 0.537$, so $a + bx + c x^2 \approx 1 + x + \frac{1}{2} x^2$, which are the first three terms of the Taylor series for $e^x$.

