Riemann integrability: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
No edit summary |
||
(7 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, | var brd = JXG.JSXGraph.initBoard('box', {boundingbox:[-3,5,3,-3],axis:true}); | ||
var p = []; | var p = []; | ||
p.push(brd.create('point',[-2,(Math.random()-0. | p.push(brd.create('point',[-2.7,(Math.random()-0.2)*5])); | ||
p.push(brd.create('point',[-1,(Math.random()-0. | p.push(brd.create('point',[-1,(Math.random()-0.2)*5])); | ||
p.push(brd.create('point',[0,(Math.random()-0. | p.push(brd.create('point',[0,(Math.random()-0.2)*5])); | ||
p.push(brd.create('point',[1,(Math.random()-0. | p.push(brd.create('point',[1,(Math.random()-0.2)*5])); | ||
p.push(brd.create('point',[2,(Math.random()-0. | p.push(brd.create('point',[2.7,(Math.random()-0.2)*5])); | ||
var f = | 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.create('riemannsum',[f,function(){ return n.Value();}, 'upper',-3,3],{fillColor:'#ff0000', fillOpacity:0.3}); | |||
var | 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='+(JXG.Math.Numerics.riemannsum(f,n.Value(),'upper',-3,3)-JXG.Math.Numerics.riemannsum(f,n.Value(),'lower',-3,3)).toFixed(4); }]); | ||
</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',[ | 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); }]);