Numerical approximation of an integral
This functionality does not run in MATLAB.
plot::Integral(f
, <n
>, <IntMethod = m
>, <a = a_{min} .. a_{max}
>, options
)
plot::Integral(f, IntMethod = m)
visualizes
the approximation of the integral of the function f
using
the numerical quadrature method m
.
Riemann sums, the trapezoidal rule, and the Simpson rule are available.
plot::Integral(f, n, IntMethod = m)
uses n
subintervals to approximate the integral.
The attribute IntMethod
determines the numerical method.
Riemann sums, the trapezoidal rule, or the Simpson rule are available.
See the help page of IntMethod
for further details. Cf. Example 1.
plot::Integral
does not plot the function
graph of the integrand. If the integrand is to be plotted, too, f
has
to be passed to the plot
command
together with the approximation object of type plot::Integral
.
If no quadrature method is specified by IntMethod = m
, plot::Integral
just hatches the area between the function f
and
the xaxis.
Several plot::Integral
objects can be plotted
together to illustrate the difference between various quadrature methods.
The order of the objects in the plot
command determines the object in
front.
The plot contains a text object providing information about
the quadrature method, the value of the approximation, the exact value
of the integral, the quadrature error, and the number of nodes. See
the help page of the attribute ShowInfo
for further details.
Attribute  Purpose  Default Value 

AffectViewingBox  influence of objects on the ViewingBox of
a scene  TRUE 
AntiAliased  antialiased lines and points?  TRUE 
Color  the main color  RGB::PaleBlue 
Filled  filled or transparent areas and surfaces  TRUE 
FillColor  color of areas and surfaces  RGB::PaleBlue 
FillPattern  type of area filling  Solid 
Frames  the number of frames in an animation  50 
Function1  first function/curve delimiting hatch  
HorizontalAlignment  horizontal alignment of text objects w.r.t. their coordinates  Left 
IntMethod  method for integral approximation  Exact 
Legend  makes a legend entry  
LegendText  short explanatory text for legend  
LegendEntry  add this object to the legend?  FALSE 
LineColor  color of lines  RGB::Black 
LineWidth  width of lines  0.35 
LineColor2  color of lines  RGB::Grey 
LineStyle  solid, dashed or dotted lines?  Solid 
LinesVisible  visibility of lines  TRUE 
LineColorType  line coloring types  Flat 
LineColorFunction  functional line coloring  
Name  the name of a plot object (for browser and legend)  
Nodes  number of subintervals or list of xvalues for subintervals  [10 ] 
ParameterEnd  end value of the animation parameter  
ParameterName  name of the animation parameter  
ParameterBegin  initial value of the animation parameter  
ParameterRange  range of the animation parameter  
PointSize  the size of points  1.5 
PointStyle  the presentation style of points  FilledCircles 
PointsVisible  visibility of mesh points  FALSE 
ShowInfo  Information about integral approximation  [2 , IntMethod , Integral ] 
TextFont  font of text objects  [" sansserif " , 11 ] 
TextRotation  rotation of a 2D text  0 
TimeEnd  end time of the animation  10.0 
TimeBegin  start time of the animation  0.0 
TimeRange  the real time span of an animation  0.0 .. 10.0 
Title  object title  
TitleFont  font of object titles  [" sansserif " , 11 ] 
TitlePosition  position of object titles  
TitleAlignment  horizontal alignment of titles w.r.t. their coordinates  Center 
TitlePositionX  position of object titles, x component  
TitlePositionY  position of object titles, y component  
VerticalAlignment  vertical alignment of text objects w.r.t. their coordinates  Bottom 
Visible  visibility  TRUE 
VisibleAfter  object visible after this time value  
VisibleBefore  object visible until this time value  
VisibleFromTo  object visible during this time range  
VisibleAfterEnd  object visible after its animation time ended?  TRUE 
VisibleBeforeBegin  object visible before its animation time starts?  TRUE 
If a single plot::Function2d
object is given without
specifying an approximation method, plot::Integral
just
hatches the area between the function graph and the xaxis:
f := plot::Function2d(cos(x), x = PI..PI): plot(plot::Integral(f), f)
Note that plot::Integral
requires an object of
type plot::Function2d
, not just a function
expression:
plot::Integral(sin(x))
Error: The first argument must be a 'plot::Function2d' object. [plot::Integral::new]
If an approximation method is specified, the numerical quadrature value computed by this method is displayed:
plot(plot::Integral(f, IntMethod = RiemannLower))
The number of quadrature intervals can be set by passing a second
argument n
or by specifying Nodes = n
:
plot(plot::Integral(f, 20, IntMethod = RiemannLower))
To see the integrand in the plot, the function object must be passed together with the approximation object. The order determines which object is in front:
plot(plot::Integral(f, IntMethod = RiemannLower), f)
delete f:
The displayed information can be configured by the user:
f := plot::Function2d(x^2, x = 5..5, Color = RGB::DarkGrey): plot(plot::Integral(f, IntMethod = RiemannLower, ShowInfo = [1, IntMethod = "Riemann lower sum", Integral = "Exact value", 2, Error = "Difference"]), f)
delete f:
One may combine several approximation objects, e.g., lower and upper sum:
f := plot::Function2d(x^2, x = 5..5): plot(plot::Integral(f, IntMethod = RiemannUpper, Color = RGB::Blue), plot::Integral(f, IntMethod = RiemannLower, Color = RGB::LightYellow), f)
The automatically placed information texts overlap. To correct
this, the option ShowInfo
must be used. In the text of
the upper sum, one additional empty line is inserted. Apart from this,
both objects use the default value, therefore there is not need to
specify ShowInfo
in the second object:
plot(plot::Integral(f, IntMethod = RiemannUpper, ShowInfo = [IntMethod, "", Integral]), plot::Integral(f, IntMethod = RiemannLower, Color = RGB::LightYellow), f)
The info text can be positioned explicitly:
plot(plot::Integral(f, IntMethod = RiemannUpper, ShowInfo = [IntMethod, Integral, Position = [5, 1]], VerticalAlignment = Top), plot::Integral(f, IntMethod = RiemannLower, Color = RGB::Yellow, ShowInfo = [IntMethod, Position = [0, 1]], VerticalAlignment = Top), f)
delete f:
plot::Integral
can be animated:
f := plot::Function2d(sin(a*x), x = 0..PI, a = 1..5): plot(plot::Integral(f, 50, IntMethod = RiemannMiddle), f)
Increasing the number of nodes decreases the quadrature error:
f := plot::Function2d(sin(x), x = 0..PI): plot(plot::Integral(f, N, N = 10..50, IntMethod = RiemannLower), f)
The function and the number of nodes can be animated simultaneously:
f := plot::Function2d(sin(a*x), x = 0..PI, a = 1..5): plot(plot::Integral(f, N, N = 10..50, IntMethod = RiemannLower), f)
delete f:

The integrand: an object of type


The number of subintervals (a positive integer) or a list of real numbers representing nodes of the integration variable.


Animation parameter, specified as 

Option, specified as The quadrature method; see 