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

### 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:

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 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.

df(x)=derivative(f,x);df

x |--> 3*x^2 - 6*x

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 .

solve(df(x)==0,x)

[x == 0, x == 2]

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 .

df(-.1)
df(.1)

0.630000000000000 -0.570000000000000

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 .

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 .

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

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

Since is never undefined, we just need to solve the equation for .

solve(d2f(x)==0,x)

[x == 1]

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.

d2f(.9)
d2f(1.1)

-0.600000000000000 0.600000000000001

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:

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 and .

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 - 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).

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

4 2 0

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.

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 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.

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


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.

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 .

solve(df(x)==0,x)

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

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 .

df(-.6)
df(-.4)

0.0217723087894590 -0.0323034428791448

There is a sign change for from postive to negative, so has a local max at .

Now try x-values close to .

df(-.1)
df(.1)

-0.107251207365702 0.358037927433905

Since changes from negative to positive, has a local min at .

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 .

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 : 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 .

d2f(-.9)
d2f(-.8)

0.0153012845704839 -0.0228268342278850

Since changes sign, changes concavity. So we have an inflection point at .

Now try x-values near .

d2f(-.2)
d2f(-.1)

-0.251624219905644 0.375379225779958

Since changes sign, changes concavity. So we also have an inflection point at .

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 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.

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 (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.