JSXGraph logo
JSXGraph
JSXGraph share

Share

Riemann integrability
QR code
<iframe 
    src="https://jsxgraph.uni-bayreuth.de/share/iframe/riemann-integrability" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Riemann integrability" 
    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: [-3, 5, 3, -3], axis: true });
    var p = [];
    p.push(board.create('point', [-2.7, (Math.random() - 0.2) * 5]));
    p.push(board.create('point', [-1, (Math.random() - 0.2) * 5]));
    p.push(board.create('point', [0, (Math.random() - 0.2) * 5]));
    p.push(board.create('point', [1, (Math.random() - 0.2) * 5]));
    p.push(board.create('point', [2.7, (Math.random() - 0.2) * 5]));
    
    var f = JXG.Math.Numerics.lagrangePolynomial(p);
    var n = board.create('slider', [[-1, 3], [2, 3], [1, 10, 50]], { name: 'n', snapWidth: 1 });
    var plot = board.create('functiongraph', [f, -3, 3]);
    
    var up = board.create('riemannsum', [f, function() { return n.Value(); }, 'upper', -3, 3], { fillColor: '#ff0000',
        fillOpacity: 0.3 });
    var lo = board.create('riemannsum', [f, function() { return n.Value(); }, 'lower', -3, 3], { fillColor: '#ffff00',
        fillOpacity: 0.3 });
    
    board.create('text', [-2, -2, function() { return 'Diff=' + (JXG.Math.Numerics.riemannsum(f, n.Value(), 'upper', -3, 3) -
            JXG.Math.Numerics.riemannsum(f, n.Value(), 'lower', -3, 3)).toFixed(4); }]);
 </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: [-3, 5, 3, -3], axis: true });
var p = [];
p.push(board.create('point', [-2.7, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [-1, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [0, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [1, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [2.7, (Math.random() - 0.2) * 5]));

var f = JXG.Math.Numerics.lagrangePolynomial(p);
var n = board.create('slider', [[-1, 3], [2, 3], [1, 10, 50]], { name: 'n', snapWidth: 1 });
var plot = board.create('functiongraph', [f, -3, 3]);

var up = board.create('riemannsum', [f, function() { return n.Value(); }, 'upper', -3, 3], { fillColor: '#ff0000',
    fillOpacity: 0.3 });
var lo = board.create('riemannsum', [f, function() { return n.Value(); }, 'lower', -3, 3], { fillColor: '#ffff00',
    fillOpacity: 0.3 });

board.create('text', [-2, -2, function() { return 'Diff=' + (JXG.Math.Numerics.riemannsum(f, n.Value(), 'upper', -3, 3) -
        JXG.Math.Numerics.riemannsum(f, n.Value(), 'lower', -3, 3)).toFixed(4); }]);
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Riemann integrability" 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: [-3, 5, 3, -3], axis: true });
   var p = [];
   p.push(board.create('point', [-2.7, (Math.random() - 0.2) * 5]));
   p.push(board.create('point', [-1, (Math.random() - 0.2) * 5]));
   p.push(board.create('point', [0, (Math.random() - 0.2) * 5]));
   p.push(board.create('point', [1, (Math.random() - 0.2) * 5]));
   p.push(board.create('point', [2.7, (Math.random() - 0.2) * 5]));
   
   var f = JXG.Math.Numerics.lagrangePolynomial(p);
   var n = board.create('slider', [[-1, 3], [2, 3], [1, 10, 50]], { name: 'n', snapWidth: 1 });
   var plot = board.create('functiongraph', [f, -3, 3]);
   
   var up = board.create('riemannsum', [f, function() { return n.Value(); }, 'upper', -3, 3], { fillColor: '#ff0000',
       fillOpacity: 0.3 });
   var lo = board.create('riemannsum', [f, function() { return n.Value(); }, 'lower', -3, 3], { fillColor: '#ffff00',
       fillOpacity: 0.3 });
   
   board.create('text', [-2, -2, function() { return 'Diff=' + (JXG.Math.Numerics.riemannsum(f, n.Value(), 'upper', -3, 3) -
           JXG.Math.Numerics.riemannsum(f, n.Value(), 'lower', -3, 3)).toFixed(4); }]);
</jsxgraph>

Riemann integrability

Plots a Lagrange polynomial through 5 random points, shows upper and lower Riemann sums with adjustable rectangles via a slider, and displays the difference between sums in real time. **AI generated desctiption**
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-3, 5, 3, -3], axis: true });
var p = [];
p.push(board.create('point', [-2.7, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [-1, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [0, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [1, (Math.random() - 0.2) * 5]));
p.push(board.create('point', [2.7, (Math.random() - 0.2) * 5]));

var f = JXG.Math.Numerics.lagrangePolynomial(p);
var n = board.create('slider', [[-1, 3], [2, 3], [1, 10, 50]], { name: 'n', snapWidth: 1 });
var plot = board.create('functiongraph', [f, -3, 3]);

var up = board.create('riemannsum', [f, function() { return n.Value(); }, 'upper', -3, 3], { fillColor: '#ff0000',
    fillOpacity: 0.3 });
var lo = board.create('riemannsum', [f, function() { return n.Value(); }, 'lower', -3, 3], { fillColor: '#ffff00',
    fillOpacity: 0.3 });

board.create('text', [-2, -2, function() { return 'Diff=' + (JXG.Math.Numerics.riemannsum(f, n.Value(), 'upper', -3, 3) -
        JXG.Math.Numerics.riemannsum(f, n.Value(), 'lower', -3, 3)).toFixed(4); }]);

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.