How to calculate the maximum and minimum values for a piecewise function?

107 Views Asked by At

I was trying to calculate the maximum and minimum for this function:

$f(x) = \begin{cases} \begin{aligned} x + 2, & \quad \text{if } -1 \leq x < 0 \end{aligned} \\ \begin{aligned} 1, & \quad \text{if } x = 0 \end{aligned} \\ \begin{aligned} \frac{x}{2}, & \quad \text{if } 0 < x \leq 1 \end{aligned} \end{cases}$

I was able to do it using calculus as follows:

We can differentiate f(x) for $−1\leq x<0$ (except end point i.e. -1) and $0<x\leq 1$ (except end point i.e. 1) as it is continuous. But even after differentiation, we will $f ' (x) = 1$ or $\frac{1}{2}$ for $(x+2)$ and $\frac{x}{2}$ respectively, and thus no critical points can be obtained to check for maximum and minimum.

Additionally, critical points are the points where $f ' (x)$ is undefined and since $f (x)$ is not differentiable at $x=0$, we can take $x=0$ as a critical point. But $f ' (x)$ doesn't change the sign while passing through $x=0$ i.e. slope is positive on either side of $x=0$. So $x=0$ has neither maximum nor minimum. In conclusion, $f(x)$ has neither maximum nor minimum.

I felt if these cases could be combined into 1, it would be easier to calculate as only 1 derivative can be taken and equated to 0 to obtain critical points and then we can proceed towards confirming maximum or minimum or neither at those critical points.