Laboratory 9
Concavity

Introduction

In this lab, we shall examine the relationships between the concavity of a function and the first and second derivatives.

9.1 Concavity and Secant Lines

A function f is said to be concave upward on the interval a<x<b if for each pair of points (Subscript[x, 1]) and (Subscript[x, 2]) with a<(Subscript[x, 1])<(Subscript[x, 2])<b, the function f lies strictly below the portion of the secant line through the points ((Subscript[x, 1]),f((Subscript[x, 1]))) and ((Subscript[x, 2]),f((Subscript[x, 2]))) when (Subscript[x, 1])<x<(Subscript[x, 2]). If the function lies above the line, we say that f is concave downward on the interval. 

	It is important to note exactly what this definition says. If the function lies strictly below the portion of the secant line through (a,f(a)) and (b,f(b)), this does not mean that the function is concave upward on (a,b). A useful comparison here can be made with the notion of an increasing function. We do not say that a function f(x) is increasing on the interval (a,b) if f(b)>f(a); rather we say that it is increasing only if f((Subscript[x, 2]))>f((Subscript[x, 1])) for all a<(Subscript[x, 1])<(Subscript[x, 2])<b. The same idea applies in our case.

To see this idea geometrically, we shall define a Mathematica module concaveTest. It will take as input a function f(x) and the endpoints a and b of the interval on which we need to examine concavity of the function. The module produces a graph of the function f(x) on the interval [a,b] as well as the portion of the secant line through ((Subscript[x, 1]),f((Subscript[x, 1]))) and ((Subscript[x, 2]),f((Subscript[x, 2]))) on the interval (Subscript[x, 1])<x<(Subscript[x, 2]), where a<(Subscript[x, 1]) and (Subscript[x, 2])<b. Using the slider controls, we can change the point (Subscript[x, 1]) and the width (Subscript[x, 2])-(Subscript[x, 1]) of the interval on which the secant line is drawn.

concaveTest[f_,a_,b_]:=DynamicModule[{x,g,p1,p2},g[x_]=f[x];Manipulate[p1=Plot[g[x],{x,a,b},PlotStyle->RGBColor[0,0,1]];
    p2=Plot[g[x1]+((g[x1+d]-g[x1])/(d))*(x-x1),{x,x1,x1+d},PlotStyle->RGBColor[1,0,0]];Show[p1,p2],{x1,a,b},{{d,(b-a)/3,"Width"},0,b-x1}]]

To see this process in action, let us first define the function f(x)=(x^3)+x.

Clear[f,x];
f[x_]:=x^3+x;

We want to compare the graph of this function on the interval (0,2) to the secant lines through the points ((Subscript[x, 1]),f((Subscript[x, 1]))) and ((Subscript[x, 2]),f((Subscript[x, 2]))) for all a<(Subscript[x, 1])<(Subscript[x, 2])<b. We do this by executing the module concaveTest for this choice of function f; we set a=0 and b=2.

concaveTest[f,0,2]

We can see from the graph that the graph of the function lies below all the secant lines. Thus f(x)=(x^3)+x is concave upward on the interval (0,2). If we replace 2 by a larger value, we see that in fact the function is concave upward on the interval (0,∞).

We can perform the same type of analysis on non-positive numbers. For example, if we apply concaveTest on the interval (-2,0), we obtain the following:

concaveTest[f,-2,0]

We see that the graph of the function now lies above the all the secant lines. For this reason, we can say that (x^3)+x is concave downward on the interval (-2,0).

Finally, let us see what happens if we choose a negative number and a positive number, say -1 and 1, as the endpoints, and apply concaveTest. Then we have

concaveTest[f,-1,1]

Adjusting the sliders, we can find a secant line such that the graph of the function is both above and below the secant line. So we can conclude that the function is neither concave upward or concave downward on any interval containing both -1 and 1; in particular it is not concave upward or downward on the interval (-2,2). Remember the definition: the function is concave up on an interval only if we can choose any two points in that interval and have the line through those two points lie above the graph. Here we have found a pair of points so that this does not occur, therefore the function is not concave up on any interval containing -1 and 1. 

	Now suppose that we choose different points to draw the secant line:

