JSXGraph logo
JSXGraph
JSXGraph share

Share

Riemann sum II
QR code
<iframe 
    src="http://jsxgraph.uni-bayreuth.de/share/iframe/riemann-sum-ii" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Riemann sum II" 
    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: [-8, 4, 8, -4], axis: true, keepaspectratio: true });
    var b = board.create('slider', [[1, 3.5], [5, 3.5], [0, 1, 3]], { name: 'a', strokeColor: 'black', fillColor: 'white' });
    var f = function(x) { return b.Value() * Math.sin(x); }
    var plot = board.create('functiongraph', [f, -7, 7], { strokeColor: '#32CD32', strokeWidth: '4px' });
    var g = JXG.Math.Numerics.D(f);
    var plot2 = board.create('functiongraph', [g, -7, 7], { strokeColor: '#9370DB', strokeWidth: '2px' });
    var os = board.create('riemannsum', [f, 35, 'middle', -7, 7], { fillColor: '#B22222', fillOpacity: 0.3,
        strokeColor: '#8B1A1A', strokeWidth: '2px' });
    var t1 = board.create('text', [-7, 2, "(a*sin(x))'"], { strokeColor: '#9370DB' });
    var t2 = board.create('text', [-7, -1.5, "a*sin(x)"], { strokeColor: '#32CD32' });
 </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: [-8, 4, 8, -4], axis: true, keepaspectratio: true });
var b = board.create('slider', [[1, 3.5], [5, 3.5], [0, 1, 3]], { name: 'a', strokeColor: 'black', fillColor: 'white' });
var f = function(x) { return b.Value() * Math.sin(x); }
var plot = board.create('functiongraph', [f, -7, 7], { strokeColor: '#32CD32', strokeWidth: '4px' });
var g = JXG.Math.Numerics.D(f);
var plot2 = board.create('functiongraph', [g, -7, 7], { strokeColor: '#9370DB', strokeWidth: '2px' });
var os = board.create('riemannsum', [f, 35, 'middle', -7, 7], { fillColor: '#B22222', fillOpacity: 0.3,
    strokeColor: '#8B1A1A', strokeWidth: '2px' });
var t1 = board.create('text', [-7, 2, "(a*sin(x))'"], { strokeColor: '#9370DB' });
var t2 = board.create('text', [-7, -1.5, "a*sin(x)"], { strokeColor: '#32CD32' });
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Riemann sum II" 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: [-8, 4, 8, -4], axis: true, keepaspectratio: true });
   var b = board.create('slider', [[1, 3.5], [5, 3.5], [0, 1, 3]], { name: 'a', strokeColor: 'black', fillColor: 'white' });
   var f = function(x) { return b.Value() * Math.sin(x); }
   var plot = board.create('functiongraph', [f, -7, 7], { strokeColor: '#32CD32', strokeWidth: '4px' });
   var g = JXG.Math.Numerics.D(f);
   var plot2 = board.create('functiongraph', [g, -7, 7], { strokeColor: '#9370DB', strokeWidth: '2px' });
   var os = board.create('riemannsum', [f, 35, 'middle', -7, 7], { fillColor: '#B22222', fillOpacity: 0.3,
       strokeColor: '#8B1A1A', strokeWidth: '2px' });
   var t1 = board.create('text', [-7, 2, "(a*sin(x))'"], { strokeColor: '#9370DB' });
   var t2 = board.create('text', [-7, -1.5, "a*sin(x)"], { strokeColor: '#32CD32' });
</jsxgraph>

Riemann sum II

This board shows a sine function with a variable amplitude controlled by a slider. Its derivative is plotted alongside in a different color, and the area under the sine curve is visualized using a Riemann sum, with labels indicating the original function and its derivative. **AI generated desctiption**
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-8, 4, 8, -4], axis: true, keepaspectratio: true });
var b = board.create('slider', [[1, 3.5], [5, 3.5], [0, 1, 3]], { name: 'a', strokeColor: 'black', fillColor: 'white' });
var f = function(x) { return b.Value() * Math.sin(x); }
var plot = board.create('functiongraph', [f, -7, 7], { strokeColor: '#32CD32', strokeWidth: '4px' });
var g = JXG.Math.Numerics.D(f);
var plot2 = board.create('functiongraph', [g, -7, 7], { strokeColor: '#9370DB', strokeWidth: '2px' });
var os = board.create('riemannsum', [f, 35, 'middle', -7, 7], { fillColor: '#B22222', fillOpacity: 0.3,
    strokeColor: '#8B1A1A', strokeWidth: '2px' });
var t1 = board.create('text', [-7, 2, "(a*sin(x))'"], { strokeColor: '#9370DB' });
var t2 = board.create('text', [-7, -1.5, "a*sin(x)"], { strokeColor: '#32CD32' });

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.