Riemann integrability: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
<jsxgraph width="800" height="400" box="box">
<jsxgraph width="800" height="400" box="box">
var brd = JXG.JSXGraph.initBoard('box', {boundingbox:[-3,4,3,-4],axis:true});
var brd = JXG.JSXGraph.initBoard('box', {boundingbox:[-3,5,3,-3],axis:true});
var p = [];
var p = [];
p.push(brd.create('point',[-2.7,(Math.random()-0.5)*5]));
p.push(brd.create('point',[-2.7,(Math.random()-0.2)*5]));
p.push(brd.create('point',[-1,(Math.random()-0.5)*5]));
p.push(brd.create('point',[-1,(Math.random()-0.2)*5]));
p.push(brd.create('point',[0,(Math.random()-0.5)*5]));
p.push(brd.create('point',[0,(Math.random()-0.2)*5]));
p.push(brd.create('point',[1,(Math.random()-0.5)*5]));
p.push(brd.create('point',[1,(Math.random()-0.2)*5]));
p.push(brd.create('point',[2.7,(Math.random()-0.5)*5]));
p.push(brd.create('point',[2.7,(Math.random()-0.2)*5]));


var f = brd.lagrangePolynomial(p);
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var n = brd.create('slider',[[-1,3],[2,3],[1,10,50]],{name:'n',snapWidth:1});
var n = brd.create('slider',[[-1,3],[2,3],[1,10,50]],{name:'n',snapWidth:1});
var plot = brd.create('functiongraph',[f,-3,3]);
var plot = brd.create('functiongraph',[f,-3,3]);
   
   
var up = brd.createElement('riemannsum',[f,function(){ return n.Value();}, 'upper',-3,3],{fillColor:'#ff0000', fillOpacity:0.3});
var up = brd.create('riemannsum',[f,function(){ return n.Value();}, 'upper',-3,3],{fillColor:'#ff0000', fillOpacity:0.3});
var lo = brd.createElement('riemannsum',[f,function(){ return n.Value();}, 'lower',-3,3],{fillColor:'#ffff00', fillOpacity:0.3});
var lo = brd.create('riemannsum',[f,function(){ return n.Value();}, 'lower',-3,3],{fillColor:'#ffff00', fillOpacity:0.3});
   
   
/*
brd.create('text',[-2,-2,function(){ return 'Diff='+(JXG.Math.Numerics.riemannsum(f,n.Value(),'upper',-3,3)-JXG.Math.Numerics.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]);
brd.createElement('text',[-6,-3,function(){ return 'Sum='+(brd.riemannsum(f,s.Value(),document.getElementById('sumtype').value,a.Value(),b.Value())).toFixed(4); }]);
brd.create('text',[3,-3,'`sum_(i=0)^n i^2`']);
*/
</jsxgraph>
</jsxgraph>
===The underlying JavaScript code===
<source lang="javascript">
var brd = JXG.JSXGraph.initBoard('box', {boundingbox:[-3,5,3,-3],axis:true});
var p = [];
p.push(brd.create('point',[-2.7,(Math.random()-0.2)*5]));
p.push(brd.create('point',[-1,(Math.random()-0.2)*5]));
p.push(brd.create('point',[0,(Math.random()-0.2)*5]));
p.push(brd.create('point',[1,(Math.random()-0.2)*5]));
p.push(brd.create('point',[2.7,(Math.random()-0.2)*5]));
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var n = brd.create('slider',[[-1,3],[2,3],[1,10,50]],{name:'n',snapWidth:1});
var plot = brd.create('functiongraph',[f,-3,3]);
var up = brd.create('riemannsum',[f,function(){ return n.Value();}, 'upper',-3,3],{fillColor:'#ff0000', fillOpacity:0.3});
var lo = brd.create('riemannsum',[f,function(){ return n.Value();}, 'lower',-3,3],{fillColor:'#ffff00', fillOpacity:0.3});
brd.create('text',[-2,-2,function(){ return 'Diff='+(JXG.Math.Numerics.riemannsum(f,n.Value(),'upper',-3,3)-JXG.Math.Numerics.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]);
</source>


[[Category:Calculus]]
[[Category:Calculus]]
[[Category:Examples]]
[[Category:Examples]]

Latest revision as of 19:09, 18 January 2013

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('box', {boundingbox:[-3,5,3,-3],axis:true});
var p = [];
p.push(brd.create('point',[-2.7,(Math.random()-0.2)*5]));
p.push(brd.create('point',[-1,(Math.random()-0.2)*5]));
p.push(brd.create('point',[0,(Math.random()-0.2)*5]));
p.push(brd.create('point',[1,(Math.random()-0.2)*5]));
p.push(brd.create('point',[2.7,(Math.random()-0.2)*5]));

var f = JXG.Math.Numerics.lagrangePolynomial(p);
var n = brd.create('slider',[[-1,3],[2,3],[1,10,50]],{name:'n',snapWidth:1});
var plot = brd.create('functiongraph',[f,-3,3]);
 
var up = brd.create('riemannsum',[f,function(){ return n.Value();}, 'upper',-3,3],{fillColor:'#ff0000', fillOpacity:0.3});
var lo = brd.create('riemannsum',[f,function(){ return n.Value();}, 'lower',-3,3],{fillColor:'#ffff00', fillOpacity:0.3});
 
brd.create('text',[-2,-2,function(){ return 'Diff='+(JXG.Math.Numerics.riemannsum(f,n.Value(),'upper',-3,3)-JXG.Math.Numerics.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]);