Mean Value Theorem

I. Cnop
Vrije Universiteit Brussel
icnop@vub.ac.be

Move a tangent along a graph.

Programming an example

Clear[f]

graph[f_, intervalLeft_, intervalRight_]:=Plot[f[x],{x, intervalLeft, intervalRight}
	,PlotStyle -> Hue[1],DisplayFunction -> Identity]

touches[f_, x0_, intervalLeft_, intervalRight_]:=Plot[f[x0]+f'[x0] (x - x0),{x, intervalLeft, intervalRight},PlotStyle -> Hue[ .7],DisplayFunction -> Identity]

f[x_]:=1 - x^2;
a = -1;
b = 3;

Show[{graph[f, a, b], touches[f, 0, a, b]},PlotRange -> {-3, 3},DisplayFunction -> $DisplayFunction]

Replace  0  by other choices of  (Subscript[x, 0]) to get tangents at other points.

Another example

Clear[g]

g[x_]:=x - x^2
a=-0.5
b=2.5
Do[Show[{graph[g, a, b], touches[g, t, a, b]}
	,PlotRange -> {-3, 3},DisplayFunction -> $DisplayFunction],{t, a, b, 0.2}]

Double-click the grouped graphics cells to see an animation.

sol=Solve[g'[x0]==0,x0]

x0 /. First[sol]

For sufficiently smooth functions we have  the   ROLLE theorem saying that at some point between zeroes the tangent has to be horizontal.

Exercises

Try this for a large number of examples.

In some examples the tangent will be horizontal at several locations:

Clear[g]

g[x_]:= x^3 -  2 x^2 + 1
a=-1
b=3
Do[Show[{graph[g, a, b], touches[g, t, a, b]}
	,PlotRange -> {-3, 3},DisplayFunction -> $DisplayFunction],{t, a, b - 1, 0.2}]

Visualising the mean value theorem.

Join the endpoints of the graph by a straight segment:

Clear[f]

graph[f_, intervalLeft_, intervalRight_]:=Plot[f[x],{x, intervalLeft, intervalRight}
	,PlotStyle -> Hue[1],DisplayFunction -> Identity]

touches[f_, x0_, intervalLeft_, intervalRight_]:=Plot[f[x0]+f'[x0] (x - x0),{x, intervalLeft, intervalRight},PlotStyle -> Hue[0.5],DisplayFunction -> Identity]

segment[f_, intervalLeft_, intervalRight_]:=Plot[f[
              intervalLeft] + (f[intervalRight]  - 
                  f[intervalLeft]) (x - 
                    intervalLeft)/(intervalRight - intervalLeft),{x, intervalLeft, intervalRight},PlotStyle -> Hue[0.7],DisplayFunction -> Identity]

f[x_]:=x^3 - x^2 -  2  x + 1;
a = -2;
b = 
        2;

Show[{graph[f, a, b], touches[f, 0, a, b], segment[f, a, b]},PlotRange -> {-5, 5},DisplayFunction -> $DisplayFunction]

Do[Show[{graph[f, a, b], touches[f, t, a, b], 
                segment[f, a, b]}
	,PlotRange -> {-5, 5},DisplayFunction -> $DisplayFunction],{t, a, b, 0.2}]

For sufficiently smooth functions we have  the mean VALUE theorem saying that at some point the tangent has to be parallel to the segment.

An application in economy.

Clear[c, r]

Assume we have the following cost and return functions when manufacturing a quantity  x  (not necessarily a whole number) of items.

c[x_] :=  .125 x^3 -  2  x^2  + 15 x

r[x_] :=  .1 (x + 2)^3 -  x^2  + 6 x -  .8

Expand[r[x]]

We want to maximise profit , the value of  r(x)- c(x)

Plot[{c[x], r[x], r[x] - c[x]}, {x, 0, 10}, PlotRange -> All, 
      PlotStyle -> {Hue[0], Hue[0.5], GrayLevel[0.3]}]

In this graph, it is clear that we operate at a loss when output is low. It improves at reasonable levels:

Plot[{c[x], r[x], r[x] - c[x]}, {x, 0, 60}, 
      PlotRange -> {0, 5000}, 
      PlotStyle -> {Hue[0], Hue[0.6], GrayLevel[0.3]}]

Plot[r[x] - c[x], {x, 0, 60}, PlotRange -> All, 
      PlotStyle -> {Hue[0], Hue[0.6], GrayLevel[0.3]}]

and where profit is maximal, its tangent is horizontal and therefore the graphs of  c  and  r  are nearly parallel:

Plot[{r[x] - c[x], r'[x] - c'[x]}, {x, 0, 50}, 
      PlotRange -> All, 
      PlotStyle -> {GrayLevel[0.3], Hue[0.65]}]

Plot[{c[x], r[x]}, {x, 39, 42}, PlotRange -> All, 
      PlotStyle -> {Hue[0], Hue[0.5]}]

The slopes of the tangents are called "marginal ...."  in this setting.

Conclusion: at maximal profit we have marginal return = marginal cost

If we color the derivatives in the same color as the original functions, we see this intersection point:

Plot[{c'[x], r'[x], r'[x] - c'[x]}, {x, 0, 50}, 
      PlotRange -> {-100, 600}, 
      PlotStyle -> {Hue[0], Hue[0.6], GrayLevel[0.3]}]

Question

Is this also the case at maximal loss?

Plot[{r[x] - c[x], r'[x] - c'[x]}, {x, 0, 5}, 
      PlotRange -> {-11, 30}]

Plot[{c[x], r[x], r[x] - c[x]}, {x, 0, 5}, 
      PlotRange -> {-11, 30}, 
      PlotStyle -> {Hue[0], Hue[0.6], GrayLevel[0.3]}]

If we color the derivatives in the same color as the original functions, we see this intersection point again:

Plot[{c'[x], r'[x], r'[x] - c'[x]}, {x, 0, 5}, 
      PlotRange -> {-20, 20}, 
      PlotStyle -> {Hue[0], Hue[0.6], GrayLevel[0.3]}]

Conclusion: at maximal loss we also have marginal return = marginal cost

Proof of the mean value theorem.

If we deduct the straight segment from the graph, we obtain the mean value theorem from the Rolle theorem for any function  f :

Clear[f, rolle]
f[x_] := 1000 + 100 x  -  .5 (x^2) +  .001 (x^3)

rolle[f_, a_, b_, x_] := 
      Plot[{f[x], f[a] + ((f[b] - f[a])/(b - a)) (x - a), 
          f[x] - f[a] - ((f[b] - f[a])/(b - a)) (x - a)}, {x, a, 
          b}, PlotStyle -> {GrayLevel[0.3], Hue[0.8], 
            Hue[0]}]

rolle[f, 10, 100, x]

rolle[f, 0, 100, x]