Riemann integrability: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 9: | Line 9: | ||
var f = brd.lagrangePolynomial(p); | var f = brd.lagrangePolynomial(p); | ||
var n = brd.create('slider',[[-1,3],[2,3],[1,10, | 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. | 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); }]); | ||
</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 = brd.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='+(brd.riemannsum(f,n.Value(),'upper',-3,3)-brd.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]); | |||
</source> | |||
[[Category:Calculus]] | [[Category:Calculus]] | ||
[[Category:Examples]] | [[Category:Examples]] |
Revision as of 12:47, 11 May 2010
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 = brd.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='+(brd.riemannsum(f,n.Value(),'upper',-3,3)-brd.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]);