Laboratory 8
Mean Value Theorem

Introduction

In this laboratory, we introduce an important theorem from calculus, known as the mean value theorem or, sometimes, as Lagrange's mean value theorem. Its statement is given below. 

Theorem. Let f be a continuous function on the closed interval [a,b] that is differentiable at all points of the open interval (a,b). Then there exists a number c∈(a,b) such that
(1)		f'(c)=((f(b)-f(a))/(b-a)).

We will first explore the meaning of the mean value theorem and then look at some applications.

8.1. The Meaning of the Mean Value Theorem

Let us take a look at the statement of the theorem. We can interpret the two sides of equation (1) as the slopes of two straight lines. The ratio on the right side of (1) is the slope of the line through the points (a,f(a)) and (b,f(b)), that is, the line connecting the two endpoints of the graph y=f(x), a≤x≤b. The derivative on the left side of (1), on the other hand, is the slope of the tangent line to the same graph at the point (c,f(c)). Therefore, the theorem states that there is a point on the graph y=f(x) (namely, (c,f(c))) such that the tangent line at that point has the same slope as the straight line connecting the endpoints of the graph. 

To see an explicit example of this, let us look at the graph y=(x^2)sin(2x), 1≤x≤5. We start by defining the function, setting a=1 and b=5, and finding the slope m and the equation of the straight line through the endpoints. We then plot the function together with the straight line through the endpoints.

Clear[a,b,m,f,line]
f[x_]:=x^2*Sin[2x]
a=1;b=5;
m=(f[b]-f[a])/(b-a);
line[x_]:=f[a]+m*(x-a)

Plot[{f[x],line[x]},{x,a,b},PlotStyle->{Black,Red}]

Next, we add to the above plot a third graph: the tangent line y=f(c)+f'(c)(x-c) at the point (c,f(c)) of the graph. Since we want to be able to vary c, we need to make our new plot dynamic. To  avoid some of the side effects of dynamic plotting, it is convenient to define a new custom for this. The new command, defined in the module below, is named visualMVT[]. It takes three arguments:
	f	the name of a function
	a, b	the endpoints of an interval.
The command visualMVT[f, a, b] then produces a plot containing: the graph y=f(x) for a≤x≤b, in black; the straight line connecting (a,f(a)) and (b,f(b)), in red; and the tangent line y=f(c)+f'(c)(x-c) at the point (c,f(c)) of the graph, in blue, where c can change dynamically in the range a≤c≤b. Initially, c is set equal to a.

