What is an algorithm for what I am trying to do?
You find the local maxima and minima by taking the derivative and setting it to 0.  This leaves you with a non-linear equation $f'(x)=0$ to solve.

The easiest, and most reliable, way to find the zeros of a continuous non-linear equation, $g(x)=0$, is called the Bisection Method.

Find two points $x_-$ and $x_+$ where $g(x_-) &lt; 0$ and $g(x_+) &gt; 0$.  (These are particularly easy to find for odd-degree polynomials, since there will always be at least one real root.)

Now evaluate $g(x_\star)$ where $x_\star = (x_- + x_+)/2$.  If $g(x_\star) &gt; 0$ then let $x_+ = x_\star$ and repeat.  Else if $g(x_\star) &lt; 0$ then let $x_- = x_\star$ and repeat.

Because you are interested in the range [-4,6] you also need to evaluate $f(-4)$ and $f(6)$, because the local maxima may not be inside the range.  (Your function obviously has no finite global maximum. $f(10)$ is about 18000, and grows from there and $f(-10)$ is also about 18000 and grows from there.