# Puzzled by how to determine when a function takes on its maximum (or minimum)

I apologize for the specificity of the my question, but I'm concerned that I'm having trouble grasping an important concept.

I'm puzzled by the answer provided for exercise 1.(v) in chapter 7 of Spivak's Calculus (4E, p.129):

For $a>-1$ and $$f(x) =\begin{cases} x^{2}, & x ≤ a \\ a+2, & x>a \end{cases},\qquad x\in(-a-1,a+1),$$

where where does $f(x)$ take on its maximum and minimum?

I get $$\begin{array}{cc} Range & Max & Min\\ -1<a<-\frac{1}{2} & a+2 & a+2 \\ -\frac{1}{2}≤a<0 & a+2 & a^{2} \\ 0≤a≤\frac{\sqrt{5}-1}{2} & a+2 & 0 \\ \frac{\sqrt{5}-1}{2}<a & - & 0 \\ \end{array}$$ but the answer key has $a^{2}$ as a minimum only for $-\frac{1}{2}<a\lt 0$.

What am I missing?

-
When you say $f(x)=x^2$ for $x \le a$, do you mean $f(x)=a^2$? Otherwise very negative $x$ will produce a large $x^2$. – Henry Sep 11 '11 at 21:45
@Henry: I only have the 2nd Edition, and in Spanish, but that's what it says in that edition. Note that the domain is restricted to $(-a-1,a+1)$, so "very negative $x$" will not be in the domain. – Arturo Magidin Sep 11 '11 at 21:52
@Henry: as written. Though maybe I should clarify: what the answer key does is shift the case of $a=-\frac{1}{2}$ from the second to the first line my solution above. – raxacoricofallapatorius Sep 11 '11 at 21:54
@raxacoricofallapatorius: I see! The problem is that when $a=-\frac{1}{2}$, the domain is $(-\frac{1}{2},\frac{1}{2})$, so you are never in the case $x\leq a$; the function is constant $a+2$ in that case. – Arturo Magidin Sep 11 '11 at 22:43
@Arturo: Exactly that. Thanks for setting me straight! – raxacoricofallapatorius Sep 11 '11 at 23:31

I have the 2nd Spanish edition (Editorial Reverté, S.A.), translated from the second English edition. The problem is the same, but did not include the condition $a\gt -1$ until the answer key. But the answer key there reads (translated):
It is bounded above and below. It is understood that $a\gt -1$ (so that $-a-1\lt a+1$). If $-1\lt a\leq -\frac{1}{2}$, then $a\lt -a-1$, so $f(x)=a+2$ for all $x\in (-a-1,a+1)$, so $a+2$ is the maximum and the minimum. If $-\frac{1}{2}\lt a\leq 0$, then $f$ has minimum $a^2$, and if $a\geq 0$, then it has minimum $0$. Since $a+2\gt (a+1)^2$ only for $\frac{-1-\sqrt{5}}{2}\lt a \lt \frac {1+\sqrt{5}}{2}$, when $a\geq -\frac{1}{2}$ the function $f$ has a maximum only for $a\leq \frac{1+\sqrt{5}}{2}$ (when this maximum is $a+2$).
Added. Oh, I see; the problem is what happens when $a=-\frac{1}{2}$.
If $a=-\frac{1}{2}$, then the function is $$f(x) = \left\{\begin{array}{ll}x^2 & \text{if }x\leq -\frac{1}{2}\\ \frac{3}{2} &\text{if }x\gt -\frac{1}{2} \end{array}\right.\qquad x\in\left(-\left(-\frac{1}{2}\right)-1,-\frac{1}{2}+1\right).$$ What you seem to be missing is that since the domain is $(-\frac{1}{2},\frac{1}{2})$, the first case never occurs, so you are always in the second case.
Ah — that's it: if $a=-\frac{1}{2}$, $a$ isn't in the domain of $f(x)$! – raxacoricofallapatorius Sep 11 '11 at 22:58