The question at hand is to find the maximum value of the integral:
$$ \int_{-1}^{1} |x-a| \cdot e^{x} dx $$
under the constraint that $ |a| \leq 1$
The way I thought of approaching this problem would be to:
$$ f(a) = \int_{-1}^{a} |x-a| \cdot e^{x} dx + \int_{a}^{1} |x-a| \cdot e^{x} dx $$
Then using the fact that $$ |x| = \begin{cases} x & x\geq 0 \\ -x & x < 0 \end{cases} $$, we can write:
$$ f(a) = \int_{-1}^{a} (a-x) \cdot e^{x} dx + \int_{a}^{1} (x-a) \cdot e^{x} dx $$
Now I am thinking of evaluating the integral using the fact that:
$$ \int (x-\alpha) \cdot e^{x} dx = e^{x}(x-\alpha-1) + C$$
And then I can differentiate with respect to $a$ and try to find the maxima and minima.
It would be great if anyone could tell me if this approach is correct.
Any other interesting approaches would also be greatly appreciated!
Since $|a-x| e^x$ is a convex function of $a$ for each $x$, $f(a)$ is a convex function of $a$. Therefore the maximum must occur at one of the endpoints. Just calculate $f(-1)$ and $f(1)$ to see which it is.