Difference between revisions of "Mean Value Theorem"

From JSXGraph Wiki
Jump to: navigation, search
Line 4: Line 4:
 
<div id="box" class="jxgbox" style="width:600px; height:400px;"></div>
 
<div id="box" class="jxgbox" style="width:600px; height:400px;"></div>
 
<script language="JavaScript">
 
<script language="JavaScript">
        board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25});
+
var board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25, axis:true});
 
board.suspendUpdate();
 
board.suspendUpdate();
        // Axes
+
var p = [];
        xax = board.createElement('axis', [[0,0], [1,0]], {});
+
p[0] = board.create('point', [-1,-2], {style:4});
        yax = board.createElement('axis', [[0,0], [0,1]], {});
+
p[1] = board.create('point', [6,5], {style:4});
 +
p[2] = board.create('point', [-0.5,1], {style:4});
 +
p[3] = board.create('point', [3,3], {style:4});
 +
var f = board.lagrangePolynomial(p);
 +
var graph = board.create('functiongraph', [f,-10, 10]);
  
        var p = [];
+
var g = function(x) {
        p[0] = board.createElement('point', [-1,-2], {style:4});
+
    return board.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
        p[1] = board.createElement('point', [6,5], {style:4});
+
};
        p[2] = board.createElement('point', [-0.5,1], {style:4});
 
        p[3] = board.createElement('point', [3,3], {style:4});
 
        var f = board.lagrangePolynomial(p);
 
        var graph = board.createElement('functiongraph', [f,-10, 10]);
 
  
        var g = function(x) {
+
var r = board.create('glider', [
            return board.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
 
        }
 
 
 
var r = board.createElement('glider', [
 
 
                     function() { return board.root(g,(p[0].X()+p[1].X())*0.5); },
 
                     function() { return board.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(board.root(g,(p[0].X()+p[1].X())*0.5)); },
 
                     graph], {name:' ',style:6,fixed:true});
 
                     graph], {name:' ',style:6,fixed:true});
board.createElement('tangent', [r], {strokeColor:'#ff0000'});
+
board.create('tangent', [r], {strokeColor:'#ff0000'});
line = board.createElement('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();
Line 35: Line 31:
 
===The underlying JavaScript code===
 
===The underlying JavaScript code===
 
<source lang="javascript">
 
<source lang="javascript">
        board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25});
+
var board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25, axis:true});
 
board.suspendUpdate();
 
board.suspendUpdate();
        // Axes
+
var p = [];
        xax = board.createElement('axis', [[0,0], [1,0]], {});
+
p[0] = board.create('point', [-1,-2], {style:4});
        yax = board.createElement('axis', [[0,0], [0,1]], {});
+
p[1] = board.create('point', [6,5], {style:4});
 
+
p[2] = board.create('point', [-0.5,1], {style:4});
        var p = [];
+
p[3] = board.create('point', [3,3], {style:4});
        p[0] = board.createElement('point', [-1,-2], {style:4});
+
var f = board.lagrangePolynomial(p);
        p[1] = board.createElement('point', [6,5], {style:4});
+
var graph = board.create('functiongraph', [f,-10, 10]);
        p[2] = board.createElement('point', [-0.5,1], {style:4});
 
        p[3] = board.createElement('point', [3,3], {style:4});
 
        var f = board.lagrangePolynomial(p);
 
        var graph = board.createElement('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 board.D(f)(x)-(p[1].Y()-p[0].Y())/(p[1].X()-p[0].X());
        }
+
};
  
var r = board.createElement('glider', [
+
var r = board.create('glider', [
 
                     function() { return board.root(g,(p[0].X()+p[1].X())*0.5); },
 
                     function() { return board.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(board.root(g,(p[0].X()+p[1].X())*0.5)); },
 
                     graph], {name:' ',style:6,fixed:true});
 
                     graph], {name:' ',style:6,fixed:true});
board.createElement('tangent', [r], {strokeColor:'#ff0000'});
+
board.create('tangent', [r], {strokeColor:'#ff0000'});
line = board.createElement('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();

Revision as of 11:24, 27 January 2010

The underlying JavaScript code

var board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25, axis:true});
board.suspendUpdate();
var p = [];
p[0] = board.create('point', [-1,-2], {style:4});
p[1] = board.create('point', [6,5], {style:4});
p[2] = board.create('point', [-0.5,1], {style:4});
p[3] = board.create('point', [3,3], {style:4});
var f = board.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f,-10, 10]);

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

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

board.unsuspendUpdate();