Unique Minimum of an Integral Let $f(x)$ be a continuously increasing function on $[a,b]$. Show that $\min_{N \in \mathbb{R} } \int_a^b \left | f(x)-N \right |\,dx=\int_{(a+b)/2}^b f(x)\,dx-\int_a^{(a+b)/2}f(x)\,dx$ if and only if $N=f((a+b)/2)$.
 A: First consider the case where $f(a) < N < f(b)$. The function $f$ has an inverse and is almost everywhere differentiable because it is increasing. We can decompose the integral as follows:
$I =\int_{a}^{b}|f(x)-N|dx = \int_{a}^{f^{-1}(N)}(N-f(x))dx + \int_{f^{-1}(N)}^{b}(f(x)-N)dx = 2N[f^{-1}(N) - (a+b)/2] - \int_{a}^{f^{-1}(N)}f(x)dx + \int_{f^{-1}(N)}^{b}f(x)dx $.
Now differentiate with respect to $N$ using Leibniz's Rule and find the critical points
$\frac{dI}{dN} = 2[f^{-1}(N) -(a+b)/2] +2N\frac{d}{dN}f^{-1}(N) -2\frac{d}{dN}f^{-1}(N)f(f^{-1}(N)) = 2[f^{-1}(N) -(a+b)/2]$.
Setting to $0$, we find a critical point at $N = f((a+b)/2)$. Checking the second derivative shows that this is a relative minimum point.  The value of the integral at this point is
$I_{min} =\int_{(a+b)/2}^{b}f(x)dx - \int_{a}^{(a+b)/2}f(x)dx $.
If $N \leq f(a)$ we find, 
$I_a =\int_{a}^{b}f(x)dx - N(b-a)$
which has minimum value at $N=f(a)$:
$\min I_a =\int_{a}^{b}f(x)dx - f(a)(b-a)$
If $N \geq f(b)$ we find, 
$I_b =-\int_{a}^{b}f(x)dx + N(b-a)$
which has minimum value at $N=f(b)$:
$\min I_b =-\int_{a}^{b}f(x)dx +f(b)(b-a)$
We can show that $I_{min} < \min I_b$ as follows:
$\min I_b - I_{min} =f(b)(b-a)-\int_{a}^{b}f(x)dx + \int_{(a+b)/2}^{b}f(x)dx - \int_{a}^{(a+b)/2}f(x)dx = 2f(b)((a+b)/2 - a)-2\int_{a}^{(a+b)/2}f(x)dx= 2\int_{a}^{(a+b)/2}[f(b)-f(x)]dx > 0$
A similar argument applies to $I_a$ and it follows that $I_{min}$ is the global minimum.  
