Let $f:[-1,1]\to\mathbb{R}$ defined by $f(x)=1+|x|$, find the extrema of $f$ in its domain.
I did it in this way: the extrema are reached in internal stationary points, in the points such that $f'$ doesn't exist and in the points on the boundary of $[-1,1]$.
It is $\text{Int}([-1,1])=(-1,1)$, and $f'$ exists for all $x\ne0$ since $|x|$ is not differentiable in $x=0$; so for $x\in(-1,1) \setminus \{0\}$ it is $f'(x)=\frac{|x|}{x}=0 \iff x=0$, but since $0 \notin(-1,1) \setminus \{0\}$ there aren't internal stationary points.
The only internal point where $f$ is not differentiable is $x=0$, and it is $f(0)=1$.
It is $\partial([-1,1])=\{-1,1\}$, and it is $f(-1)=f(1)=2$; since $f(0) \leq f(-1)=f(1)$ it follows that $f$ has maximum $2$ for $x=1$ or $x=-1$ and $f$ has minimum $1$ for $x=0$.
Is this correct? I have a doubt when I evaluate $f'$: one of the hypothesis of Fermat's theorem on stationary points is that $f$ is defined in an open interval $(a,b)$, but in this case I have $(-1,1) \setminus \{0\}$ which is not an interval (if I'm not wrong, a union of interval in general is not an interval). So I'm not sure about my work in that point. My work is wrong and I can save it by considering the two cases $f_1(x)=1-x$ for $x \in (-1,0)$ and $f_2(x)=1+x$ for $x\in(0,1)$, in this way $f_1$ and $f_2$ are defined on intervals so all is fine and I just have to take the union of the results I obtain in the single intervals $(-1,0)$ and $(0,1)$? Or my work is correct as well? Thanks.
Why so complicated ?
We have $f(x) \ge 1$ for all $x$ and $f(0)=1.$
Furthermore: $f(x) \le 2 $ for all $x \in [-1,1]$ and $f( \pm 1)=2.$