Difference between revisions of "Rolle's Theorem"

From JSXGraph Wiki
Jump to navigationJump to search
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
+
<jsxgraph box="box" width="600" height="400">
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
+
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 10, 7, -6], axis: true});
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
 
<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">
 
        board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 50, unitY: 25});
 
 
board.suspendUpdate();
 
board.suspendUpdate();
        // Axes
+
var p = [];
        xax = board.createElement('axis', [[0,0], [1,0]], {});
+
p[0] = board.create('point', [-1,2], {size:3,face:'x',fixed:true});
        yax = board.createElement('axis', [[0,0], [0,1]], {});
+
p[1] = board.create('point', [6,2], {size:3,face:'x',fixed:true});
 +
p[2] = board.create('point', [-0.5,1], {size:2});
 +
p[3] = board.create('point', [2,0.5], {size:2});
 +
var f = JXG.Math.Numerics.lagrangePolynomial(p);
 +
var graph = board.create('functiongraph', [f, -10, 10]);
  
        var p = [];
+
var r = board.create('glider', [function() { return JXG.Math.Numerics.root(JXG.Math.Numerics.D(f),(p[0].X()+p[1].X())*0.5); },
        p[0] = board.createElement('point', [-1,2], {style:1,fixed:true});
+
                                function() { return f(JXG.Math.Numerics.root(JXG.Math.Numerics.D(f),(p[0].X()+p[1].X())*0.5)); },graph],
        p[1] = board.createElement('point', [6,2], {style:1,fixed:true});
+
                                {name:' ',size:4});
        p[2] = board.createElement('point', [-0.5,1], {style:4});
+
var t = board.create('tangent', [r], {strokeColor:'#ff0000'});
        p[3] = board.createElement('point', [2,0.5], {style:4});
+
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});
        var f = function(x) {
+
board.unsuspendUpdate();
                var i;
+
</jsxgraph>
                var y = 0.0;
 
                var xc = [];
 
                for (i=0;i<p.length;i++) {
 
                  xc[i] = p[i].X();
 
                }
 
                for (i=0;i<p.length;i++) {
 
                  var t = p[i].Y();
 
                  for (var k=0;k<p.length;k++) {
 
                    if (k!=i) {
 
                      t *= (x-xc[k])/(xc[i]-xc[k]);
 
                    }
 
                  }
 
                  y += t;
 
                }
 
                return y;
 
            };
 
    var graph = board.createElement('curve', ['x', f, 'x', -10, 10], {curveType:'graph'});
 
  
    var r = board.createElement('point', [function() { return board.root(board.D(f),(p[0].X()+p[1].X())*0.5); },
+
=== The underlying JavaScript code ===
                    function() { return f(board.root(board.D(f),(p[0].X()+p[1].X())*0.5)); }],  
+
<source lang="javascript">
        {name:' ',style:6});
+
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 10, 7, -6], axis: true});
/*
+
board.suspendUpdate();
  var r2 = board.createElement('point', [function(){ return r.X()+0.01;},
+
var p = [];
      function(){ return f(r.X()+0.01);}], {style:7,visible:false});
+
p[0] = board.create('point', [-1,2], {size:3,face:'x',fixed:true});
 +
p[1] = board.create('point', [6,2], {size:3,face:'x',fixed:true});
 +
p[2] = board.create('point', [-0.5,1], {size:2});
 +
p[3] = board.create('point', [2,0.5], {size:2});
 +
var f = JXG.Math.Numerics.lagrangePolynomial(p);
 +
var graph = board.create('functiongraph', [f, -10, 10]);
  
 +
var r = board.create('glider', [function() { return JXG.Math.Numerics.root(JXG.Math.Numerics.D(f),(p[0].X()+p[1].X())*0.5); },
 +
                                function() { return f(JXG.Math.Numerics.root(JXG.Math.Numerics.D(f),(p[0].X()+p[1].X())*0.5)); },graph],
 +
                                {name:' ',size:4});
 +
var t = board.create('tangent', [r], {strokeColor:'#ff0000'});
 +
line = board.create('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});
 +
board.unsuspendUpdate();
 +
</source>
  
line = board.createElement('line',[r,r2],{strokeColor:'#ff0000'});
 
line = board.createElement('line',[p[0],p[1]],{strokeColor:'#ff0000',dash:1});
 
*/
 
 
board.unsuspendUpdate();
 
</script>
 
</html>
 
  
 
[[Category:Examples]]
 
[[Category:Examples]]
 
[[Category:Calculus]]
 
[[Category:Calculus]]

Latest revision as of 17:52, 20 February 2013

The underlying JavaScript code

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

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