JSXGraph logo
JSXGraph
JSXGraph share

Share

Convergence of series
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/convergence-of-series" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Convergence of series" 
    allowfullscreen
></iframe>
This code has to
nth-element of the series: <input type="text" id="input" value="1 / 2^n">
Start summation at n = <input type="number" id="startval" value="0" style="width:3em"><br />
<input type="button" value="start" onClick="start_approx()">
<input type="button" value="stop" onClick="clear_all()">


<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, {axis:true, boundingbox: [-3, 8, 50, -8]});
    
    var series = board.create('curve', [[], []], {strokeColor: 'black'});
    var n, a_n;
     
    var series_add = function() {
        var val = a_n(n);
        if (series.dataY.length > 0) {
            val += series.dataY[series.dataY.length - 1];
        }
        series.dataX.push(n);
        series.dataY.push(val);
        n++;
    };
    
    var txt = board.create('text', [15, 1.8, () => 'n=' + (series.dataX.length-1) + ': value = ' + series.dataY[series.dataY.length - 1]], {strokeColor: 'blue'});
    
    var timeoutHandle;
    
    // Animation
    var approx = function() {
         series_add();
         board.update();
         if (series.dataX.length <= 50) {
             timeoutHandle = setTimeout(approx, 500);
         }
    };
    
    // Start animation
    var start_approx = function() {
        series.dataX = [];
        series.dataY = [];
    
        var txtraw = document.getElementById('input').value;
        a_n = board.jc.snippet(txtraw, true, 'n', true);
        n = parseInt(document.getElementById('startval').value);
        approx();
    };
    
    // Stop animation
    var clear_all = function() {
        clearTimeout(timeoutHandle);
    };
    
 </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, {axis:true, boundingbox: [-3, 8, 50, -8]});

var series = board.create('curve', [[], []], {strokeColor: 'black'});
var n, a_n;
 
var series_add = function() {
    var val = a_n(n);
    if (series.dataY.length > 0) {
        val += series.dataY[series.dataY.length - 1];
    }
    series.dataX.push(n);
    series.dataY.push(val);
    n++;
};

var txt = board.create('text', [15, 1.8, () => 'n=' + (series.dataX.length-1) + ': value = ' + series.dataY[series.dataY.length - 1]], {strokeColor: 'blue'});

var timeoutHandle;

// Animation
var approx = function() {
     series_add();
     board.update();
     if (series.dataX.length <= 50) {
         timeoutHandle = setTimeout(approx, 500);
     }
};

// Start animation
var start_approx = function() {
    series.dataX = [];
    series.dataY = [];

    var txtraw = document.getElementById('input').value;
    a_n = board.jc.snippet(txtraw, true, 'n', true);
    n = parseInt(document.getElementById('startval').value);
    approx();
};

// Stop animation
var clear_all = function() {
    clearTimeout(timeoutHandle);
};

Convergence of series

Compute partial sums of the series $\sum_{n=0}^\infty a_n$.
nth-element of the series: Start summation at n =
nth-element of the series: <input type="text" id="input" value="1 / 2^n">
Start summation at n = <input type="number" id="startval" value="0" style="width:3em"><br />
<input type="button" value="start" onClick="start_approx()">
<input type="button" value="stop" onClick="clear_all()">
// Define the id of your board in BOARDID

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

var series = board.create('curve', [[], []], {strokeColor: 'black'});
var n, a_n;
 
var series_add = function() {
    var val = a_n(n);
    if (series.dataY.length > 0) {
        val += series.dataY[series.dataY.length - 1];
    }
    series.dataX.push(n);
    series.dataY.push(val);
    n++;
};

var txt = board.create('text', [15, 1.8, () => 'n=' + (series.dataX.length-1) + ': value = ' + series.dataY[series.dataY.length - 1]], {strokeColor: 'blue'});

var timeoutHandle;

// Animation
var approx = function() {
     series_add();
     board.update();
     if (series.dataX.length <= 50) {
         timeoutHandle = setTimeout(approx, 500);
     }
};

// Start animation
var start_approx = function() {
    series.dataX = [];
    series.dataY = [];

    var txtraw = document.getElementById('input').value;
    a_n = board.jc.snippet(txtraw, true, 'n', true);
    n = parseInt(document.getElementById('startval').value);
    approx();
};

// Stop animation
var clear_all = function() {
    clearTimeout(timeoutHandle);
};

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.