JSXGraph logo
JSXGraph
JSXGraph share

Share

Antiderivative
QR code
<iframe 
    src="https://www.jsxgraph.uni-bayreuth.de/share/iframe/antiderivative" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Antiderivative" 
    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: 2 / 1; width: 100%;" data-ar="2 / 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: [-3, 10, 3, -3],
        axis: true,
        showClearTraces: true
    });
    
    var p = [];
    p.push(board.create('point', [-2, Math.random() * 5 + 5], {
        name: '',
        size: 2
    }));
    p.push(board.create('point', [0, 2], {
        name: '',
        size: 2
    }));
    p.push(board.create('point', [0.5, Math.random() * 1 + 7], {
        name: '',
        size: 2
    }));
    
    // f defines the function graph through the three points
    var f = JXG.Math.Numerics.lagrangePolynomial(p);
    
    var plot = board.create('functiongraph', [f, -3, 3]);
    
    var s = board.create('glider', [-2, f(-2), plot], {
        name: 'drag me',
        color: 'black',
        size: 5
    });
    var int = board.create('integral', [
        [function() {
            return p[0].X();
        }, function() {
            return s.X();
        }], plot
    ], {
        fillOpacity: 0.2
    });
    
    var F = board.create('point', [function() {
        return s.X();
    }, function() {
        return JXG.Math.Numerics.I([p[0].X(), s.X()], f);
    }], {
        trace: true,
        name: 'F',
        fillColor: '#0000aa',
        strokeColor: '#0000aa',
        face: '[]'
    });
 </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: [-3, 10, 3, -3],
    axis: true,
    showClearTraces: true
});

var p = [];
p.push(board.create('point', [-2, Math.random() * 5 + 5], {
    name: '',
    size: 2
}));
p.push(board.create('point', [0, 2], {
    name: '',
    size: 2
}));
p.push(board.create('point', [0.5, Math.random() * 1 + 7], {
    name: '',
    size: 2
}));

// f defines the function graph through the three points
var f = JXG.Math.Numerics.lagrangePolynomial(p);

var plot = board.create('functiongraph', [f, -3, 3]);

var s = board.create('glider', [-2, f(-2), plot], {
    name: 'drag me',
    color: 'black',
    size: 5
});
var int = board.create('integral', [
    [function() {
        return p[0].X();
    }, function() {
        return s.X();
    }], plot
], {
    fillOpacity: 0.2
});

var F = board.create('point', [function() {
    return s.X();
}, function() {
    return JXG.Math.Numerics.I([p[0].X(), s.X()], f);
}], {
    trace: true,
    name: 'F',
    fillColor: '#0000aa',
    strokeColor: '#0000aa',
    face: '[]'
});
<jsxgraph width="100%" aspect-ratio="2 / 1" title="Antiderivative" 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: [-3, 10, 3, -3],
       axis: true,
       showClearTraces: true
   });
   
   var p = [];
   p.push(board.create('point', [-2, Math.random() * 5 + 5], {
       name: '',
       size: 2
   }));
   p.push(board.create('point', [0, 2], {
       name: '',
       size: 2
   }));
   p.push(board.create('point', [0.5, Math.random() * 1 + 7], {
       name: '',
       size: 2
   }));
   
   // f defines the function graph through the three points
   var f = JXG.Math.Numerics.lagrangePolynomial(p);
   
   var plot = board.create('functiongraph', [f, -3, 3]);
   
   var s = board.create('glider', [-2, f(-2), plot], {
       name: 'drag me',
       color: 'black',
       size: 5
   });
   var int = board.create('integral', [
       [function() {
           return p[0].X();
       }, function() {
           return s.X();
       }], plot
   ], {
       fillOpacity: 0.2
   });
   
   var F = board.create('point', [function() {
       return s.X();
   }, function() {
       return JXG.Math.Numerics.I([p[0].X(), s.X()], f);
   }], {
       trace: true,
       name: 'F',
       fillColor: '#0000aa',
       strokeColor: '#0000aa',
       face: '[]'
   });
</jsxgraph>

Antiderivative

Dragging the black point shows that the antiderivative of the parabola looks like a polynomial of degree 3.
// Define the id of your board in BOARDID

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

var p = [];
p.push(board.create('point', [-2, Math.random() * 5 + 5], {
    name: '',
    size: 2
}));
p.push(board.create('point', [0, 2], {
    name: '',
    size: 2
}));
p.push(board.create('point', [0.5, Math.random() * 1 + 7], {
    name: '',
    size: 2
}));

// f defines the function graph through the three points
var f = JXG.Math.Numerics.lagrangePolynomial(p);

var plot = board.create('functiongraph', [f, -3, 3]);

var s = board.create('glider', [-2, f(-2), plot], {
    name: 'drag me',
    color: 'black',
    size: 5
});
var int = board.create('integral', [
    [function() {
        return p[0].X();
    }, function() {
        return s.X();
    }], plot
], {
    fillOpacity: 0.2
});

var F = board.create('point', [function() {
    return s.X();
}, function() {
    return JXG.Math.Numerics.I([p[0].X(), s.X()], f);
}], {
    trace: true,
    name: 'F',
    fillColor: '#0000aa',
    strokeColor: '#0000aa',
    face: '[]'
});

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.