Let be $a,b\in \mathbb{R}$ with $a<b$ and consider a continuous and strictly increasing function $f:[a,b]\to \mathbb{R}$. For $y\in \mathbb{R}$ let define, $$E(y)=\int_a^{b}|f(x)-y|dx.$$Show that $E$ has a minimun value and find all the values of $y$ where the function $E$ achieve the minimun.
My attempt:
We note that $E(y)\geq 0$ for all $y\in \mathbb{R}$, so I think that the minimun value of $E$ is $0$. But, How can I prove it? I also know that $f$ is continuous and strictly increasing, hence $f(a)\leq f(x)\leq f(b)$ for all $x\in [a,b]$, is it a relevant fact?
Minimum at $y=f(\frac{a+b}{2})$. In fact, assume $y=f(t)$ (it is easy to rule out the case $y\notin [f(a), f(b)]$), then $$ E=\int_a^t|f(x)-f(t)|dx+\int_t^b|f(x)-f(t)|dx=\int_a^t [f(t)-f(x)] dx+\int_t^b[f(x)-f(t)]dx; $$ thus $$ E'(t)=\int_a^tf'(t)dx+[f(t)-f(t)]-\int_t^bf'(t)dx-[f(t)-f(t)]=(t-a-b+t)f'(t). $$ We see $f'(t)\geq 0$. so $E'(t)\leq 0$ when $t<\frac{a+b}{2}$ and $E'(t)\geq 0$ when $t>\frac{a+b}{2}$, thus minimum when $t=\frac{a+b}{2}$.
In general, $f$ can be approximated by a sequence of increasing, smooth function (e.g. using convolution) and take limit one reach the same conclusion.
Alternatively, we can take derivative with respect $y$ directly:
From $E'(y)=\lim_{y'\to y} \frac{E(y')-E(y)}{y'-y}$, we can write $y=f(t)$, $y'=f(t')$; we can assume $t'>t$ ($t'<t$ can be treated similarly), a direct calculation shows $$ \begin{aligned} E(y')-E(y)=&-2\int_t^{t'}f(x)dx+(t'-a)f(t')-(t-a)f(t)-(b-t')f(t')+(b-t)f(t)\\ =&-2\int_t^{t'}f(x)dx+(t-a-b+t)[f(t')-f(t)]+2(t'-t)f(t')\\ =&2\int_t^{t'}f(t')-f(x)dx+(t-a-b+t)[f(t')-f(t)]. \end{aligned}$$ Note $y'-y=f(t')-f(t)$, first, $$ \begin{aligned} \Big|\frac{1}{y'-y}\int_t^{t'}f(t')-f(x)dx\Big| =&\Big|\frac{1}{f(t')-f(t)}\int_t^{t'}f(t')-f(x)dx\Big|\\ \leq &\Big|\frac{1}{f(t')-f(t)}\int_t^{t'}f(t')-f(t)dx\Big|=(t'-t), \end{aligned}$$ this goes to $0$ as $y'\to y$ since $f$ is strictly increasing. Thus we conclude $$ E'(y)=2t-a-b. $$ Thus $E'(y)=0$ when $t=\frac{a+b}{2}$, i.e. $y=f(\frac{a+b}{2})$.