TITLE: Maximum value of the integral $\int_0^1e^{|t-x|}dt$ for $0 \leq x \leq 1$
QUESTION [7 upvotes]: Define $$f(x)=\int_0^1e^{|t-x|}dt$$
I have to find the maximum value of $f(x)$ when $0 \leq x \leq 1$.
To remove the modulus, I wrote $$f(x)=\int_0^xe^{x-t}dt + \int_x^1e^{t-x}dt$$
$$f(x)=e^x\int_0^xe^{-t}dt + e^{-x}\int_x^1e^tdt$$
And then $$f'(x)=e^x\int_0^xe^{-t}dt + 2 - e^{-x}\int_x^1e^tdt$$
This does not seem to help me much as I still cannot get any values of $x$ for which $f'(x)=0$.
Can you help me with how to proceed from here? Or maybe a different method?

REPLY [2 votes]: Hints: 

Note that the function $g:\mathbb{R}\to \mathbb{R}$ given by 
$$ g(x)~:=~{\rm sgn}(x) (e^{|x|}-1) ~=~-g(-x) $$
belongs to $C^1(\mathbb{R})$, and the derivative
$$ g^{\prime}(x)~=~e^{|x|} $$
is related to OP's integrand.
So OP's function $f:\mathbb{R}\to \mathbb{R}$ also belongs to $C^1(\mathbb{R})$,
$$ f(x)~:=~\int_0^1 \! dt~ g^{\prime}(t-x)
~=~ \left[g(t-x)\right]^{t=1}_{t=0}
~=~ -\left[g(x-t)\right]^{t=1}_{t=0}$$ 
$$~=~ -\left[{\rm sgn}(x-t) (e^{|x-t|}-1)\right]^{t=1}_{t=0}. $$
The derivative 
$$ f^{\prime}(x) ~=~ -\left[g^{\prime}(x-t)\right]^{t=1}_{t=0}
~=~ -\left[e^{|x-t|}\right]^{t=1}_{t=0} $$
is zero iff $x=\frac{1}{2}$.
So the potential candidates for the maximum points are at $x=\frac{1}{2}$ and at the end-points $x=0$ and $x=1$. We leave it to the reader to determine which.