a) Find $a$ and $b$ such that $\displaystyle \int_0^1 |x^2 - ax - b| \,dx$ is minimum.
b) How about $\displaystyle \int_0^1 |x^2 - ax - b|^2 \,dx$?
This is what I did for part a):
If $D=a^2+4b\leq 0$ then $|x^2-ax-b| =x^2-ax-b$ and we have:
$ I= \int_0^1 |x^2-ax-b|\,dx = \int_0^1 (x^2-ax-b)\,dx ={1\over 3}-{a\over 2}-b$
and
$I \geq {1\over 3}-{a\over 2}+{a^2\over 4} = {1\over 12}+{(a-1)^2\over 4} $
so $I_{min}\leq {1\over 12}$ and $I= {1\over 12}$ iff $a= 1$ and $b = -{1\over 4}$.
But, I can not handle easyl case $D>0$.
Part (b) is more immediately clear to me:
\begin{align*} \int_0^1 |x^2+ax+b|^2 \, dx &= \int_0^1 (x^2+ax+b)^2 \, dx\\[0.3cm] &= \int_0^1 (x^4+2ax^3+(a^2+2b)x^2 + 2abx+b^2) \, dx\\[0.3cm] &= 1/5 + a^2/3 + 2 b/3 + b^2 + a/2 + ab \end{align*}
Let $S=1/5 + a^2/3 + 2 b/3 + b^2 + a/2 + ab.$ This is extremised when $\partial S/\partial a = \partial S/\partial b = 0$ so $2a/3+b+1/2=0$ and $a+2b+2/3 =0$.
Solving we find $a=-1$, $b=1/6$.
As for (a): Let's assume that both roots of the quadratic are in $[0,1]$, and call them $c$ and $d$ with $c \leq d$. Then
$$ \int_0^1 |(x-c)(x-d)|dx = \int_0^1 (x-c)(x-d) dx - 2\int_c^d |(x-c)(x-d)|dx, $$ which is
$T = 1/3 - c/2 - c^3/3 - d/2 + cd + c^2 d - c d^2 + d^3/3.$
Again we want $\partial T/\partial c = \partial T/\partial d = 0$, so $-1/2 - c^2 + d + 2cd - d^2 = 0$ and $-1/2 + c + c^2 - 2cd + d^2= 0$. This gives two solutions:
$c=1/2$, $d=1/2$ and $c=1/4$, $d=3/4$.
so the two solutions are $a=-1$, $b=1/4$ and $a=-1$, $b=3/16$.
But which is the minimum? Well, $\displaystyle\int_0^1 |x^2-x+1/4| dx = 1/12$ while $$\int_0^1 |x^2-x+3/16| dx=1/16$$
So the correct solution is $a=-1$, $b=3/16$.