Difference between revisions of "Riemann integrability"

From JSXGraph Wiki
Jump to: navigation, search
 
Line 8: Line 8:
 
p.push(brd.create('point',[2.7,(Math.random()-0.2)*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]);
Line 15: Line 15:
 
var lo = brd.create('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='+(brd.riemannsum(f,n.Value(),'upper',-3,3)-brd.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]);
+
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); }]);
 
</jsxgraph>
 
</jsxgraph>
  
Line 28: Line 28:
 
p.push(brd.create('point',[2.7,(Math.random()-0.2)*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]);
Line 35: Line 35:
 
var lo = brd.create('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='+(brd.riemannsum(f,n.Value(),'upper',-3,3)-brd.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]);
+
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>
 
</source>
  
 
[[Category:Calculus]]
 
[[Category:Calculus]]
 
[[Category:Examples]]
 
[[Category:Examples]]

Latest revision as of 21: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); }]);