JSXGraph logo
JSXGraph
JSXGraph share

Share

Differentiability
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/differentiability" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Differentiability" 
    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 4.0 International License.
    https://creativecommons.org/licenses/by/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    const board = JXG.JSXGraph.initBoard(BOARDID, {
        boundingbox: [-5, 10, 7, -6], 
        axis: true,
        showClearTraces: true,
        showFullscreen: true});
    
    // Blue points that define the function graph
    var p = [];
    p[0] = board.create('point', [-1,0], {withLabel: false, size:2, color:'blue'});
    p[1] = board.create('point', [-0.5,3], {withLabel: false, size:2, color:'blue'});
    p[2] = board.create('point', [2,0.5], {withLabel: false, size:2, color:'blue'});
    p[3] = board.create('point', [6, 3], {withLabel: false, size:2, color:'blue'});
    
    // Lagrange polynomial through blue points
    var pol = JXG.Math.Numerics.lagrangePolynomial(p);
    var graph = board.create('functiongraph', [pol, -10, 10], {strokeWidth: 2, name:"f", withLabel: true});
    
    var x0 = board.create('glider', [1, 0, board.defaultAxes.x], {name: 'x_0', size:4, label: {fontSize:20}});
    var x = board.create('glider', [5, 0, board.defaultAxes.x], {name: 'x', size:4, label: {fontSize:20}});
    var fx0 = board.create('point', [function() { return x0.X(); }, function() { return pol(x0.X()); }], {name: '', color: 'grey', fixed: true, size:3});
    var fx = board.create('point', [function() { return x.X(); }, function() { return pol(x.X()); }], {name: '', color: 'grey', fixed: true, size:3});
    // Secant through fx0 and fx
    var line = board.create('line', [fx0, fx],{strokeColor:'#ff0000', dash:2});
    
    // Trace point visualizing f_1
    var f1 = board.create('point', [
            () => x.X(),
            () => (fx.Y() - fx0.Y()) / (fx.X() - fx0.X() + 0.0000001)],
            {size: 1, name: 'f_1', color: 'black', fixed: true, trace: true});
    
    // Print function values of f_1
    var txt = board.create('text', [0.5, 7, 
           () => '( ' + 
                   fx.Y().toFixed(2) + ' - (' + fx0.Y().toFixed(2) + 
                   ') ) / ( ' + 
                   fx.X().toFixed(2) + ' - (' + fx0.X().toFixed(2) +
                   ') ) = ' + ((fx.Y() - fx0.Y()) / (fx.X() - fx0.X())).toFixed(3)
        ]);
    
    // Plot derivative
    board.create('functiongraph',[JXG.Math.Numerics.D(pol)], {dash: 2, name:"f'", withLabel: true});
    
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution 4.0 International License.
https://creativecommons.org/licenses/by/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!

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

// Blue points that define the function graph
var p = [];
p[0] = board.create('point', [-1,0], {withLabel: false, size:2, color:'blue'});
p[1] = board.create('point', [-0.5,3], {withLabel: false, size:2, color:'blue'});
p[2] = board.create('point', [2,0.5], {withLabel: false, size:2, color:'blue'});
p[3] = board.create('point', [6, 3], {withLabel: false, size:2, color:'blue'});

// Lagrange polynomial through blue points
var pol = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [pol, -10, 10], {strokeWidth: 2, name:"f", withLabel: true});

var x0 = board.create('glider', [1, 0, board.defaultAxes.x], {name: 'x_0', size:4, label: {fontSize:20}});
var x = board.create('glider', [5, 0, board.defaultAxes.x], {name: 'x', size:4, label: {fontSize:20}});
var fx0 = board.create('point', [function() { return x0.X(); }, function() { return pol(x0.X()); }], {name: '', color: 'grey', fixed: true, size:3});
var fx = board.create('point', [function() { return x.X(); }, function() { return pol(x.X()); }], {name: '', color: 'grey', fixed: true, size:3});
// Secant through fx0 and fx
var line = board.create('line', [fx0, fx],{strokeColor:'#ff0000', dash:2});

// Trace point visualizing f_1
var f1 = board.create('point', [
        () => x.X(),
        () => (fx.Y() - fx0.Y()) / (fx.X() - fx0.X() + 0.0000001)],
        {size: 1, name: 'f_1', color: 'black', fixed: true, trace: true});

// Print function values of f_1
var txt = board.create('text', [0.5, 7, 
       () => '( ' + 
               fx.Y().toFixed(2) + ' - (' + fx0.Y().toFixed(2) + 
               ') ) / ( ' + 
               fx.X().toFixed(2) + ' - (' + fx0.X().toFixed(2) +
               ') ) = ' + ((fx.Y() - fx0.Y()) / (fx.X() - fx0.X())).toFixed(3)
    ]);