concaveTest[f,-1,1]

We see that in this instance the curve lies below the secant line. This does not contradict our statement above, that (x^3)+x is not concave upward or downward on the interval (-1,1). Remember the definition again! To be concave upward on the interval (-1,1) we must be able to choose any pair of points in that interval, and the curve must lie below the resulting line. Although the curve lies below the line for some choices of points, like -0.25 and 0.75, it does not lie below the line for all choices--in particular the curve does not lie below the line for the choices -0.75 and 0.75.

	Because the function f(x) is concave up for x>0 and concave down for x<0, we say that the point x=0 is an inflection point, or a point of inflection. In general, an inflection point x=(Subscript[x, 0]) is a point at which the function changes concavity.

Experiment 9.1a

Consider the function (Subscript[f, 1])(x)=(e^(-(x^2))) on the interval -3<x<3. Verify that (Subscript[f, 1]) is concave downward on (((-1)/(Sqrt[2])),(1/(Sqrt[2]))) and that (Subscript[f, 1]) is concave upward on both (-3,((-1)/(Sqrt[2]))) and ((1/(Sqrt[2])),3).

Experiment 9.1b

Consider the function (Subscript[f, 2])(x)=(x^3)-4x+1 on the interval -2<x<2.  Decide which (if any) of the points x=-1, x=0, or x=1 is an inflection point for (Subscript[f, 2]). Explain your reasoning.

Experiment 9.1c

Analyze the function (Subscript[f, 3])(x)=ln(x)-(1/(3x-6)) on the interval 0<x<2. Note that the function has vertical asymptotes when x=0 or x=2. Determine the approximately the intervals where (Subscript[f, 3]) is concave upward and the intervals where (Subscript[f, 3]) is concave downward. Try to be accurate to within ±0.5.

9.2 Concavity and Tangent Lines

There is another interpretation which we can give to concavity. Let us return to our original function f(x)=(x^3)+x. The following module, called slopeTest, takes as input the function f and end endpoints of an interval. It then plots a graph of the function f in blue, and a graph of the tangent line to f through ((Subscript[x, 0]),f((Subscript[x, 0]))) in red. The slider controls the point (Subscript[x, 0]).

