Sequences of functions: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 1: Line 1:
<jsxgraph width="650" height="400" box="box">
<jsxgraph width="650" height="400" box="box">
var brd = JXG.JSXGraph.initBoard('box', {axis:true, originX: 100, originY: 340, unitX: 400, unitY: 200});
var brd = JXG.JSXGraph.initBoard('box', {axis:true, originX: 100, originY: 340, unitX: 400, unitY: 200});
var n = brd.createElement('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:'n'});
var n = brd.createElement('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:'n',snapWidth:1});
var f = function(x){ return Math.pow(x,Math.floor(n.Value())); }
var f = function(x){ return Math.pow(x,n.Value()); }
var plot = brd.createElement('functiongraph',[f,0,1], {strokeWidth:2});
var plot = brd.createElement('functiongraph',[f,0,1], {strokeWidth:2});
brd.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>'+Math.floor(n.Value())+'</sup>';}],
brd.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>'+n.Value()+'</sup>';}],
   {fontSize:'20px'});
   {fontSize:'20px'});
</jsxgraph>
</jsxgraph>
Line 12: Line 12:
<jsxgraph width="600" height="400" box="box">
<jsxgraph width="600" height="400" box="box">
var brd = JXG.JSXGraph.initBoard('box', {axis:true, originX: 100, originY: 340, unitX: 400, unitY: 200});
var brd = JXG.JSXGraph.initBoard('box', {axis:true, originX: 100, originY: 340, unitX: 400, unitY: 200});
var n = brd.createElement('slider',[[0.1,1.5],[0.9,1.5],[1,1,100]],{name:'n'});
var n = brd.createElement('slider',[[0.1,1.5],[0.9,1.5],[1,1,100]],{name:'n',snapWidth:1});
var f = function(x){ return Math.pow(x,n.Value()); }
var f = function(x){ return Math.pow(x,n.Value()); }
var plot = brd.createElement('functiongraph',[f,0,1], {strokeWidth:2});
var plot = brd.createElement('functiongraph',[f,0,1], {strokeWidth:2});
brd.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>'+Math.floor(n.Value())+'</sup>';}],
brd.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>'+n.Value()+'</sup>';}],
   {fontSize:'20px'});
   {fontSize:'20px'});
</jsxgraph>
</jsxgraph>

Revision as of 17:16, 22 June 2009

The underlying JavaScript code

<jsxgraph width="600" height="400" box="box">
var brd = JXG.JSXGraph.initBoard('box', {axis:true, originX: 100, originY: 340, unitX: 400, unitY: 200});
var n = brd.createElement('slider',[[0.1,1.5],[0.9,1.5],[1,1,100]],{name:'n',snapWidth:1});
var f = function(x){ return Math.pow(x,n.Value()); }
var plot = brd.createElement('functiongraph',[f,0,1], {strokeWidth:2});
brd.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>'+n.Value()+'</sup>';}],
  {fontSize:'20px'});
</jsxgraph>