Difference between revisions of "Continuous function II"

From JSXGraph Wiki
Jump to navigationJump to search
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<jsxgraph width="600" height="500" box="box">
 
<jsxgraph width="600" height="500" box="box">
  board = JXG.JSXGraph.initBoard('box', {originX: 50, originY: 400, unitX: 50, unitY: 50});
+
  var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-1, 10, 2, -2], axis: true});
b1axisx = board.create('axis', [[0,0], [1,0]], {});
 
b1axisy = board.create('axis', [[0,0], [0,1]], {});
 
  
 
  var f = function(x) { return 1.0/x; };
 
  var f = function(x) { return 1.0/x; };
  graph = board.create('functiongraph', [f,0.00001, 15], {strokeColor:'#00ff00'});
+
  var graph = board.create('functiongraph', [f,0.00001, 15], {strokeColor:'#0000ff'});
  
  s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'&epsilon;'});
+
  var s = board.create('slider', [[0,-1],[1.5,-1],[0,1,1]],{name:'&epsilon;'});
  
  y1 = board.create('glider', [0,3,b1axisy],{name:'f(a)'});
+
  var x1 = board.create('glider', [1/2, 0, board.defaultAxes.x],{name:'a'});
 
  board.suspendUpdate();
 
  board.suspendUpdate();
  y2 = board.create('point', [0,function(){return y1.Y()-s.Value();}],{style:7,name:' '});
