JSXGraph logo
JSXGraph
JSXGraph share

Share

Mean Value Theorem
QR code
<iframe 
    src="http://jsxgraph.org/share/iframe/mean-value-theorem" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Mean Value Theorem" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>

<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution ShareAlike 4.0 International License.
    https://creativecommons.org/licenses/by-sa/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-5, 10, 7, -6], axis: true, keepaspectratio: true });
    
    var p = [];
    p[0] = board.create('point', [-1, -2], { size: 2 });
    p[1] = board.create('point', [6, 5], { size: 2 });
    p[2] = board.create('point', [-0.5, 1], { size: 2 });
    p[3] = board.create('point', [3, 3], { size: 2 });
    var f = JXG.Math.Numerics.lagrangePolynomial(p);
    var graph = board.create('functiongraph', [f, -10, 10]);
    
    var g = function(x) {
        return JXG.Math.Numerics.D(f)(x) - (p[1].Y() - p[0].Y()) / (p[1].X() - p[0].X());
    };
    
    var r = board.create('glider', [
            function() { return JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5); },
            function() { return f(JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5)); },
            graph], { name: ' ', size: 3, color: JXG.palette.blue, fixed: true });
    
    board.create('tangent', [r], { strokeColor: '#ff0000' });
    var line = board.create('line', [p[0], p[1]], { strokeColor: '#ff0000', dash: 1 });
    
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID = 'your_div_id'; // Insert your id here!

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-5, 10, 7, -6], axis: true, keepaspectratio: true });

var p = [];
p[0] = board.create('point', [-1, -2], { size: 2 });
p[1] = board.create('point', [6, 5], { size: 2 });
p[2] = board.create('point', [-0.5, 1], { size: 2 });
p[3] = board.create('point', [3, 3], { size: 2 });
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f, -10, 10]);

var g = function(x) {
    return JXG.Math.Numerics.D(f)(x) - (p[1].Y() - p[0].Y()) / (p[1].X() - p[0].X());
};

var r = board.create('glider', [
        function() { return JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5); },
        function() { return f(JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5)); },
        graph], { name: ' ', size: 3, color: JXG.palette.blue, fixed: true });

board.create('tangent', [r], { strokeColor: '#ff0000' });
var line = board.create('line', [p[0], p[1]], { strokeColor: '#ff0000', dash: 1 });
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Mean Value Theorem" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is licensed under a 
   Creative Commons Attribution ShareAlike 4.0 International License.
   https://creativecommons.org/licenses/by-sa/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-5, 10, 7, -6], axis: true, keepaspectratio: true });
   
   var p = [];
   p[0] = board.create('point', [-1, -2], { size: 2 });
   p[1] = board.create('point', [6, 5], { size: 2 });
   p[2] = board.create('point', [-0.5, 1], { size: 2 });
   p[3] = board.create('point', [3, 3], { size: 2 });
   var f = JXG.Math.Numerics.lagrangePolynomial(p);
   var graph = board.create('functiongraph', [f, -10, 10]);
   
   var g = function(x) {
       return JXG.Math.Numerics.D(f)(x) - (p[1].Y() - p[0].Y()) / (p[1].X() - p[0].X());
   };
   
   var r = board.create('glider', [
           function() { return JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5); },
           function() { return f(JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5)); },
           graph], { name: ' ', size: 3, color: JXG.palette.blue, fixed: true });
   
   board.create('tangent', [r], { strokeColor: '#ff0000' });
   var line = board.create('line', [p[0], p[1]], { strokeColor: '#ff0000', dash: 1 });
   
</jsxgraph>

Mean Value Theorem

This code builds a Lagrange interpolation polynomial through four points and plots it. Then it visualizes the *mean value theorem*, i.e. there exists a point between the points $A$ and $B$ on the curve such that the tangent at this point has the same slope as the dotted line through the two points $A$ and $B$.
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-5, 10, 7, -6], axis: true, keepaspectratio: true });

var p = [];
p[0] = board.create('point', [-1, -2], { size: 2 });
p[1] = board.create('point', [6, 5], { size: 2 });
p[2] = board.create('point', [-0.5, 1], { size: 2 });
p[3] = board.create('point', [3, 3], { size: 2 });
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f, -10, 10]);

var g = function(x) {
    return JXG.Math.Numerics.D(f)(x) - (p[1].Y() - p[0].Y()) / (p[1].X() - p[0].X());
};

var r = board.create('glider', [
        function() { return JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5); },
        function() { return f(JXG.Math.Numerics.root(g, (p[0].X() + p[1].X()) * 0.5)); },
        graph], { name: ' ', size: 3, color: JXG.palette.blue, fixed: true });

board.create('tangent', [r], { strokeColor: '#ff0000' });
var line = board.create('line', [p[0], p[1]], { strokeColor: '#ff0000', dash: 1 });

license

This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.