Fitting $\cos(x)$ with a polynomial Consider the graph of $\cos(x)$ on the interval $[-\pi/2,\pi/2]$. It looks very close to a parabola. I would like to find the parabola (or possibly family of parabolas) that "fit" the $\cos$ function the best on this interval.
By "fit" the best, I mean I want to minimize the absolute area between the curves as much as possible, i.e. minimize $$\int_{-\pi/2}^{\pi/2}|\cos(x)-p_2(x)|dx,$$
where $p_2$ is a degree $2$ polynomial.
My initial approach was to look at the Taylor approximation about $x=0$ of degree $2$
$$\cos(x)\approx1-\frac {x^2}2$$

The area between these curves is $2-\pi-\frac{\pi^3}{24}\approx0.15403$. Surely we can do better.
I then looked at the interpolating polynomial through the points $(-\pi/2,0),(0,1),(\pi/2,0)$, which gives the function $1-\frac{4x^2}{\pi^2}$.

The area between these two curves is $\frac23(\pi-3)\approx0.094395$. Better!
Next, I tried looking what quadratic, with vertex $(0,1)$, satisfies $$\int_{-\pi/2}^{\pi/2}\cos(x)-p_2(x)dx=0.$$
We then find that $p_2(x)=1-\frac{12(\pi-2)}{\pi^3}x^2$. 

So, there area between these two curves is $0$, but the absolute area is approximately $0.0539276$. Checking numerically, this appears to be the best-fitting parabola that has vertex $(0,1)$.

Is the polynomial $p(x)=1-\frac{12(\pi-2)}{\pi^3}x^2$ the unique quadratic that minimizes $$\int_{-\pi/2}^{\pi/2}|\cos(x)-p_2(x)|dx,$$
  where $p_2$ is a degree two polynomial?

Of course, it could be that there is a better-fitting polynomial that does not have its vertex at $(0,1)$. If not, then I simply ask:

Find a quadratic polynomial $p_2(x)$ that minimizes $$\int_{-\pi/2}^{\pi/2}|\cos(x)-p_2(x)|dx.$$

Now, this can be extended to other degree polynomials. For example, the best fitting constant is $c=\sqrt{2}/2$, and that gives $$\int_{-\pi/2}^{\pi/2}|\cos(x)-\frac{\sqrt2}2|dx=2(\sqrt2-1)\approx0.82843.$$ This raises my more general question.

Let $n\in\mathbb{N}$ and let $p_n(x)$ be an $n$th degree polynomial. For each $n$, what polynomial minimizes  $$\int_{-\pi/2}^{\pi/2}|\cos(x)-p_n(x)|dx?$$

 A: This is NOT a complete answer. Let me offer few observations that might help someone figure out a complete answer.
The problem is to find (I am assuming $b=0$ in the solution) $a$ and $c$ such that $\int_{0}^{\pi/2}|\cos(x)-(ax^{2}+c)|dx$ is minimized. (The switch from $[-\pi/2,\pi/2]$ to $[0,\pi/2]$ is by the symmetry of the problem around $0$).
First order conditions w.r.t. $a$ and $c$ (by the usual principle of wishful thinking) are
$$\newcommand{\sgn}{\mathop{\rm sgn}}
\begin{aligned}
\int_{0}^{\pi/2}\sgn{(\cos(x)-(ax^{2}+c))}(-x^2)dx&=0\\
\int_{0}^{\pi/2}\sgn{(\cos(x)-(ax^{2}+c))}(-1)dx&=0\\
\end{aligned}$$
The second equation says that the areas where the approximation is above the original function and is below have to be equal.
My conjecture is that this implies that the approximation and the original function have to intersect twice on $[0,\pi/2]$ (if only once then if the second equation holds the first cannot). But this is pure speculation.
Taking the idea of two intersections seriously, denote the intersections, that is solutions to $\cos(z)=az^2+c$ on $[0,\pi/2]$ by $x$ and $y>x$. The two first order conditions then become
$$\begin{aligned}
{}[-z]_{0}^{x}+[z]_{x}^{y}+[-z]_{y}^{\pi/2}&=0\\%
{}[-z^3/3]_{0}^{x}+[z^3/3]_{x}^{y}+[-z^3/3]_{y}^{\pi/2}&=0\\%
\end{aligned}$$
which solves to $y=\frac{1}{8}\pi(\sqrt5+1)$ and $x=\frac{1}{8}\pi(\sqrt5-1)$. Finding $a$ and $c$ such that $\cos{z}=az^2+c$ for $z\in\{x,y\}$ gives (thank you Mathematica)
$$\begin{aligned}
a&=-\frac{32\sin{(\frac{\pi}{8})}\sin{(\frac{\sqrt{5}\pi}{8})}}{\sqrt5\pi^2}\\%
c&=\cos{(\tfrac{\pi}{8})}\cos{(\tfrac{\sqrt{5}\pi}{8})}\frac{3\sin{(\frac{\pi}{8})}\sin{(\frac{\sqrt{5}\pi}{8})}}{\sqrt{5}}
\end{aligned}$$
which is approximately  $a=-0.427001$ and $c=0.985095$. The area is then approximately (taking $[-\pi/2,\pi/2]$) equal to $0.0449071$. (This shows that Oleg567 above in the comments has done an amazing job).
