Sage Homework: Derivatives and Graphs
In class, we have outlined a procedure for finding pertinent information about the graph of a function by using Calculus. The "problem" with this is of course the fact that the algebraic aspects can be challenging for a complicated function. Here is an example of how we can use computer to help us with the mathematics.
Example 1: Consider the function f(x) = 3x^530x^4+70x^3+60x^2225x+5. Our goal is to get a decent graph of this function. Let's just see what Sage gives us on a standard window.

That's not very enlightening, is it? Let's see if the graph has any bumps?
So, let's compute the derivative:

Now we can try to see when this is zero. Note that the x in the following line tells Sage what to solve for and the double equal sign == is what Sage uses to test equality. The single equals sign = is used for assignment.
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = \left(3\right), x = 9, x = \left(8\right), x = 4\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = \left(3\right), x = 9, x = \left(8\right), x = 4\right]

In this case, Sage gives us exact answers. Indeed, it's possible to factor this.
\newcommand{\Bold}[1]{\mathbf{#1}}30 \, {\left(x  9\right)} {\left(x  4\right)} {\left(x + 3\right)} {\left(x + 8\right)}
\newcommand{\Bold}[1]{\mathbf{#1}}30 \, {\left(x  9\right)} {\left(x  4\right)} {\left(x + 3\right)} {\left(x + 8\right)}

Task 1: Draw the chart of increasing/decreasing for f(x).
We can easily use Sage to compute test values. For example, if we want to compute the derivative when x = 0, we simply execute the following:
111720 22680 25920 12480 42120 111720 22680 25920 12480 42120 
You should see that the graph of f(x) increases, then decreases, then increases, then decreases, then increases. Correct? So, we have relative minima at x = 1 and x = 5. And relative maxima at x = 1 and 3. We can use Sage to get the function values:
40207 46668 73039 13836 40207 46668 73039 13836 
Now, how about concavity? We need the second derivative. We compute that with the following command:

Again, let's try finding the zeros.
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = 7, x = \left(\frac{1}{2}\right), x = \left(6\right)\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = 7, x = \left(\frac{1}{2}\right), x = \left(6\right)\right]

10.0000000000000 0.000000000000000 3.00000000000000 10.0000000000000 10.0000000000000 0.000000000000000 3.00000000000000 10.0000000000000 
85680 2520 10800 54720 85680 2520 10800 54720 
Again we get exact answers.
Task 2: Draw the chart of concavity. You should see that the graph is concave down, then concave up, then down, and finally up again. So x = 2\sqrt(5), x = 2, x = 2+\sqrt(5) are all inflection points. Again, let's evaluate them.
This is an exact value, but we can have Sage give us an approximate value by using the numerical evaluation function N:
If we want more accuracy, we can use:
3039.00000000000 13185.5000000000 23332.0000000000 3039.00000000000 13185.5000000000 23332.0000000000 
With all of this information, we see that the "interesting" stuff happens between x = 1 and x = 5 with yvalues between 245 and 187. So, let's try graphing the function with a slightly larger window:

Indeed, we see all the interesting behavior of the graph.
We can even add a few points to the graph to highlight all the interesting points.
Traceback (click to the left of this block for traceback) ... TypeError: 'sage.rings.integer.Integer' object does not support indexing Traceback (most recent call last): p += point( [(6, 3039)], color='black'); File "", line 1, in <module> File "/tmp/tmpiasO5Y/___code___.py", line 4, in <module> p += point( [(_sage_const_3039 )], color='red'); File "/home/sageserver/sage/sage5.0stock/local/lib/python2.7/sitepackages/sage/plot/point.py", line 312, in point return point3d(points, **kwds) File "/home/sageserver/sage/sage5.0stock/local/lib/python2.7/sitepackages/sage/plot/plot3d/shapes2.py", line 1022, in point3d A = sum([Point(z, size, **kwds) for z in v]) File "/home/sageserver/sage/sage5.0stock/local/lib/python2.7/sitepackages/sage/plot/plot3d/shapes2.py", line 680, in __init__ self.loc = (float(center[0]), float(center[1]), float(center[2])) TypeError: 'sage.rings.integer.Integer' object does not support indexing 