// Plot derivative
board.create('functiongraph',[JXG.Math.Numerics.D(pol)], {dash: 2, name:"f'", withLabel: true});
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Differentiability" 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 4.0 International License.
   https://creativecommons.org/licenses/by/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   const board = JXG.JSXGraph.initBoard(BOARDID, {
       boundingbox: [-5, 10, 7, -6], 
       axis: true,
       showClearTraces: true,
       showFullscreen: true});
   
   // Blue points that define the function graph
   var p = [];
   p[0] = board.create('point', [-1,0], {withLabel: false, size:2, color:'blue'});
   p[1] = board.create('point', [-0.5,3], {withLabel: false, size:2, color:'blue'});
   p[2] = board.create('point', [2,0.5], {withLabel: false, size:2, color:'blue'});
   p[3] = board.create('point', [6, 3], {withLabel: false, size:2, color:'blue'});
   
   // Lagrange polynomial through blue points
   var pol = JXG.Math.Numerics.lagrangePolynomial(p);
   var graph = board.create('functiongraph', [pol, -10, 10], {strokeWidth: 2, name:"f", withLabel: true});
   
   var x0 = board.create('glider', [1, 0, board.defaultAxes.x], {name: 'x_0', size:4, label: {fontSize:20}});
   var x = board.create('glider', [5, 0, board.defaultAxes.x], {name: 'x', size:4, label: {fontSize:20}});
   var fx0 = board.create('point', [function() { return x0.X(); }, function() { return pol(x0.X()); }], {name: '', color: 'grey', fixed: true, size:3});
   var fx = board.create('point', [function() { return x.X(); }, function() { return pol(x.X()); }], {name: '', color: 'grey', fixed: true, size:3});
   // Secant through fx0 and fx
   var line = board.create('line', [fx0, fx],{strokeColor:'#ff0000', dash:2});
   
   // Trace point visualizing f_1
   var f1 = board.create('point', [
           () => x.X(),
           () => (fx.Y() - fx0.Y()) / (fx.X() - fx0.X() + 0.0000001)],
           {size: 1, name: 'f_1', color: 'black', fixed: true, trace: true});
   
   // Print function values of f_1
   var txt = board.create('text', [0.5, 7, 
          () => '( ' + 
                  fx.Y().toFixed(2) + ' - (' + fx0.Y().toFixed(2) + 
                  ') ) / ( ' + 
                  fx.X().toFixed(2) + ' - (' + fx0.X().toFixed(2) +
                  ') ) = ' + ((fx.Y() - fx0.Y()) / (fx.X() - fx0.X())).toFixed(3)
       ]);
   
   // Plot derivative
   board.create('functiongraph',[JXG.Math.Numerics.D(pol)], {dash: 2, name:"f'", withLabel: true});
   
</jsxgraph>

Differentiability

If the function $f: D \to {\mathbb R}$ is *differentiable* in $x_0\in D$ then there is a function $f_1: D \to {\mathbb R}$ that is continuous in $x_0$ such that $$f(x) = f(x_0) + (x-x_0) f_1(x) \,.$$ This means: $$f_1(x) = \frac{f(x) - f(x_0)}{x-x_0} \,.$$ Drag the point $x$ to see the function $f_1$.
// Define the id of your board in BOARDID

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

// Blue points that define the function graph
var p = [];
p[0] = board.create('point', [-1,0], {withLabel: false, size:2, color:'blue'});
p[1] = board.create('point', [-0.5,3], {withLabel: false, size:2, color:'blue'});
p[2] = board.create('point', [2,0.5], {withLabel: false, size:2, color:'blue'});
p[3] = board.create('point', [6, 3], {withLabel: false, size:2, color:'blue'});

// Lagrange polynomial through blue points
var pol = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [pol, -10, 10], {strokeWidth: 2, name:"f", withLabel: true});

var x0 = board.create('glider', [1, 0, board.defaultAxes.x], {name: 'x_0', size:4, label: {fontSize:20}});
var x = board.create('glider', [5, 0, board.defaultAxes.x], {name: 'x', size:4, label: {fontSize:20}});
var fx0 = board.create('point', [function() { return x0.X(); }, function() { return pol(x0.X()); }], {name: '', color: 'grey', fixed: true, size:3});
var fx = board.create('point', [function() { return x.X(); }, function() { return pol(x.X()); }], {name: '', color: 'grey', fixed: true, size:3});
// Secant through fx0 and fx
var line = board.create('line', [fx0, fx],{strokeColor:'#ff0000', dash:2});

// Trace point visualizing f_1
var f1 = board.create('point', [
        () => x.X(),
        () => (fx.Y() - fx0.Y()) / (fx.X() - fx0.X() + 0.0000001)],
        {size: 1, name: 'f_1', color: 'black', fixed: true, trace: true});

// Print function values of f_1
var txt = board.create('text', [0.5, 7, 
       () => '( ' + 
               fx.Y().toFixed(2) + ' - (' + fx0.Y().toFixed(2) + 
               ') ) / ( ' + 
               fx.X().toFixed(2) + ' - (' + fx0.X().toFixed(2) +
               ') ) = ' + ((fx.Y() - fx0.Y()) / (fx.X() - fx0.X())).toFixed(3)
    ]);

// Plot derivative
board.create('functiongraph',[JXG.Math.Numerics.D(pol)], {dash: 2, name:"f'", withLabel: true});

license

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