student::plotRiemann -- plot
of a numerical approximation to an integral using rectangles
Introductionstudent::plotRiemann(f, x=a..b, n)
computes a numerical approximation to the integral
int(f(x),x=a..b) using rectangles and returns a plot of the
numerical process.
Call(s)student::plotRiemann(f, x=a..b <, n> <,
opt1>...)
student::plotRiemann(f, x=a..b <, n>, method <,
opt1>...)
Parametersf |
- | functional expression in x |
x |
- | identifier |
a, b |
- | arithmetical expressions |
n |
- | a positive integer (number of rectangles) |
method |
- | one of the options Left, Middle, or Right |
opt1 |
- | plot option(s) for two-dimensional graphical objects |
OptionsLeft |
- | The height of each rectangle is determined by the value of the function at the leftpoint of each interval. |
Middle |
- | The height of each rectangle is determined by the value of the function at the middlepoint of each interval (the default method). |
Right |
- | The height of each rectangle is determined by the value of the function at the rightpoint of each interval. |
Returnsa graphical object of the domain type plot::Group.
Related
Functionsplot, plot::Group, student::plotSimpson, student::plotTrapezoid,
student::riemann
Detailsstudent::plotRiemann(f, x=a..b, n)
computes a numerical approximation to the integral
int(f(x),x=a..b) using n rectangles and returns a
graphical object of the numerical process that can be displayed with
the function plot.
The height of each rectangle is determined by the value of the function at the middlepoint of each interval (as with option Middle).
student::plotRiemann(f, x=a..b, n, Left), the height of each rectangle is
determined by the value of the function at the leftpoint of each
interval.
Use option Right, if the rightpoint of each interval should be taken.
n is the number of rectangles to use. The default
value is 4.opt1... must be valid plot options
for two-dimensional graphical objects. See plot2d for details.
Note that scene options are not allowed! You may
give scene options as optional arguments for the function plot, or use plot::Scene to create an object
representing a graphical scene.
f (of the
domain type plot::Function2d). The first two
operands are objects of the domain plot::Group.
Example
1The following call returns a visualization of the numerical approximation to the integral int(e^x,x=-1..1) using 10 rectangles:
>> p := student::plotRiemann(exp(x), x = -1..1, 10)
plot::Group()
>> plot(p)
Example
2You can change plot parameters of the visualization
returned by student::plotRiemann. For example, to change
the color of the filled rectangles to blue, we must set the plot option
Color of the first operand of p to the value
RGB::Blue:
>> (p[1])::Color := RGB::Blue: plot(p, Axes = Box)
Here we changed the style of the axes of the graphical
scene to the value Box.