<s>[INST] Find $k$ such that $f(k)$ is Minimum Find $k$ such that 
$$f(k)=\int_{0}^{4} |4x-x^2-k|dx$$ is Minimum
I splitted the Modulus in to two cases:
$1.$   if   $4x-x^2-k \ge 0$ Then
$$f(k)=\int_{0}^{4} (4x-x^2-k)dx=\frac{32}{3}-4k$$
$2.$ if   $4x-x^2-k \lt 0$  Then
$$f(k)=4k-\frac{32}{3}$$
But How to minimize $f(k)$ which is linear in $k$?
 [/INST] We need to separate it into three cases :


*

*Case 1 : If $k\ge 4$, then we have $4x-x^2-k=-(x-2)^2+4-k\le 0$, so $$f(k)=\int_0^4 (x^2-4x+k)dx=4k-\frac{32}{3}$$So, $f(k)\ge f(4)=\frac{16}{3}$ for $k\ge 4$. 

*Case 2 : If $0\lt k\lt 4$, then $0\lt 2-\sqrt{4-k}\lt 2+\sqrt{4-k}\lt 4$ where $x=2\pm\sqrt{4-k}$ are roots of $4x-x^2-k$, so we have $$\begin{align}\small f(k)&=\int_{0}^{2-\sqrt{4-k}}(x^2-4x+k)dx+\int_{2-\sqrt{4-k}}^{2+\sqrt{4-k}}(-x^2+4x-k)dx+\int_{2+\sqrt{4-k}}^{4}(x^2-4x+k)dx\\\\&=\frac 43\left(2(4-k)^{3/2}+3k-8\right)\end{align}$$
and
$$f'(k)=4\left(1-\sqrt{4-k}\right)$$ from which we see that $f(k)$ is decreasing for $0\lt k\lt 3$ and increasing for $3\lt k\lt 4$ to have $f(k)\ge f(3)=4$ for $0\lt k\lt 4$.

*Case 3 : If $k\le 0$, then $4x-x^2-k=x(4-x)-k\ge 0$, so $$f(k)=\int_0^4(-x^2+4x-k)dx=\frac{32}{3}-4k$$So, $f(k)\ge f(0)=\frac{32}{3}$ for $k\le 0$.
Therefore, the minimum of $f(k)$ is attained when $\color{red}{k=3}$.
</s>