slopeTest[f_,a_,b_]:=DynamicModule[{x,g,p1,p2},g[x_]=f[x];Manipulate[p1=Plot[g[x],{x,a,b},PlotStyle->RGBColor[0,0,1]];
                 p2=Plot[g[x0]+g'[x0](x-x0),{x,a,b},PlotStyle->RGBColor[1,0,0]];
Show[p1,p2],{{x0,(a+b)/2},a,b}]]

Once again we define our function.

Clear[f];
f[x_]:=x^3+x;

Then, to see this module in action, we use slopeTest to plot f(x)=(x^3)+x and experiment with the tangent line to f through various points ((Subscript[x, 0]),f((Subscript[x, 0]))), in the window -2<x<2.

slopeTest[f,-2,2]

Note that the tangent line lies below the function in a small interval around the point of tangency; in particular the tangent line on the above plot is below the curve for -1<x<2. Experimenting tangent lines for positive values of (Subscript[x, 0]), we see that all those lines are below the graph of the function on a small interval around the point (Subscript[x, 0]).

On the other hand, if we look at the tangent lines that are tangent to the curve at points with negative x-coordinate, the reverse occurs. The following graph shows what happens if we choose (Subscript[x, 0])=-0.5.

slopeTest[f,-2,2]

Choosing different negative values for (Subscript[x, 0]) we see that the tangent line is above the curve in some small interval around the point of tangency.

We have already decided that the function f(x)=(x^3)+x is concave upward for x>0 and that it is concave downward for x<0. Moreover, we have just seen that the tangent lines to f are below the function in an interval around the point of tangency when x>0, and that they are above the curve in an interval around the point of tangency when x<0. This agreement is not coincidental. If f(x) is concave upward on the interval (a,b), then for every a<(Subscript[x, 0])<b, the tangent line to f through the point ((Subscript[x, 0]),f((Subscript[x, 0]))) is below the curve in some interval around the point of tangency. On the other hand, if f is concave downward on that interval, then the tangent lines must lie above the curve in some interval around the point of tangency.

Thus, we can determine whether a function is concave up or concave down at a given point by examining the tangent line at that point. If the tangent line lies below the curve in an interval around the point of tangency, then the curve is concave up at that point, while if the tangent line lies above the curve in an interval around the point of tangency, then the curve is concave downward at that point.

Returning to our example f(x)=(x^3)+x, because the tangent line lies below the curve in an interval around the point of tangency for all points x>0, and because the tangent lines lie above the curve in an interval around the point of tangency when x<0, we can conclude that f(x)=(x^3)+x is concave upward for x>0 and concave downward for x<0.

Experiment 9.2a

Consider the function (Subscript[f, 1])(x)=(e^(-(x^2))) on the interval -3<x<3. Use the process slopeTest to verify that (Subscript[f, 1]) is concave downward on (((-1)/(Sqrt[2])),(1/(Sqrt[2]))) and that (Subscript[f, 1]) is concave upward on both (-3,((-1)/(Sqrt[2]))) and ((1/(Sqrt[2])),3).

Experiment 9.2b

Consider the function (Subscript[f, 2])(x)=(x^3)-4x+1 on the interval -2<x<2. Use the process slopeTest to decide which (if any) of the points x=-1, x=0, or x=1 is an inflection point for (Subscript[f, 2]). Explain your reasoning. This should confirm the answer you obtained for Experiment 9.1b.

Experiment 9.2c

Use the process slopeTest to determine the intervals on which this function (Subscript[f, 3])(x)=ln(x)-(1/(3x-6)) is concave up or down. Use the interval 0<x<2. Note that the function has vertical asymptotes when x=0 or x=2. Try to be accurate to within ±0.2.

9.3 Concavity and the Second Derivative

Once more we return to our original function f(x)=(x^3)+x. Now we shall plot both the function and it second derivative on the same axes.

Clear[f];
f[x_]:=x^3+x;
Plot[{f[x],f''[x]},{x,-2,2},PlotRange->{-4,4},PlotStyle->{{RGBColor[1,0,0]},{RGBColor[0,0,1]}}]

Note that the second derivative is positive when x>0 and that the second derivative is negative when x<0; at the same time we already know that the function is concave upward when x>0 and the function is concave downward when x<0. This relationship is not coincidental. In fact, a function is concave upward at points where the second derivative is positive, and it is concave downward at points where the second derivative is negative.

	We can use the Mathematica command Solve to determine exactly where the function changes concavity as follows.

Solve[f''[x]==0,x]

Thus we see that the function changes concavity when x=0; we can then use the graph to conclude that the function is concave upward for x>0 and concave downward for x<0.

Experiment 9.3a

Consider the function (Subscript[f, 1])=(e^(-(x^2))) in the window -3<x<3 and 0<y<1. Show that (Subscript[f, 1]) is concave downward on (((-1)/(Sqrt[2])),(1/(Sqrt[2]))) and that (Subscript[f, 1]) is concave upward on both (-3,((-1)/(Sqrt[2]))) and ((1/(Sqrt[2])),3).

Experiment 9.3b

Consider the function (Subscript[f, 2])(x)=(x^3)-4x+1 in the window -2<x<2 and -5<y<5. Use the second derivative to decide which (if any) of the points x=-1, x=0, or x=1 is an inflection point for (Subscript[f, 2]). This should confirm the answer you obtained for Experiment 9.1b.

Experiment 9.3c

Use the second derivative to determine the intervals on which the function (Subscript[f, 3])(x)=ln(x)-(1/(3x-6)) is concave up or down. Use the window 0<x<2 and -5<y<5. Note that the function has vertical asymptotes when x=0 or x=2. Be sure to give exact values, and if appropriate, a numerical approximation.

Credits

These laboratories were created by Raouf Boules, Geoff Goodson, Ohoe Kim and Mike O'Leary for use in the Calculus courses of Towson University. Commercial use is prohibited without permission of the authors. Non-commercial use is permitted, provided this credit section is retained.