student::plotTrapezoid --
plot of a numerical approximation to an integral using the Trapezoidal
rule
Introductionstudent::plotTrapezoid(f, x=a..b, n)
computes a numerical approximation to the integral
int(f(x),x=a..b) using the Trapezoidal rule and returns a
plot of the numerical process.
Call(s)student::plotTrapezoid(f, x=a..b <, n> <,
opt1>...)
Parametersf |
- | functional expression in x |
x |
- | identifier |
a, b |
- | arithmetical expressions |
n |
- | a positive integer (number of trapezoids to use) |
opt1 |
- | plot option(s) for two-dimensional graphical objects |
Returnsa graphical object of the domain type plot::Group.
Related
Functionsplot, plot::Group, student::plotRiemann, student::plotTrapezoid,
student::trapezoid
Detailsstudent::plotTrapezoid(f, x=a..b, n)
computes a numerical approximation to the integral
int(f(x),x=a..b) using the Trapezoidal rule and returns a
graphical object of the numerical process that can be displayed with
the function plot.n is the number of trapezoids 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(cos(x),x=0..PI/2) = 1 using the Trapezoidal rule and 10 trapezoids:
>> p := student::plotTrapezoid(cos(x), x = 0..PI/2, 10)
plot::Group()
To display it on the screen, call:
>> plot(p)
Example
2You can change plot parameters of the visualization
returned by student::plotTrapezoid. For example, to change
the x-range of the graph of f, we set the
attribute range of the last operand of p to
the value x = -PI/2..PI/2:
>> (p[nops(p)])::range := x = -PI/2..PI/2: plot(p)