Extended mean value theorem

From JSXGraph Wiki
Revision as of 16:10, 29 January 2019 by A WASSERMANN (talk | contribs)

The underlying JavaScript code

var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 10, 7, -6], axis:true});
var p = [];

p[0] = board.create('point', [-2,-2], {size:2});
p[1] = board.create('point', [-1.5, 5], {size:2});
p[2] = board.create('point', [1,4], {size:2});
p[3] = board.create('point', [3,-1], {size:2});

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

// Secant 
line = board.create('line', [p[0], p[3]], {strokeColor:'#ff0000', dash:1});

var df = JXG.Math.Numerics.D(fg[0]);
var dg = JXG.Math.Numerics.D(fg[1]);

// Usually, the extended mean value theorem is formulated as
// df(t) / dg(t) == (p[3].X() - p[0].X()) / (p[3].Y() - p[0].Y())
// We can avoid division by zero with that formulation:
var quot = function(t) {
    return df(t) * (p[3].Y() - p[0].Y()) - dg(t) * (p[3].X() - p[0].X());
};

var r = board.create('glider', [
            function() { return fg[0](JXG.Math.Numerics.root(quot, (fg[3]() + fg[2]) * 0.5)); },
            function() { return fg[1](JXG.Math.Numerics.root(quot, (fg[3]() + fg[2]) * 0.5)); },
            graph], {name: '', size: 4, fixed:true, color: 'blue'});

board.create('tangent', [r], {strokeColor:'#ff0000'});