Difference between revisions of "Riemann sum III"

From JSXGraph Wiki
Jump to navigationJump to search
Line 1: Line 1:
 +
Appromximate the integral of
 
<math>f: R\to R, x\mapsto x^2 </math>
 
<math>f: R\to R, x\mapsto x^2 </math>
 
<html>
 
<html>
Line 12: Line 13:
 
<jsxgraph width="800" height="400" box="box">
 
<jsxgraph width="800" height="400" box="box">
 
var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox:[-2,40,8,-5]});
 
var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox:[-2,40,8,-5]});
var s = brd.create('slider',[[1,30],[5,30],[1,50,500]],{name:'n',snapWidth:1});
+
var s = brd.create('slider',[[-1,30],[5,30],[3,50,500]],{name:'n',snapWidth:1});
var a = brd.create('slider',[[1,20],[5,20],[-10,0,0]],{name:'start'});
+
var a = brd.create('slider',[[-1,20],[3,20],[-10,0,0]],{name:'start'});
var b = brd.create('slider',[[1,10],[5,10],[0,6,10]],{name:'end'});
+
var b = brd.create('slider',[[-1,10],[3,10],[0,6,10]],{name:'end'});
 
var f = function(x){ return x*x; };
 
var f = function(x){ return x*x; };
 
var plot = brd.create('functiongraph',[f,function(){return a.Value();}, function(){return b.Value();}]);
 
var plot = brd.create('functiongraph',[f,function(){return a.Value();}, function(){return b.Value();}]);
Line 24: Line 25:
 
     ],  
 
     ],  
 
     {fillColor:'#ffff00', fillOpacity:0.3});
 
     {fillColor:'#ffff00', fillOpacity:0.3});
/*
+
 
 
brd.createElement('text',[-6,-4,function(){ return 'Sum='+(brd.riemannsum(f,s.Value(),document.getElementById('sumtype').value,a.Value(),b.Value())).toFixed(4); }]);
 
brd.createElement('text',[-6,-4,function(){ return 'Sum='+(brd.riemannsum(f,s.Value(),document.getElementById('sumtype').value,a.Value(),b.Value())).toFixed(4); }]);
*/
+
 
 
</jsxgraph>
 
</jsxgraph>
  

Revision as of 17:25, 2 February 2010

Appromximate the integral of [math]f: R\to R, x\mapsto x^2 [/math]

Riemann sum type:

The underlying JavaScript code

<jsxgraph width="800" height="400" box="box">
</jsxgraph>