Find the interval $[a,b]$ for which the value of the integral $\int_{a}^{b} (2+x-x^2)dx$ is maximized.
To solve this problem, I believe I need to the largest interval over which the integrand is nonnegative. To that end, $2+x-x^2 \ge 0$ if and only if $(x+1)(x-2) \le 0$. This occurs if $x \ge -1$ and $x \le 2$ or $x \le -1$ and $x \ge 2$. Obviously the latter condition is contradictory in nature, so we conclude that $f(x)$ is nonnegative if and only if $x \in [-1,2]$. Now we prove that this is the interval over which the integral is maximized.
Let $[a,b] \subseteq \Bbb{R}$ be some other interval. If $[a,b]$ is contained in either $(- \infty, -1]$ or $[2,\infty)$, then the integral is negative and therefore smaller. If $[a,b]$ is strictly contained in $[-1,2]$, then $\int_{-1}^{2} f(x)dx = \int_{-1}^{a} f(x)dx + \int_{a}^{b} f(x) dx + \int_{b}^{2} f(x)dx \ge \int_{a}^{b} f(x) dx$. The only remaining case is when $[a,b]$ and $[-1,2]$ overlap but the latter is not contained in the former. Suppose that $a \le -1 \le b$. Then
$$\int_{a}^{b} f(x) dx = \int_{a}^{-1}f(x) dx + \int_{-1}^{b} f(x) dx \le \int_{-1}^{b} f(x) dx + \int_{b}^{2} f(x) dx.$$ The $a \le 2 \le b$ case is similar. Finally, it's possible to have $[-1,2] \subseteq [a,b]$, but that case can be handled in a similar fashion, and so I omit it.
As one can see, I had to deal with more cases than I cared to. Is there a simpler solution, or have I no such recourse?