Mean Value Theorem: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
<jsxgraph width="600" height="400" box="box">
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 10, 7, -6], axis:true});
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<div id="box" class="jxgbox" style="width:600px; height:400px;"></div>
<script language="JavaScript">
var board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25, axis:true});
board.suspendUpdate();
board.suspendUpdate();
var p = [];
var p = [];
p[0] = board.create('point', [-1,-2], {style:4});
p[0] = board.create('point', [-1,-2], {size:2});
p[1] = board.create('point', [6,5], {style:4});
p[1] = board.create('point', [6,5], {size:2});
p[2] = board.create('point', [-0.5,1], {style:4});
p[2] = board.create('point', [-0.5,1], {size:2});
p[3] = board.create('point', [3,3], {style:4});
p[3] = board.create('point', [3,3], {size:2});
var f = board.lagrangePolynomial(p);
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f,-10, 10]);
var graph = board.create('functiongraph', [f,-10, 10]);


var g = function(x) {
var g = function(x) {
     return board.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
     return JXG.Math.Numerics.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
};
};


var r = board.create('glider', [
var r = board.create('glider', [
                     function() { return board.root(g,(p[0].X()+p[1].X())*0.5); },
                     function() { return JXG.Math.Numerics.root(g,(p[0].X()+p[1].X())*0.5); },
                     function() { return f(board.root(g,(p[0].X()+p[1].X())*0.5)); },
                     function() { return f(JXG.Math.Numerics.root(g,(p[0].X()+p[1].X())*0.5)); },
                     graph], {name:' ',style:6,fixed:true});
                     graph], {name:' ',size:4,fixed:true});
board.create('tangent', [r], {strokeColor:'#ff0000'});
board.create('tangent', [r], {strokeColor:'#ff0000'});
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});


board.unsuspendUpdate();
board.unsuspendUpdate();
</script>
</jsxgraph>
</html>


===The underlying JavaScript code===
===The underlying JavaScript code===
<source lang="javascript">
<source lang="javascript">
var board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25, axis:true});
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 10, 7, -6], axis:true});
board.suspendUpdate();
board.suspendUpdate();
var p = [];
var p = [];
p[0] = board.create('point', [-1,-2], {style:4});
p[0] = board.create('point', [-1,-2], {size:2});
p[1] = board.create('point', [6,5], {style:4});
p[1] = board.create('point', [6,5], {size:2});
p[2] = board.create('point', [-0.5,1], {style:4});
p[2] = board.create('point', [-0.5,1], {size:2});
p[3] = board.create('point', [3,3], {style:4});
p[3] = board.create('point', [3,3], {size:2});
var f = board.lagrangePolynomial(p);
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f,-10, 10]);
var graph = board.create('functiongraph', [f,-10, 10]);


var g = function(x) {
var g = function(x) {
     return board.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
     return JXG.Math.Numerics.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
};
};


var r = board.create('glider', [
var r = board.create('glider', [
                     function() { return board.root(g,(p[0].X()+p[1].X())*0.5); },
                     function() { return JXG.Math.Numerics.root(g,(p[0].X()+p[1].X())*0.5); },
                     function() { return f(board.root(g,(p[0].X()+p[1].X())*0.5)); },
                     function() { return f(JXG.Math.Numerics.root(g,(p[0].X()+p[1].X())*0.5)); },
                     graph], {name:' ',style:6,fixed:true});
                     graph], {name:' ',size:4,fixed:true});
board.create('tangent', [r], {strokeColor:'#ff0000'});
board.create('tangent', [r], {strokeColor:'#ff0000'});
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});

Latest revision as of 15:29, 20 February 2013

The underlying JavaScript code

var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 10, 7, -6], axis:true});
board.suspendUpdate();
var p = [];
p[0] = board.create('point', [-1,-2], {size:2});
p[1] = board.create('point', [6,5], {size:2});
p[2] = board.create('point', [-0.5,1], {size:2});
p[3] = board.create('point', [3,3], {size:2});
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f,-10, 10]);

var g = function(x) {
     return JXG.Math.Numerics.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
};

var r = board.create('glider', [
                    function() { return JXG.Math.Numerics.root(g,(p[0].X()+p[1].X())*0.5); },
                    function() { return f(JXG.Math.Numerics.root(g,(p[0].X()+p[1].X())*0.5)); },
                    graph], {name:' ',size:4,fixed:true});
board.create('tangent', [r], {strokeColor:'#ff0000'});
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});

board.unsuspendUpdate();