What's the trick to finding the minimum/maximum values of problems like $f(x) = |x + 1| - |x - 2| + |2x + 1|$

I often come across to problems like "find the minimum value of $f(x) = |x + 1| - |x - 2|$" or "find the maximum value of $f(x) = |x - 1| + |2x + 5| - |6x + 1|$" or find the difference of the minimum and maximum value of $$f(x) = \frac{|x + 3|}{|x - 2|}$$ I wanna know what's the trick to solve these kind of problems.


Solution 1:

The way to approach exercises with absolute value terms is to find the zeros of the absolute value terms and dividing the domain into intervals bounded by those zeros. Then you can eliminate the absolute values on each interval and simplify the expression into a piecewise function.

For example: $f(x) = |x + 1| + |2x + 1|- |x - 2| $.

The zeros are $-1, -\dfrac{1}{2}, 2$. (Notice that I rearranged the terms in order of their zeros.) Now we divide the domain into four intervals

$$D=(-\infty,-1)\cup[-1,-1/2)\cup[-1/2,2)\cup[2,\infty) $$

On the first interval, all expressions in the absolute values are replaced by their negatives and the expression is simplified to

$$ (-x-1)+(-2x-1)-(-x+2)=-2x-4$$

In the next interval only the expressions in the second two absolute values are replaced by their negatives. In the third interval, only the expression in the last absolute value is replaced by its negative. Finally, in the fourth interval, all expressions are replaced by their positives.

The result is a piecewise defined function:

\begin{equation} f(x)=\begin{cases}-2x-4&\text{ for }x<-1\\ -2&\text{ for }-1\le x<-1/2\\ 4x&\text{ for }-1/2\le x<2\\ 2x+4&\text{ for }x\ge2\end{cases} \end{equation}

The graph will show you the minimum value.

Here is a link to the graph on desmos.

Solution 2:

I would convert it into a piecewise function. To do that, you basically, have to case on values of $x$.

For example, for $f(x) = |x+1|-|x-2|$, we have that for $x \ge 2$, $f(x) = x+1-(x-2) = 3$. For $x\le -1$, $f(x) = -(x-1) - -(x-2) = -3$. Finally for $x\in[-1,2]$, we have that $f(x) = x+1 - -(x-2) = 2x-1$.

Then I can draw this, or just look at each piece separately and answer the question.