Difference between revisions of "Continuous function II"

From JSXGraph Wiki
Jump to navigationJump to search
(New page: <html> <link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" /> <script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/pro...)
 
 
(34 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
+
<jsxgraph width="600" height="500" box="box">
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
+
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-1, 10, 2, -2], 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>
+
var f = function(x) { return 1.0/x; };
<div id="box" class="jxgbox" style="width:600px; height:500px;"></div>
+
var graph = board.create('functiongraph', [f,0.00001, 15], {strokeColor:'#0000ff'});
<script language="JavaScript">
+
 
  board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 250, unitX: 50, unitY: 50});
+
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();
 
  board.suspendUpdate();
  b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
+
  var y1 = board.create('point', [0,function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'});
  b1axisy = board.createElement('axis', [[0,0], [0,1]], {});
+
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 f = function(x) { return 1.0/x; };
+
  var z1 = board.create('point', [function(){return f(y1.Y());},function(){return y1.Y();}],{size:2,face:'[]',name:' '});
  graph = board.createElement('curve', ['x',f, 'x', 0.00001, 5], {curveType:'graph',strokeColor:'#00ff00'});
+
  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:' '});
  
  s = board.createElement('slider', [0,-2,4,0,1,1],{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});
  
  x1 = board.createElement('glider', [-2,0,b1axisx],{name:'a'});
+
  var h1 = board.create('curve', [function(t){return z1.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
x2 = board.createElement('point', [function(){return x1.X()-s.X();},0],{style:7,name:' '});
+
  var h2 = board.create('curve', [function(t){return z2.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
x3 = board.createElement('point', [function(){return x1.X()+s.X();},0],{style:7,name:' '});
+
  var h3 = board.create('curve', [function(t){return z3.X();},function(t){return t},0,20], {strokeColor:'gray',dash:2,strokeWidth:1});
  y1 = board.createElement('point', [function(){return x1.X();},function(){return f(x1.X());}],{style:7,name:'f(a)'});
 
y2 = board.createElement('point', [function(){return x2.X();},function(){return f(x2.X());}],{style:7,name:' '});
 
  y3 = board.createElement('point', [function(){return x3.X();},function(){return f(x3.X());}],{style:7,name:' '});
 
v1 = board.createElement('line', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1,straightFirst:false,straightLast:false});
 
v2 = board.createElement('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
 
v3 = board.createElement('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});
 
  
  h1 = board.createElement('curve', [function(t){return t},function(t){return y1.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1});
+
  var txt = board.create('text', [1.2, 4.3, function() {  
h2 = board.createElement('curve', [function(t){return t},function(t){return y2.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1});
+
            return '&delta; = ' + Math.min(z1.X() - z3.X(), z2.X() - z1.X()).toFixed(5); }]);
h3 = board.createElement('curve', [function(t){return t},function(t){return y3.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1});
 
 
  board.unsuspendUpdate();
 
  board.unsuspendUpdate();
 
+
</jsxgraph>
</script>
 
</html>
 
  
 
=== References ===
 
=== References ===
  
 
* [http://en.wikipedia.org/wiki/Continuous_function http://en.wikipedia.org/wiki/Continuous_function]
 
* [http://en.wikipedia.org/wiki/Continuous_function http://en.wikipedia.org/wiki/Continuous_function]
 +
 +
=== The underlying JavaScript code ===
 +
 +
<source lang="javascript">
 +
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();
 +
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]
 +
[[Category:Calculus]]

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();