Riemann sum II: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
Line 4: Line 4:
var f = function(x){ return b.Value()*Math.sin(x); }
var f = function(x){ return b.Value()*Math.sin(x); }
var plot = brd.create('functiongraph',[f,-7,7], {strokeColor:'#32CD32', strokeWidth:'4px'});
var plot = brd.create('functiongraph',[f,-7,7], {strokeColor:'#32CD32', strokeWidth:'4px'});
var g = brd.D(f);
var g = JXG.Math.Numerics.D(f);
var plot2 = brd.create('functiongraph',[g,-7,7], {strokeColor:'#9370DB', strokeWidth:'2px'});
var plot2 = brd.create('functiongraph',[g,-7,7], {strokeColor:'#9370DB', strokeWidth:'2px'});
var os = brd.create('riemannsum',[f, 35, 'middle', -7, 7], {fillColor:'#B22222', fillOpacity:0.3, strokeColor:'#8B1A1A', strokeWidth:'2px'});
var os = brd.create('riemannsum',[f, 35, 'middle', -7, 7], {fillColor:'#B22222', fillOpacity:0.3, strokeColor:'#8B1A1A', strokeWidth:'2px'});
Line 17: Line 17:
var f = function(x){ return b.Value()*Math.sin(x); }
var f = function(x){ return b.Value()*Math.sin(x); }
var plot = brd.create('functiongraph',[f,-7,7], {strokeColor:'#32CD32', strokeWidth:'4px'});
var plot = brd.create('functiongraph',[f,-7,7], {strokeColor:'#32CD32', strokeWidth:'4px'});
var g = brd.D(f);
var g = JXG.Math.Numerics.D(f);
var plot2 = brd.create('functiongraph',[g,-7,7], {strokeColor:'#9370DB', strokeWidth:'2px'});
var plot2 = brd.create('functiongraph',[g,-7,7], {strokeColor:'#9370DB', strokeWidth:'2px'});
var os = brd.create('riemannsum',[f, 35, 'middle', -7, 7], {fillColor:'#B22222', fillOpacity:0.3, strokeColor:'#8B1A1A', strokeWidth:'2px'});
var os = brd.create('riemannsum',[f, 35, 'middle', -7, 7], {fillColor:'#B22222', fillOpacity:0.3, strokeColor:'#8B1A1A', strokeWidth:'2px'});

Latest revision as of 15:50, 20 February 2013

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('box', {boundingbox: [-8, 4, 8, -4]});
var b = brd.create('slider',[[1,3.5],[5,3.5],[0,1,3]],{name:'a', strokeColor:'black', fillColor:'white'});
var f = function(x){ return b.Value()*Math.sin(x); }
var plot = brd.create('functiongraph',[f,-7,7], {strokeColor:'#32CD32', strokeWidth:'4px'});
var g = JXG.Math.Numerics.D(f);
var plot2 = brd.create('functiongraph',[g,-7,7], {strokeColor:'#9370DB', strokeWidth:'2px'});
var os = brd.create('riemannsum',[f, 35, 'middle', -7, 7], {fillColor:'#B22222', fillOpacity:0.3, strokeColor:'#8B1A1A', strokeWidth:'2px'});
var t1 = brd.create('text',[-7,2,"(a*sin(x))'"],{strokeColor:'#9370DB'});
var t2 = brd.create('text',[-7,-1.5,"a*sin(x)"],{strokeColor:'#32CD32'});