Shared10 - Function Analysis Part 1 Assignment / Function Analysis Part 1 Notes.sagewsOpen in CoCalc
This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is Creative Commons License
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 f' is related to the direction of f :

  • If f' is positive on an interval, then f is increasing on that interval.

  • If f' is negative on an interval, then f is decreasing on that interval.

Therefore, if the direction of f changes (from increasing to decreasing, or vice versa), then the sign of f' must change. If f' 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 f' 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 f' is a function in its own right, so it has critical points as well. The critical points of f' are the x-values at which its derivative, f'' , is 0 or undefined. The critical points of f' tell us the possible locations where f' can change direction.

Recall that the direction of f' corresponds to the concavity of f .

  • If f' is increasing on an interval, then f is concave up on that interval.

  • If f' is decreasing on an interval, then f is concave down on that interval.

Since the direction of f' corresponds to the sign of its derivative, f'' , we can also phrase the above this way:

  • If f'' is positive on an interval, then f is concave up on that interval.

  • If f'' is negative on an interval, then f is concave down on that interval.

Since f' can change direction only at its critical points, f can change concavity only there as well. In other words, the critical points of f' (i.e., places where f'' is 0 or undefined) are the potential inflection points of f .

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 f'' 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 f , to find its critical points we compute f' , and we find where f'(x)=0 or f' is undefined. If we want a good graph of f , 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 f' , i.e., places where f'' 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 f(x)=x^3-3x^2+4 .

Here is the default graph:

f(x)=x^3-3*x^2+4
plot(f)

We know from precalc that this is not a complete graph, since a cubic polynomial has opposite behavior at \infty and -\infty .

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 f and f' so we can make a more educated guess for the viewing window.

Step 1 Find the domain of f .

Our function f is a cubic polynomial, so its domain is all real numbers, \mathbb{R} .

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 f' . In Sage, I will call this df.

df(x)=derivative(f,x);df
x |--> 3*x^2 - 6*x

Step 3 Find the critical points of f , i.e. places where f' is 0 or undefined.

Our derivative is never undefined, so we just need to solve the equation f'(x)=0 for x .

solve(df(x)==0,x)
[x == 0, x == 2]

We have two solutions: x=0 and x=2 . These are the two critical points of f .

Step 4 See if the sign of f' actually changes at the critical points of f , and determine whether f has a local maximum or local minimum at these points.

To determine whether the sign of f' actually changes at x=0 (which means f actually has a local min or max there), choose some x-values close to 0 and plug them into f' .

df(-.1)
df(.1)
0.630000000000000 -0.570000000000000

Notice that the sign of f' is different to either side of 0 . Since the sign changes, the direction of f changes - that means f has a local min or max at x=0 .

In fact, since the sign of f' changes from positive to negative, f has a local max.


Comment: How close to 0 do my test points need to be? Just make sure they are closer to 0 than the rest of the critical points. In this case, as long as we get closer than 2 , then we're fine.

Now let's see if the sign of f' changes at x=2 .

df(1.9)
df(2.1)
-0.569999999999999 0.629999999999999

Once again, the sign does change, so we have another local min or max at x=2 .

Since the sign of f' changes from negative to positive, f has a local min.

Step 5 Find f'' . In Sage I will call this d2f.

d2f(x)=derivative(f,x,2); d2f   #of course, you could do derivative(df,x)
x |--> 6*x - 6

Step 6 Find the critical points of f' , i.e. places where f'' is 0 or undefined.

Since f'' is never undefined, we just need to solve the equation f''(x)=0 for x .

solve(d2f(x)==0,x)
[x == 1]

We have one solution: x=1 . This is the critical point of f' .

Step 7 See if the sign of f'' actually changes at the critical points of f' , and determine whether f has an inflection point at these points.

To determine whether there is an inflection point at x=1 , we can choose some nearby x-values and plug them into f'' . If the sign is different, then we have an inflection point.

d2f(.9)
d2f(1.1)
-0.600000000000000 0.600000000000001

