JSXGraph logo
JSXGraph
JSXGraph share

Share

Convergence of sequence
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/convergence-of-sequence" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Convergence of sequence" 
    allowfullscreen
></iframe>
This code has to
nth-element of the sequence: <input type="text" id="input" value="1 / n">
Start at n = <input type="number" id="startval" value="1" style="width:4em"><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 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';

    const board = JXG.JSXGraph.initBoard(BOARDID, {axis:true, boundingbox: [-3, 8, 50, -8]});
    
    var seq = board.create('curve', [[], []], {strokeColor: 'blue'});
    var n, a_n;
    
     var seq_add = function() {
        var val = a_n(n);
        seq.dataX.push(n);
        seq.dataY.push(val);
        n++;
     };
    
    var txt1 = board.create('text', [15, 1.6, () => 'n=' + (seq.dataX.length-1) + ': value = ' + seq.dataY[seq.dataY.length - 1]], {strokeColor: 'blue'});
    
    var timeoutHandle;
    
    // Approximation animation
    var approx = function() {
         seq_add();
         board.update();
         if (n <= 50) {
             timeoutHandle = setTimeout(approx, 500);
         }
    };
    
    // Start new approximation
    var start_approx = function() {
        // JessieCode function from user input
        var txtraw = document.getElementById('input').value;
        a_n = board.jc.snippet(txtraw, true, 'n', true);
    
        seq.dataX = [];
        seq.dataY = [];
        n = parseInt(document.getElementById('startval').value);
        approx();
    }
    
    // Stop approximation
    var clear_all = function() {
        clearTimeout(timeoutHandle);
    };
    
 </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!

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

var seq = board.create('curve', [[], []], {strokeColor: 'blue'});
var n, a_n;

 var seq_add = function() {
    var val = a_n(n);
    seq.dataX.push(n);
    seq.dataY.push(val);
    n++;
 };

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

var timeoutHandle;

// Approximation animation
var approx = function() {
     seq_add();
     board.update();
     if (n <= 50) {
         timeoutHandle = setTimeout(approx, 500);
     }
};

// Start new approximation
var start_approx = function() {
    // JessieCode function from user input
    var txtraw = document.getElementById('input').value;
    a_n = board.jc.snippet(txtraw, true, 'n', true);

    seq.dataX = [];
    seq.dataY = [];
    n = parseInt(document.getElementById('startval').value);
    approx();
}

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

Convergence of sequence

Compute values of the sequence $(a_n)_{n\in{\mathbb N}}$.
nth-element of the sequence: Start at n =
nth-element of the sequence: <input type="text" id="input" value="1 / n">
Start at n = <input type="number" id="startval" value="1" style="width:4em"><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 seq = board.create('curve', [[], []], {strokeColor: 'blue'});
var n, a_n;

 var seq_add = function() {
    var val = a_n(n);
    seq.dataX.push(n);
    seq.dataY.push(val);
    n++;
 };

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

var timeoutHandle;

// Approximation animation
var approx = function() {
     seq_add();
     board.update();
     if (n <= 50) {
         timeoutHandle = setTimeout(approx, 500);
     }
};

// Start new approximation
var start_approx = function() {
    // JessieCode function from user input
    var txtraw = document.getElementById('input').value;
    a_n = board.jc.snippet(txtraw, true, 'n', true);

    seq.dataX = [];
    seq.dataY = [];
    n = parseInt(document.getElementById('startval').value);
    approx();
}

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

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.