student::plotSimpson
-- plot
of a numerical approximation to an integral using Simpson's rulestudent::plotSimpson
(f, x=a..b, n)
computes a numerical approximation to the integral
int(f(x),x=a..b) using Simpson's rule and returns a plot of
the numerical process.
student::plotSimpson(f, x=a..b <, n> <,
opt1>...)
f |
- | functional expression in x |
x |
- | identifier |
a, b |
- | arithmetical expressions |
n |
- | a positive integer (number of stripes to use) |
opt1 |
- | plot option(s) for two-dimensional graphical objects |
a graphical object of the domain type plot::Group
.
plot
, plot::Group
, student::plotRiemann
, student::plotTrapezoid
,
student::simpson
student::plotSimpson
(f, x=a..b, n)
computes a numerical approximation to the integral
int(f(x),x=a..b) using Simpson's rule and returns a
graphical object of the numerical process that can be displayed with
the function plot
.n
is the number of stripes 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.
n+1
operands: the
n stripes as well as the function graph of f
(of the domain type plot::Function2d
). Every stripe is
an object of the domain type plot::Group
.The following call returns a visualization of the numerical approximation to the integral int(sin(x),x=0..1) using Simpson's rule and 10 stripes:
>> p := student::plotSimpson(sin(x), x = 0..1, 10)
plot::Group()
To display it on the screen, call:
>> plot(p)
You can change plot parameters of the visualization
returned by student::plotSimpson
. For example, to change
the color of every second filled stripe to red, we must set the plot
option Color
of the operands of p
with even
index to the value RGB::Blue
:
>> ((p[2*i])::Color := RGB::Red) $ i = 1..nops(p) div 2: plot(p)