Since the sign of f'' does change, f has an inflection point at x=1 (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:

solve(f(x)==0,x)  #find the x-intercepts - might have to use find_root for more complicated functions
[x == -1, x == 2]
f(0)  #find the y-intercept
4

Step 9 Determine the end behavior.

The end behavior is \displaystyle\lim_{x\to\infty}f(x) and \displaystyle\lim_{x\to-\infty}f(x) .

This will reveal any horizontal asymptotes.

limit(f(x),x=infinity)
+Infinity
limit(f(x),x=-infinity)
-Infinity

There are no horizontal asymptotes in this case.

Step 10 Make an informed graph. Mark any x - and y -intercepts, relative maxima and minima, and inflection points.

We need a viewing window that includes at least x=0 , x=1 , and x=2 (the critical points) as well as x=-1 and x=2 (the x-intercepts).

Sage will determine y-values for us, but we need to include at least f(0) , f(1) , and f(2) (from the critical points) and f(0) (the y-intercept).

f(0)
f(1)
f(2)
4 2 0

Now we know that the x-axis needs to cover the interval [-1,2] , and the y-axis needs to cover [0,4] .

We should probably make the viewing window just a little bigger than this to show the intercepts and critical points clearly.

f(x)=x^3-3*x^2+4
plot(f,xmin=-2,xmax=3,ymin=-1,ymax=5)+point([(-1,0),(0,4),(1,2),(2,0)],color='black',size=20)

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 f do result in a local min and a local max, and the critical point of f' 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 f is increasing on the interval (-\infty,0] , decreasing on [0,2] , and increasing on [2,\infty) . The direction changes at x=0 and x=2 (the critical points of f ).

Notice that f is concave up on the interval [1,\infty) and concave down on the interval (-\infty,1] . The inflection point occurs at x=1 (the critical point of f' ).


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 f(x)=x^2e^{4x} . Once again, we'll look at the default graph to see why the calculus is useful.

f(x)=x^2*e^(4*x)
plot(f)

This graph appears to have the same basic shape as e^x : 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 \mathbb{R} .

Step 2 Find the derivative.

df(x)=derivative(f,x);df
x |--> 4*x^2*e^(4*x) + 2*x*e^(4*x)

Step 3 Find the critical points of f .

solve(df(x)==0,x)
[x == (-1/2), x == 0]

There are no places where f' is undefined, and so there are two critical points of f (where f' is 0): x=-\frac{1}{2} and x=0 . We have potential local max or min here - these are not apparent on the graph above.

Step 4 See if the sign of f' actually changes at the critical points of f , and determine whether f has a local maximum or local minimum at these points.

First, try some x-values close to -\frac{1}{2} .

df(-.6)
df(-.4)
0.0217723087894590 -0.0323034428791448

There is a sign change for f' from postive to negative, so f has a local max at x=-\frac{1}{2} .


Now try x-values close to 0 .

df(-.1)
df(.1)
-0.107251207365702 0.358037927433905

Since f' changes from negative to positive, f has a local min at x=0 .

Step 5 Find the second derivative.

d2f(x)=derivative(f,x,2);d2f
x |--> 16*x^2*e^(4*x) + 16*x*e^(4*x) + 2*e^(4*x)

Step 6 Find the critical points of f' .

solve(d2f(x)==0,x)
[x == -1/4*sqrt(2) - 1/2, x == 1/4*sqrt(2) - 1/2]
N(-1/4*sqrt(2) - 1/2)
N(1/4*sqrt(2) - 1/2)
-0.853553390593274 -0.146446609406726

There are two critical points of f' : x=-\frac{\sqrt{2}}{4}-\frac{1}{2}\approx-0.8536 and x=\frac{\sqrt{2}}{4}-\frac{1}{2}\approx-0.1464 . These are the potential inflection points.

Step 7 See if the sign of f'' actually changes at the critical points of f' , and determine whether f has an inflection point at these points.

First, try x-values near -0.8536 .

d2f(-.9)
d2f(-.8)
0.0153012845704839 -0.0228268342278850

Since f'' changes sign, f changes concavity. So we have an inflection point at x=-\frac{\sqrt{2}}{4}-\frac{1}{2}\approx-0.8536 .


Now try x-values near -0.1464 .

d2f(-.2)
d2f(-.1)
-0.251624219905644 0.375379225779958

Since f'' changes sign, f changes concavity. So we also have an inflection point at x=\frac{\sqrt{2}}{4}-\frac{1}{2}\approx-0.1464 .

Step 8 Find the x- and y-intercepts.

solve(f(x)==0,x)
[x == 0]
f(0)
0

Step 9 Determine the end behavior.

limit(f(x),x=infinity);limit(f(x),x=-infinity)
+Infinity 0

We found that \displaystyle\lim_{x\to\infty}f(x)=\infty and \displaystyle\lim_{x\to-\infty}f(x)=0 . This means the x-axis is a horizontal asymptote (in the negative direction).

Step 10 Make an informed graph. Mark any x - and y -intercepts, relative maxima and minima, and inflection points.

Let's put the pieces together. Our graph needs to cover the critical points, x=-0.8536,\ -0.5,\ -0.1464,\ 0 , along with their correspoding y-values.

f(-0.8536)
f(-.5)
f(-0.1464)
f(0)
0.0239692107419376 0.0338338208091532 0.0119332655442418 0

In this example, these values already cover the x- and y-intercepts and the end behavior.

f(x)=x^2*e^(4*x)
plot(f,xmin=-1.5,xmax=.5,ymin=0,ymax=.05)+point([(-.5,0.0338),(0,0),(-0.8536,0.0240),(-0.1464,0.0119)],color='black',size=20)

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 0 (at x=0 ).

This function is increasing on (-\infty,-0.5] and [0,\infty) . It is decreasing on [-0.5,0] .

This function is concave up on (-\infty,-0.8536] and [-0.1464,\infty) . It is concave down on [-0.8536,-0.1464] .


Comment: Notice once again where the critical points show up in Step 11.