visualMVT[f_,a_,b_]:=DynamicModule[{x,g,ξ,p1,p2},
g[x_]=f[x];
Manipulate[
p1=Plot[
{g[x],g[a]+(g[b]-g[a])/(b-a)*(x-a)},
{x,a,b},PlotStyle->{Black,Red}];
p2=Plot[g[ξ]+g'[ξ]*(x-ξ),{x,a,b},PlotStyle->Blue];
Show[p1,p2],{ξ,a,b}]]

Here is the effect of this command on our example (f(x)=(x^2)sin(2x), a=1, b=5).

visualMVT[f,a,b]

We can "drag" the tangent line along the graph using the slider. In particular, after some experimentation, we see that when c≈1.47, the blue and red lines appear parallel; hence, their slopes must be (almost) equal. Therefore, we have found that, for the function f(x)=(x^2)sin(2x), 
			f'(1.47)≈((f(5)-f(1))/(5-1)).

The mean value theorem basically says that this is not a coincidence. Since the function f(x)=(x^2)sin(2x) is continuous and differentiable on the whole real line, the mean value theorem ensures that when we replace the interval [1,5] by any other closed interval [a,b], we will be able to find a number c in that new interval such that (1) will hold and the tangent line to the graph at c will be parallel to the secant line through (a,f(a)) and (b,f(b)). For example, here are a few pairs of intervals [a,b] and ponts c∈(a,b) that one may discover using the above procedure:
	c≈1.40 is acceptable for the interval [0,5];
	c≈1.26 is acceptable for the interval [-2,3];
	c≈4.125 is acceptable for the interval [3,6].
	
Note what the theorem does not say. It does not say where in the interval the point c may be located. That is because, in general, there is no way to predict the location of c. Indeed, there may be more than one point c in the given interval that satisfies equation (1). For example, experimentation with the slider in the above example reveals that there are three possible candidates for c in (1,5): c≈1.47, c≈2.41 and c≈4.10.

Experiment 8.1

For each of the following functions, use the command visualMVT[] to produce a dynamic plot of the function on the given interval [a,b] together with the secant line through the endpoints of the graph and the tangent line at a "moving point" x=c. Then use that dynamic plot from to find approximately the points c∈(a,b) that satisfy the conclusion of the mean value theorem. If there is more than one such point, list all the possibilities in your answer.
(a) f(x)=(x^2) (e^(-x/2)), a=-0.5, b=3;		(b) f(x)=((x+1)/(x-1)),a=2, b=3;
(c) f(x)=x cos(1+(Sqrt[x])), a=4, b=10;	(d) f(x)=(((x+(1/x)))^x), a=0.5, b=2;

8.2  Obtaining Better Approximations of c.

The built-in command FindRoot will allow us to find a more precise value of the point c satisfying the equation (1). In the example discussed in Section 8.1, we saw that the approximate values of c such that 
f'(c)=((f(5)-f(1))/(5-1)) are c≈1.47, c≈2.41 and c≈4.10. We now use these approximate values to get better approximations.

Clear[a,b,m,f]
f[x_]:=x^2*Sin[2x]
a=1;b=5;
m=(f[b]-f[a])/(b-a);

The command FindRoot takes an equation we need to solve and an initial guess as parameters. In our case, the equation is f'(x)=c, and the initial guesses have been obtained in Section 8.1.

FindRoot[f'[x]==m,{x,1.47}]
FindRoot[f'[x]==m,{x,2.41}]
FindRoot[f'[x]==m,{x,4.10}]

Experiment 8.2

For each of the following functions, use the results of Experiment 8.1 and the command FindRoot to determine the points c∈(a,b) that satisfy the conclusion of the mean value theorem. If there is more than one such point, list all the possibilities in your answer.
(a) f(x)=(x^2) (e^(-x/2)), a=-0.5, b=3;		(b) f(x)=((x+1)/(x-1)),a=2, b=3;
(c) f(x)=x cos(1+(Sqrt[x])), a=4, b=10;	(d) f(x)=(((x+(1/x)))^x), a=0.5, b=2;

8.3 Why are Differentiability and Continuity Conditions Important?

The hypotheses of the Mean Value Theorem not only require the continuity of f(x), but they require as well that f be differentiable. We should also point out that the closed bounded interval [a, b] cannot be replaced by an open interval (a, b), or an unbounded interval such as [a, ∞). Let us give some examples which illustrate difficulties that may arise if we try to weaken some of these hypotheses.

Consider the function  f(x) = ((| x -2 |)/(x - 2))  on the interval  [1, 3].

Clear[f]
f[x_] := Abs[x-2]/(x-2)

Plot[f[x], {x, 1, 3}]

The secant line joining the points (1, -1) and (3, 1) has equation y=x-2, so m=1, but there is no point c in the interval (-1, 3) with the property that f '(c)=m, (remember, f '(x)=0 everywhere except at  x=2). The problem arises because of the discontinuity of y=f(x) at x=2.

Plot[{f[x], x-2}, {x, 1, 3}, PlotStyle -> {Thickness[.005], {Thickness[.007], RGBColor[1,0,0]}}]

Consider the function g(x)=|x-2| on the interval [1, 3].

Clear[g]
g[x_] := Abs[x - 2]

Plot[g[x], {x, 1, 3}]

Examining the secant line joining the points (1, 1) and (3, 1), we see that its equation is y=1, and there is no point c in the interval (1, 3) with g '(c)=0. Of course the fact that gis not differentiable at x=2 is the reason the Mean Value Theorem fails to apply.

Plot[{g[x], 1}, {x, 1, 3},PlotStyle -> {Thickness[.005], {Thickness[.007], RGBColor[1,0,0]}} ]

Experiment 8.3

For each of the following functions on the prescribed interval [a, b], explain why the Mean Value Theorem is not applicable.
	1.   f(x) = (1/(((x - 1))^2)),  a = 0,  b = 3.
	
	2.  f(x) = arctan(x),  a = 0, b= ∞.
	
	3.  f(x) = |x + sin x|,  a = -2,  b = 3.

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.