For any number $c$ we let $f_c(x)$ be the smaller of the two numbers $(x-c)^2$ and $(x-c-2)^2$. Then we define $g(c)=\int_0^1f_c(x)dx$. Find the maximum and minimum values of $g(c)$ if $-2\le c \le 2$.
So the maximum/minimum values are either $g(\pm2)$ (the endpoints) or $g(c)$ where $g'(c)=0$.
$$g(2)=\int_0^1f_2(x)dx=\int_0^1\min((x-2)^2,(x-4)^2)dx\\=\int_0^1(x-2)^2dx=\frac{(1-2)^3}{3}-\frac{(0-2)^3}{3}=\frac{7}{3}$$ The last step I was thinking was because on the interval $[0,1]$, $|x-2|$ is always smaller than $|x-4|$.
In the same way, $$g(-2)=\int_0^1f_{-2}(x)dx=\int_0^1\min((x+2)^2,x^2)dx\\=\int_0^1x^2dx=\frac{1}{3}$$
So $7$ thirds and $1$ third for the endpoints. When the derivative is zero, I am having trouble. I am struggling to understand how the derivative and antiderivative of $g$ and $f_c$ would operate. Thanks.
Problem Source: James Stewart, Calculus, Integrals Chapter
It can be shown that $g$ has a symmetry in $c=-\frac 12$.
$\displaystyle g(c)=\int_0^1 \min\left((x-c)^2,(x-c-2)^2\right)\mathop{dx}\quad$ let substitute $u=1-x$
$\displaystyle\phantom{g(c)}=\int_1^0 \min\left((1-u-c)^2,(1-u-c-2)^2\right)(-\mathop{du})\\\displaystyle\phantom{g(c)}=\int_0^1 \min\left((u+c-1)^2,(u+c+1)^2\right)\mathop{du}=g(-c-1)$
So we need only to study $g$ on the interval $[-\frac 12,2]$.
$f_c(x)=\min((x-c)^2,(x-c)^2-4(x-c)+4)=(x-c)^2+4\min(0,1+c-x)$
Let's have $\begin{cases}\displaystyle g_0(c)=\int_0^1(x-c)^2\mathop{dx}=c^2-c+\frac 13\\\displaystyle g_1(c)=4\int_{c+1}^1 (1+c-x)\mathop{dx}=-2c^2\end{cases}$
For $c\in[0,2]\implies g(c)=g_0(c)$
with a minimum in $g(\frac 12)=\frac 1{12}$ and a maximum $g(2)=\frac 73$.
For $c\in[-\frac 12,0]\implies g(c)=g_0(c)+g_1(c)$
with a maximum $g(-\frac 12)=\frac 7{12}$ and a minimum $g(0)=\frac 13$.
So overall the extrema of $g$ for $c\in[-2,2]$ are