Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
License: OTHER
Image: ubuntu2004

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Prerequisites:
Intro to Sage
Graphing and Solving Equations
Differentiation
Function Analysis, Part 1
The goal of this lab is to explore the general shape of a function's graph using calculus (i.e., before graphing the function). Topics include increasing/decreasing and concave up/concave down and their relationship with the derivative.
Why do we want to do calculus before graphing?
Compare the two graphs below. The first looks like the graph of a quadratic function (parabola), while the second looks like a cubic function. Would you believe that these are both graphs of the same function?
If you saw a formula for the function that has been plotted, you would recognize it as a cubic polynomial. Based on your precalculus knowledge of polynomials, you would know that the first graph is not complete. However, there are many functions that we don't understand from precalculus alone. For these functions, calculus can give us the information we need to produce a complete graph. If we can produce a complete graph, then we can see the key features of the function.
Critical Points
Recall that the sign of is related to the direction of :
If is positive on an interval, then is increasing on that interval.
If is negative on an interval, then is decreasing on that interval.
Therefore, if the direction of changes (from increasing to decreasing, or vice versa), then the sign of must change. If changes sign (from positive to negative, or vice versa), it either has to go through 0 or it has to jump over the x-axis, in which case it will be undefined there. That leads to the next defintion:
Definition: A critical point of a function is an element in the domain of the function (an x-value) at which its derivative is 0 or undefined.
Critical points are the only points in the domain at which the direction of the function can change from increasing to decreasing or vice versa (of course, if there is a hole in the domain, the function could change direction there).
Critical points also give the possible locations of local minima and maxima.
Note that the critical points are the possible points of direction change; the direction does not necessarily change there. There are two ways to determine if a critical point actually results in a direction change: (1) look at a graph; (2) try some nearby values of x and see if the sign of changes. The advantage of (1) is that it's less work for us. The disadvantage is that our graph may not be good enough to see whether the direction changes. So while (2) is more work, it's more reliable.
Remember that is a function in its own right, so it has critical points as well. The critical points of are the x-values at which its derivative, , is 0 or undefined. The critical points of tell us the possible locations where can change direction.
Recall that the direction of corresponds to the concavity of .
If is increasing on an interval, then is concave up on that interval.
If is decreasing on an interval, then is concave down on that interval.
Since the direction of corresponds to the sign of its derivative, , we can also phrase the above this way:
If is positive on an interval, then is concave up on that interval.
If is negative on an interval, then is concave down on that interval.
Since can change direction only at its critical points, can change concavity only there as well. In other words, the critical points of (i.e., places where is 0 or undefined) are the potential inflection points of .
Once again, we have two ways to determine if the potential inflection points are actual inflection points: (1) look at a graph; (2) try some nearby values of x and see if the sign of changes. Changes in concavity are often harder to see than changes in direction, so option (1) is even less reliable in this case.
To summarize, if we have a function , to find its critical points we compute , and we find where or is undefined. If we want a good graph of , then we should make sure our viewing window includes all the critical points, since the direction of the function may change there.
We also want to find the critical points of , i.e., places where is 0 or undefined. We should include these in a good graph as well, since these are the potential inflection points.
Example 1
Let's consider an example. Suppose we wish to understand the shape of .
Here is the default graph:
We know from precalc that this is not a complete graph, since a cubic polynomial has opposite behavior at and .
Of course, we can simply play around with the viewing window to get a good graph. However, in some cases this strategy may take too much trial and error to be practical. Moreover, we may encounter functions that were not covered as completely in precalc as the polynomials, so we may not know whether we have a complete graph. At the very least, we generally want a "good graph" to include x- and y-intercepts, local minima and maxima, inflection points, and asymptotes. This kind of graph reveals the overall shape of the graph and the features of the function that we usually care about.
As an example of function analysis, let's consider the critical points of and so we can make a more educated guess for the viewing window.
Step 1 Find the domain of .
Our function is a cubic polynomial, so its domain is all real numbers, .
Other functions may have gaps in the domain. These may correspond to either vertical asymptotes or holes. These features should be explored at this point, if necessary.
Step 2 Find . In Sage, I will call this df.
Step 3 Find the critical points of , i.e. places where is 0 or undefined.
Our derivative is never undefined, so we just need to solve the equation for .
We have two solutions: and . These are the two critical points of .
Step 4 See if the sign of actually changes at the critical points of , and determine whether has a local maximum or local minimum at these points.
To determine whether the sign of actually changes at (which means actually has a local min or max there), choose some x-values close to and plug them into .
Notice that the sign of is different to either side of . Since the sign changes, the direction of changes - that means has a local min or max at .
In fact, since the sign of changes from positive to negative, has a local max.
Comment: How close to do my test points need to be? Just make sure they are closer to than the rest of the critical points. In this case, as long as we get closer than , then we're fine.
Now let's see if the sign of changes at .
Once again, the sign does change, so we have another local min or max at .
Since the sign of changes from negative to positive, has a local min.
Step 5 Find . In Sage I will call this d2f.
Step 6 Find the critical points of , i.e. places where is 0 or undefined.
Since is never undefined, we just need to solve the equation for .
We have one solution: . This is the critical point of .
Step 7 See if the sign of actually changes at the critical points of , and determine whether has an inflection point at these points.
To determine whether there is an inflection point at , we can choose some nearby x-values and plug them into . If the sign is different, then we have an inflection point.
Since the sign of does change, has an inflection point at (there is a change from concave down to concave up).
Step 8 Find the x- and y-intercepts.
We would like our graph to reveal the intercepts, so let's find them:
Step 9 Determine the end behavior.
The end behavior is and .
This will reveal any horizontal asymptotes.
There are no horizontal asymptotes in this case.
Step 10 Make an informed graph. Mark any - and -intercepts, relative maxima and minima, and inflection points.
We need a viewing window that includes at least , , and (the critical points) as well as and (the x-intercepts).
Sage will determine y-values for us, but we need to include at least , , and (from the critical points) and (the y-intercept).
Now we know that the x-axis needs to cover the interval , and the y-axis needs to cover .
We should probably make the viewing window just a little bigger than this to show the intercepts and critical points clearly.
This graph shows the x- and y-intercepts, the local maximum and minimum, and the inflection point (marked with black dots), as well as the end behavior. Also, there is not a lot of extra white space (which may happen if we let Sage choose the vertical plot range).
From the graph we can see that the critical points of do result in a local min and a local max, and the critical point of results in an inflection point, just as our calculations showed.
Step 11 Discuss absolute max/min, increasing/decreasing, concave up/down.
One thing we can do with a complete graph is determine the absolute (or global) maximum and minimum. In this case, we can see that neither exists.
Notice that is increasing on the interval , decreasing on , and increasing on . The direction changes at and (the critical points of ).
Notice that is concave up on the interval and concave down on the interval . The inflection point occurs at (the critical point of ).
Comment: The endpoints for the increasing/decreasing intervals are the critical points from Step 3. The endpoints for the concave up/down intervals are the critical points from Step 6.
Example 2
Consider . Once again, we'll look at the default graph to see why the calculus is useful.
This graph appears to have the same basic shape as : concave up, increasing everywhere. However, if we do some analysis we'll find that this graph is misleading.
Step 1 Find the domain.
The domain is .
Step 2 Find the derivative.
Step 3 Find the critical points of .
There are no places where is undefined, and so there are two critical points of (where is 0): and . We have potential local max or min here - these are not apparent on the graph above.
Step 4 See if the sign of actually changes at the critical points of , and determine whether has a local maximum or local minimum at these points.
First, try some x-values close to .
There is a sign change for from postive to negative, so has a local max at .
Now try x-values close to .
Since changes from negative to positive, has a local min at .
Step 5 Find the second derivative.
Step 6 Find the critical points of .
There are two critical points of : and . These are the potential inflection points.
Step 7 See if the sign of actually changes at the critical points of , and determine whether has an inflection point at these points.
First, try x-values near .
Since changes sign, changes concavity. So we have an inflection point at .
Now try x-values near .
Since changes sign, changes concavity. So we also have an inflection point at .
Step 8 Find the x- and y-intercepts.
Step 9 Determine the end behavior.
We found that and . This means the x-axis is a horizontal asymptote (in the negative direction).
Step 10 Make an informed graph. Mark any - and -intercepts, relative maxima and minima, and inflection points.
Let's put the pieces together. Our graph needs to cover the critical points, , along with their correspoding y-values.
In this example, these values already cover the x- and y-intercepts and the end behavior.
This looks quite a bit different than the default graph we started with. Of course, we can see from the values on the y-axis that this "wiggle" in the graph is very small, but depending on the application, this wiggle could be important.
Step 11 Discuss absolute max/min, increasing/decreasing, concave up/down.
This function has no absolute maximum. The absolute minimum is (at ).
This function is increasing on and . It is decreasing on .
This function is concave up on and . It is concave down on .
Comment: Notice once again where the critical points show up in Step 11.