Distance between a polynomial and the exponential Consider the space $L^2(-1,1)$ and the subspace $M = \text{span}\{1,t,t^2\}$, the space generated by all polynomials of degree $2$, then for the function $x(t) = e^t$ the idea is to calculate the distance,
$~d(x(t), M)~.$
I know, if I have a Hilbert space $H$ and $M \le H$ a closed subspace. For all $x \in H$, exist an unique $z \in M$ such that $||x - z || = \displaystyle\inf_{m \in M} \{||x - m||\}$.
I'd like to use this instead of doing a lot of calculations, but I don't know how to find the $z$.
 A: You want the unique element $a+bt+ct^2$ such that
$$
      \langle e^t-a-bt-ct^2,1\rangle = 0 \\
       \langle e^t-a-bt-ct^2,t\rangle = 0 \\
        \langle e^t-a-bt-ct^2,t^2\rangle = 0
$$
That's a straightforward matrix solve. It's just tedious.
$$
    \left[\begin{array}{ccc}
      \langle 1,1\rangle & \langle t,1\rangle & \langle t^2,1\rangle \\
      \langle 1,t\rangle & \langle t,t\rangle & \langle t^2,t\rangle \\
      \langle 1,t^2\rangle & \langle t,t^2\rangle & \langle t^2,t^2\rangle
          \end{array}\right]\left[\begin{array}{c}a \\ b \\ c\end{array}\right]=\left[\begin{array}{c}\langle e^t,1\rangle \\ \langle e^t,t\rangle \\ \langle e^t,t^2\rangle\end{array}\right]
$$
You could use Gram-Schmidt, but the calculations are the same. These terms in the matrix are $0$:
$$
           \langle t,1\rangle=\langle 1,t\rangle = 0, \\
            \langle t,t^2\rangle =\langle t^2,t\rangle = 0,\;\; 
$$
Finally, the distance from $e^t$ to $a+bt+ct^2$ is
\begin{align}
          \|e^t-a-bt-ct^2\|^2&=\langle e^t-a-bt-ct^2,e^t-a-bt-ct^2\rangle \\
           &= \langle e^t-a-bt-ct^2,e^t\rangle \\
           &= \langle e^t,e^t\rangle-a\langle 1,e^t\rangle-b\langle t,e^t\rangle-c\langle t^2,e^t\rangle
\end{align}
