Sequences of functions: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 13: | Line 13: | ||
var brd2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox:[-0.25,1.7,1.25,-0.5]}); | var brd2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox:[-0.25,1.7,1.25,-0.5]}); | ||
brd2.suspendUpdate(); | brd2.suspendUpdate(); | ||
var n2 = brd2.create('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:' | var n2 = brd2.create('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:'n',snapWidth:1}); | ||
var f2 = function(x){ return x*x/n2.Value(); } | var f2 = function(x){ return x*x/n2.Value(); } | ||
var plot2 = brd2.create('functiongraph',[ | var plot2 = brd2.create('functiongraph',[f2,0,1], {strokeWidth:2}); | ||
brd2.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>2</sup>/'+n2.Value().toFixed(0);}], | brd2.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>2</sup>/'+n2.Value().toFixed(0);}], | ||
{fontSize:'20px'}); | {fontSize:'20px'}); | ||
Line 25: | Line 25: | ||
<source lang="xml"> | <source lang="xml"> | ||
<jsxgraph width="600" height="400" box="box"> | <jsxgraph width="600" height="400" box="box"> | ||
var brd = JXG.JSXGraph.initBoard('box', {axis:true, | var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox:[-0.25,1.7,1.25,-0.5]}); | ||
var n = brd.create('slider',[[0.1,1.5],[ | brd.suspendUpdate(); | ||
var n = brd.create('slider',[[0.1,1.5],[1.1,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.create('functiongraph',[f,0,1], {strokeWidth:2}); | var plot = brd.create('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>'+Math.floor(n.Value())+'</sup>';}], | ||
{fontSize:'20px'}); | {fontSize:'20px'}); | ||
brd.unsuspendUpdate(); | |||
</jsxgraph> | |||
<jsxgraph width="650" height="400" box="box2"> | |||
var brd2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox:[-0.25,1.7,1.25,-0.5]}); | |||
brd2.suspendUpdate(); | |||
var n2 = brd2.create('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:'n',snapWidth:1}); | |||
var f2 = function(x){ return x*x/n2.Value(); } | |||
var plot2 = brd2.create('functiongraph',[f2,0,1], {strokeWidth:2}); | |||
brd2.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>2</sup>/'+n2.Value().toFixed(0);}], | |||
{fontSize:'20px'}); | |||
brd2.unsuspendUpdate(); | |||
</jsxgraph> | </jsxgraph> | ||
</source> | </source> |
Revision as of 16:15, 27 May 2010
The underlying JavaScript code
<jsxgraph width="600" height="400" box="box">
var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox:[-0.25,1.7,1.25,-0.5]});
brd.suspendUpdate();
var n = brd.create('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:'n',snapWidth:1});
var f = function(x){ return Math.pow(x,n.Value()); }
var plot = brd.create('functiongraph',[f,0,1], {strokeWidth:2});
brd.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>'+Math.floor(n.Value())+'</sup>';}],
{fontSize:'20px'});
brd.unsuspendUpdate();
</jsxgraph>
<jsxgraph width="650" height="400" box="box2">
var brd2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox:[-0.25,1.7,1.25,-0.5]});
brd2.suspendUpdate();
var n2 = brd2.create('slider',[[0.1,1.5],[1.1,1.5],[1,1,100]],{name:'n',snapWidth:1});
var f2 = function(x){ return x*x/n2.Value(); }
var plot2 = brd2.create('functiongraph',[f2,0,1], {strokeWidth:2});
brd2.createElement('text',[0.2,0.7,function(){return 'f(x)=x<sup>2</sup>/'+n2.Value().toFixed(0);}],
{fontSize:'20px'});
brd2.unsuspendUpdate();
</jsxgraph>