JSXGraph logo
JSXGraph
JSXGraph share

Share

Curve interpolation: Neville's algorithm
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/curve-interpolation-nevilles-algorithm" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Curve interpolation: Neville's algorithm" 
    allowfullscreen
></iframe>
This code has to
<input type="button" value="Add point" onClick="addPoint()">

<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 4 / 3; width: 100%;" data-ar="4 / 3"></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: [-5, 5, 7, -3]});
    
    // Create initial points
    var p = [];
    p[0] = board.create('point', [-1, 2], {size:4});
    p[1] = board.create('point', [3, -1], {size:4});
    p[2] = board.create('point', [2, 1], {size:4});
    
    // Create interpolation curve
    var graph = board.create('curve', JXG.Math.Numerics.Neville(p), {strokeWidth:5, strokeOpacity:0.5});
    
    // Add tangent
    var g = board.create('glider', [graph], {color: 'blue'});
    var t = board.create('tangent', [g], {dash:1, strokeColor:'green'});
    
    // Add point at random position
    var addPoint = function () {
        p.push(board.create('point', [(Math.random() - 0.5) * 10, (Math.random() - 0.5) * 3], {size:4}));
        board.update();
    };
 </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: [-5, 5, 7, -3]});

// Create initial points
var p = [];
p[0] = board.create('point', [-1, 2], {size:4});
p[1] = board.create('point', [3, -1], {size:4});
p[2] = board.create('point', [2, 1], {size:4});

// Create interpolation curve
var graph = board.create('curve', JXG.Math.Numerics.Neville(p), {strokeWidth:5, strokeOpacity:0.5});

// Add tangent
var g = board.create('glider', [graph], {color: 'blue'});
var t = board.create('tangent', [g], {dash:1, strokeColor:'green'});

// Add point at random position
var addPoint = function () {
    p.push(board.create('point', [(Math.random() - 0.5) * 10, (Math.random() - 0.5) * 3], {size:4}));
    board.update();
};

Curve interpolation: Neville's algorithm

<input type="button" value="Add point" onClick="addPoint()">
// Define the id of your board in BOARDID

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

// Create initial points
var p = [];
p[0] = board.create('point', [-1, 2], {size:4});
p[1] = board.create('point', [3, -1], {size:4});
p[2] = board.create('point', [2, 1], {size:4});

// Create interpolation curve
var graph = board.create('curve', JXG.Math.Numerics.Neville(p), {strokeWidth:5, strokeOpacity:0.5});

// Add tangent
var g = board.create('glider', [graph], {color: 'blue'});
var t = board.create('tangent', [g], {dash:1, strokeColor:'green'});

// Add point at random position
var addPoint = function () {
    p.push(board.create('point', [(Math.random() - 0.5) * 10, (Math.random() - 0.5) * 3], {size:4}));
    board.update();
};

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.