Math Applets

Mean Value Theorem

Mean Value Theorem:

Let f:[a,b]Rf : [a,b] \to \mathbb{R} be continuous on [a,b][a,b] and differentiable on (a,b)(a,b). Then there exists a c(a,b)c \in (a,b) such that

f(c)=f(b)f(a)ba.f'(c) = \frac{f(b) - f(a)}{b - a}.

How to use the applet

  • Drag the points aa (green) and bb (red) along the xx-axis to change the interval [a,b][a,b].
  • The points (a,f(a))(a,f(a)) and (b,f(b))(b,f(b)) are marked on the graph.
  • The red line is the secant through (a,f(a))(a,f(a)) and (b,f(b))(b,f(b)). Its slope is f(b)f(a)ba\frac{f(b)-f(a)}{b-a}.
  • The point cc (purple) is computed so that f(c)f'(c) equals this secant slope.
  • The purple line is drawn parallel to the secant through (c,f(c))(c,f(c)), visualizing that the tangent slope at cc matches the secant slope.
  • As you move aa and bb, the secant slope changes, and the applet updates cc accordingly.
  • The theorem guarantees that at least one such point c(a,b)c\in(a,b) exists (for functions continuous on [a,b][a,b] and differentiable on (a,b)(a,b)); in this example the applet displays one solution.

Loading graph…
  • Hold Shift + scroll to zoom
  • Hold Shift + drag to move
  • Points shaped like <> act as sliders

Description

Link to code.

Reference: Lecture Notes Calculus 1 ( May22,2022 ) Figure6.6 and Theorem6.10 page 104

To demonstrate the theorem i have selected a simple function 0.2x30.5x2+20.2*x^3 - 0.5*x^2 + 2 with derivative 0.6x2x0.6x^2 - x.

    const f = (x: number) => 0.2 * x * x * x - 0.5 * x * x + 2;
    // const fPrime = (x: number) => 0.6 * x * x - x;

Points aa and bb can be adjusted. The secant is just a line passing though f(a)f(a) and f(b)f(b). To construct cc i solved the equation:

f(c)=f(b)f(a)ba=secantSlopef'(c) = \frac{f(b) - f(a)}{b-a} = \text{secantSlope}

Giving c2cf(b)f(a)(ba)0.6c^2 - c - \frac{f(b) - f(a)}{(b-a)*0.6}. Solving with the quadratric formula: c=1±1+40.6secantSlope20.6c =1 ± \frac{\sqrt{1 + 4*0.6*\text{secantSlope}}}{2*0.6}. If the discriminant is negative or cc does not lie on the interval [a,b][a,b] i return NaN (not a number).

    function findC(): number {
        const a = pointA.X();
        const b = pointB.X();
        const fa = f(a);
        const fb = f(b);
        const secantSlope = (fb - fa) / (b - a);
        const discriminant = 1 + 4 * 0.6 * secantSlope;
        if (discriminant < 0) {
            return NaN;
        }
        const cPos = (1 + Math.sqrt(discriminant)) / (2 * 0.6);
        const cNeg = (1 - Math.sqrt(discriminant)) / (2 * 0.6);
        const minAB = Math.min(a, b);
        const maxAB = Math.max(a, b);
        if (cPos >= minAB && cPos <= maxAB) {
            return cPos;
        } else if (cNeg >= minAB && cNeg <= maxAB) {
            return cNeg;
        } else {
            return NaN;
        }
    }

Finally the tangent line (best approximation of f(c)f'(c)) has to be parallel to the secant.

    board.create('parallel', [secant, pointC],...)