Usage (signatures)
board.create('riemannsum', [f, n, typeopt, aopt, bopt]);
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
f |
function | Array | Either a function term f(x) describing the function graph which is filled by the Riemann bars, or an array consisting of two functions and the area between is filled by the Riemann bars. |
||
n |
Number | function | Determines the number of bars, it is either a fixed number or a function |
||
type |
String | function |
<optional> |
'left'
|
A string or function returning one of the values: 'left', 'right', 'middle', 'lower', 'upper', 'random', 'simpson', or 'trapezoidal'. Default value is 'left'. "simpson" is Simpson's 1/3 rule. |
a |
Number | function |
<optional> |
Left interval border a of the domain of the Riemann sum |
|
b |
Number | function |
<optional> |
Right interval border a of the domain of the Riemann sum |
Examples
// Create Riemann sums for f(x) = 0.5*x*x-2*x.
var s = board.create('slider',[[0,4],[3,4],[0,4,10]],{snapWidth:1});
var f = (x) => 0.5*x*x-2*x;
var r = board.create('riemannsum',
[f, () => s.Value(), 'upper', -2, 5],
{fillOpacity:0.4}
);
var g = board.create('functiongraph',[f, -2, 5]);
var t = board.create('text',[-2,-2, function(){ return 'Sum=' + JXG.toFixed(r.Value(), 4); }]);
// Riemann sum between two functions
var s = board.create('slider',[[0,4],[3,4],[0,4,10]],{snapWidth:1});
var g = function(x) { return 0.5*x*x-2*x; };
var f = function(x) { return -x*(x-4); };
var r = board.create('riemannsum',
[[g,f], function(){return s.Value();}, 'lower', 0, 4],
{fillOpacity:0.4}
);
var f = board.create('functiongraph',[f, -2, 5]);
var g = board.create('functiongraph',[g, -2, 5]);
var t = board.create('text',[-2,-2, function(){ return 'Sum=' + JXG.toFixed(r.Value(), 4); }]);
Attributes
Own
none
Inherited
Members
Own
none
Inherited
Methods
Own
Value() → {Number}
Returns the value of the Riemann sum, i.e. the sum of the (signed) areas of the rectangles.
Returns
value of Riemann sum.
- Type
- Number
Details
- Source
- base/curve.js, line 2542
Inherited
Events
Own
none