Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Math 241
Views: 332
License: OTHER
Image: ubuntu2004
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 ff' is related to the direction of ff:

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

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

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

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

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

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

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

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

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

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

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 ff'' 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 ff, to find its critical points we compute ff', and we find where f(x)=0f'(x)=0 or ff' is undefined. If we want a good graph of ff, 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 ff', i.e., places where ff'' 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)=x33x2+4f(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 ff and ff' so we can make a more educated guess for the viewing window.

Step 1 Find the domain of ff.

Our function ff is a cubic polynomial, so its domain is all real numbers, R\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 ff'. 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 ff, i.e. places where ff' is 0 or undefined.

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

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

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

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

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

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

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

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


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

Now let's see if the sign of ff' changes at x=2x=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=2x=2.

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

Step 5 Find ff''. 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 ff', i.e. places where ff'' is 0 or undefined.

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

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

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

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

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

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

Since the sign of ff'' does change, ff has an inflection point at x=1x=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 limxf(x)\displaystyle\lim_{x\to\infty}f(x) and limxf(x)\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 xx- and yy-intercepts, relative maxima and minima, and inflection points.

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

Sage will determine y-values for us, but we need to include at least f(0)f(0), f(1)f(1), and f(2)f(2) (from the critical points) and f(0)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][-1,2], and the y-axis needs to cover [0,4][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 ff do result in a local min and a local max, and the critical point of ff' 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 ff is increasing on the interval (,0](-\infty,0], decreasing on [0,2][0,2], and increasing on [2,)[2,\infty). The direction changes at x=0x=0 and x=2x=2 (the critical points of ff).

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


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)=x2e4xf(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 exe^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 R\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 ff.

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

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

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

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

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

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


Now try x-values close to 00.

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

Since ff' changes from negative to positive, ff has a local min at x=0x=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 ff'.

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 ff': x=24120.8536x=-\frac{\sqrt{2}}{4}-\frac{1}{2}\approx-0.8536 and x=24120.1464x=\frac{\sqrt{2}}{4}-\frac{1}{2}\approx-0.1464. These are the potential inflection points.

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

First, try x-values near 0.8536-0.8536.

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

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


Now try x-values near 0.1464-0.1464.

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

Since ff'' changes sign, ff changes concavity. So we also have an inflection point at x=24120.1464x=\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 limxf(x)=\displaystyle\lim_{x\to\infty}f(x)=\infty and limxf(x)=0\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 xx- and yy-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, 0x=-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 00 (at x=0x=0).

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

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


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