Sage will happily compute derivatives.

Combining this with what we know from the previous section, we can find and evaluate critical points.

So the critical values are $x=-2$ and $x=1$. We'll use the second derivative test:

So there is a local maximum at $-2$ and a local minimum at $1$.

Let's make sure this seems reasonable by graphing the function.

To be complete, we should examine the first derivative a little more carefully.

So it is easy to see that the first derivative is undefined at $x=-3$, and we should investigate that point. We can use the most primitive of the tests we saw for maximum and minimum points: check the value of $f$ at three points: the critical value $x=-3$ and one value on each side of this value.

Well that's peculiar—why are we getting a complex number for $f(3.5)$? The problem is that $-3.5+3=-0.5$ has three cube roots, two of them complex and one (the one we want) real. Sage picks something called the principal cube root, which is one of the complex roots. (The reasons for this take us well beyond calculus.) So we have to work around this problem. You could just use a calculator to compute $f(-3.5)$, or we can use Sage as a calculator with a little care. We want to compute $(-0.5)^{2/3}$ and in effect Sage is interpreting this as $((-0.5)^{1/3})^2$. We can force it instead to compute $((-0.5)^2)^{1/3}$, which will become the cube root of a positive number, and the principal cube root of a positive number is real. So here is the calculation:

Thus $f(-3)=0$, $f(-3.5)\approx 12.8$, and $f(-2.5)\approx 7.1$, so the point at $x=-3$ is a local minimum. We would like now to plot the function showing all three local extrema, but Sage will have the same problem as above: it won't be able to compute $f(x)$ properly when $x< -3$. Taking a clue from our work-around, we can redefine $f$, doing the square before the cube root.

There are some lessons here: even apparently simple situations can have subtle complications, and computer programs sometimes do surprising things, either in error or because of those subtle complications. Fortunately, in most of the problems you will encounter, Sage will do just fine.