+
  var y1 = board.create('point', [0,function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'});
  y3 = board.create('point', [0,function(){return y1.Y()+s.Value();}],{style:7,name:' '});
+
var y2 = board.create('point', [0,function(){return f(x1.X())-s.Value();}],{size:2,face:'[]',name:' '});
 +
  var y3 = board.create('point', [0,function(){return f(x1.X())+s.Value();}],{size:2,face:'[]',name:' '});
  
  z1 = board.create('point', [function(){return f(y1.Y());},function(){return y1.Y();}],{style:7,name:'f(a)'});
+
  var z1 = board.create('point', [function(){return f(y1.Y());},function(){return y1.Y();}],{size:2,face:'[]',name:' '});
  z2 = board.create('point', [function(){return f(y2.Y());},function(){return y2.Y();}],{style:7,name:' '});
+
  var z2 = board.create('point', [function(){return f(y2.Y());},function(){return y2.Y();}],{size:2,face:'[]',name:' '});
  z3 = board.create('point', [function(){return f(y3.Y());},function(){return y3.Y();}],{style:7,name:' '});
+
  var z3 = board.create('point', [function(){return f(y3.Y());},function(){return y3.Y();}],{size:2,face:'[]',name:' '});
  
  v1 = board.create('line', [z1,y1],{strokeColor:'gray',dash:2,strokeWidth:1,straightFirst:false,straightLast:false});
+
  var v1 = board.create('segment', [z1,y1],{strokeColor:'gray',dash:2,strokeWidth:1});
  v2 = board.create('line', [z2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
+
  var v2 = board.create('line', [z2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
  v3 = board.create('line', [z3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});
+
  var v3 = board.create('line', [z3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});
  
  h1 = board.create('curve', [function(t){return z1.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
+
  var h1 = board.create('curve', [function(t){return z1.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
  h2 = board.create('curve', [function(t){return z2.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
+
  var h2 = board.create('curve', [function(t){return z2.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
  h3 = board.create('curve', [function(t){return z3.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
+
  var h3 = board.create('curve', [function(t){return z3.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
 +
 
 +
var txt = board.create('text', [1.2, 4.3, function() {
 +
            return '&delta; = ' + Math.min(z1.X() - z3.X(), z2.X() - z1.X()).toFixed(5); }]);
 
  board.unsuspendUpdate();
 
  board.unsuspendUpdate();
 
</jsxgraph>
 
</jsxgraph>
Line 35: Line 37:
  
 
<source lang="javascript">
 
<source lang="javascript">
  board = JXG.JSXGraph.initBoard('box', {originX: 50, originY: 400, unitX: 50, unitY: 50});
+
  var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-1, 10, 2, -2], axis: true});
board.suspendUpdate();
 
b1axisx = board.create('axis', [[0,0], [1,0]], {});
 
b1axisy = board.create('axis', [[0,0], [0,1]], {});
 
  
 
  var f = function(x) { return 1.0/x; };
 
  var f = function(x) { return 1.0/x; };
  graph = board.create('functiongraph', [f,0.00001, 15], {strokeColor:'#00ff00'});
+
  var graph = board.create('functiongraph', [f,0.00001, 15], {strokeColor:'#0000ff'});
 +
 
 +
var s = board.create('slider', [[0,-1],[1.5,-1],[0,1,1]],{name:'&epsilon;'});
  
  s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'&epsilon;'});
+
  var x1 = board.create('glider', [1/2, 0, board.defaultAxes.x],{name:'a'});
 +
board.suspendUpdate();
 +
var y1 = board.create('point', [0,function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'});
 +
var y2 = board.create('point', [0,function(){return f(x1.X())-s.Value();}],{size:2,face:'[]',name:' '});
 +
var y3 = board.create('point', [0,function(){return f(x1.X())+s.Value();}],{size:2,face:'[]',name:' '});
  
  y1 = board.create('glider', [0,3,b1axisy],{name:'f(a)'});
+
  var z1 = board.create('point', [function(){return f(y1.Y());},function(){return y1.Y();}],{size:2,face:'[]',name:' '});
  y2 = board.create('point', [0,function(){return y1.Y()-s.Value();}],{style:7,name:' '});
+
  var z2 = board.create('point', [function(){return f(y2.Y());},function(){return y2.Y();}],{size:2,face:'[]',name:' '});
  y3 = board.create('point', [0,function(){return y1.Y()+s.Value();}],{style:7,name:' '});
+
  var z3 = board.create('point', [function(){return f(y3.Y());},function(){return y3.Y();}],{size:2,face:'[]',name:' '});
  
  z1 = board.create('point', [function(){return f(y1.Y());},function(){return y1.Y();}],{style:7,name:'f(a)'});
+
  var v1 = board.create('segment', [z1,y1],{strokeColor:'gray',dash:2,strokeWidth:1});
  z2 = board.create('point', [function(){return f(y2.Y());},function(){return y2.Y();}],{style:7,name:' '});
+
  var v2 = board.create('line', [z2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
  z3 = board.create('point', [function(){return f(y3.Y());},function(){return y3.Y();}],{style:7,name:' '});
+
  var v3 = board.create('line', [z3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});
  
  v1 = board.create('line', [z1,y1],{strokeColor:'gray',dash:2,strokeWidth:1,straightFirst:false,straightLast:false});
+
  var h1 = board.create('curve', [function(t){return z1.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
  v2 = board.create('line', [z2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
+
  var h2 = board.create('curve', [function(t){return z2.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
  v3 = board.create('line', [z3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});
+
  var h3 = board.create('curve', [function(t){return z3.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
  
  h1 = board.create('curve', [function(t){return z1.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
+
  var txt = board.create('text', [1.2, 4.3, function() {  
h2 = board.create('curve', [function(t){return z2.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
+
            return '&delta; = ' + Math.min(z1.X() - z3.X(), z2.X() - z1.X()).toFixed(5); }]);
h3 = board.create('curve', [function(t){return z3.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
 
 
  board.unsuspendUpdate();
 
  board.unsuspendUpdate();
 
</source>
 
</source>

Latest revision as of 20:23, 7 January 2019

References

The underlying JavaScript code

 var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-1, 10, 2, -2], axis: true});

 var f = function(x) { return 1.0/x; };
 var graph = board.create('functiongraph', [f,0.00001, 15], {strokeColor:'#0000ff'});

 var s = board.create('slider', [[0,-1],[1.5,-1],[0,1,1]],{name:'&epsilon;'});

 var x1 = board.create('glider', [1/2, 0, board.defaultAxes.x],{name:'a'});
 board.suspendUpdate();
 var y1 = board.create('point', [0,function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'});
 var y2 = board.create('point', [0,function(){return f(x1.X())-s.Value();}],{size:2,face:'[]',name:' '});
 var y3 = board.create('point', [0,function(){return f(x1.X())+s.Value();}],{size:2,face:'[]',name:' '});

 var z1 = board.create('point', [function(){return f(y1.Y());},function(){return y1.Y();}],{size:2,face:'[]',name:' '});
 var z2 = board.create('point', [function(){return f(y2.Y());},function(){return y2.Y();}],{size:2,face:'[]',name:' '});
 var z3 = board.create('point', [function(){return f(y3.Y());},function(){return y3.Y();}],{size:2,face:'[]',name:' '});

 var v1 = board.create('segment', [z1,y1],{strokeColor:'gray',dash:2,strokeWidth:1});
 var v2 = board.create('line', [z2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
 var v3 = board.create('line', [z3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});

 var h1 = board.create('curve', [function(t){return z1.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
 var h2 = board.create('curve', [function(t){return z2.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
 var h3 = board.create('curve', [function(t){return z3.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});

 var txt = board.create('text', [1.2, 4.3, function() { 
            return '&delta; = ' + Math.min(z1.X() - z3.X(), z2.X() - z1.X()).toFixed(5); }]);
 board.unsuspendUpdate();