ShowInfo

Information about integral approximation

Value Summary

OptionalList of arithmetical expressions

Graphics Primitives

ObjectsShowInfo Default Values
plot::Integral[2, IntMethod, Integral]

Description

ShowInfo defines the text information displayed by plot::Integral.

In plot::Integral, text information about the used approximation method, the values of the approximation and the exact integral, the number of subintervals and the error of the approximation can be displayed within the approximation object.

The attribute is specified by ShowInfo = [entry1, entry2, …] with a list of various entries. The user may specify the entries in arbitrary order.

If the list is empty, no text information is displayed.

Each entry in the list can be of one of the following types:

  • an arbitrary string

    In the text, this entry is appended to the current line. No white space or line break is prepended or appended. The string itself, however, may contain white space or a line break (given by \n).

  • "" (empty string)

    This inserts an empty line in the text.

  • IntMethod

    In the text, this creates a new line

    name: float_value,

    where name is the value of the attribute IntMethod and float_value is the numerical value of the integral approximation. This value is computed internally and inserted in the text, automatically.

  • IntMethod = name

    In the text, this creates a new line

    name: float_value,

    where float_value is the numerical value of the integral approximation.

    If name is one of the flags RiemannLower etc. listed on the help page of the attribute IntMethod, this flag is displayed in the text.

    Alternatively, name may be a string. When name is the empty string "", only the numerical approximation of the integral value is displayed.

  • Integral

    In the text, this creates a new line

    Integral: float_value,

    where float_value is a high precision float approximation of the exact integral value.

  • Integral = string

    In the text, this creates a new line

    string: float_value,

    where string is an arbitrary text string and float_value is a high precision float approximation of the exact integral value .

    When string is the empty string "", only the high precision approximation float_value is displayed.

  • Error

    In the text, this creates a new line

    Error: float_value,

    where float_value is the absolute difference between the numerical value obtained by the chosen approximation method and a high precision float approximation of the exact integral value.

  • Error = string

    In the text, this creates a new line

    string: float_value,

    where string is an arbitrary text string and float_value is the absolute difference between the numerical value obtained by the chosen approximation method and a high precision float approximation of the exact integral value.

    When string is the empty string "", only the absolute quadrature error float_value is displayed.

  • Nodes

    In the text, this creates a new line

    Nodes: n,

    where the integer n is the number of intervals used for the integral approximation.

  • Nodes = string

    In the text, this creates a new line

    string: n,

    where string is an arbitrary text string and the integer n is the number of intervals used for the integral approximation.

    When string is the empty string "", only the integer n is displayed.

  • Position = [X, Y]

    This entry determines the position of the text information. X and Y are the coordinates of the anchor point of the text. The alignment of the text with respect to the anchor point can be chosen by the attributes HorizontalAlignment and VerticalAlignment.

  • a positive integer digits

    The integer digits determines the number of digits after the decimal point for all following float values.

    Different float values can be displayed with a different number of digits by inserting several digits entries at appropriate positions in the list.

Without an explicit specification of Position = [X, Y], the text is positioned automatically.

Examples

Example 1

By default, the approximation method, the value of approximation and the integral is displayed with 2 digits after the decimal point:

f := plot::Function2d(x^2, x = -5..5, Color = RGB::DarkGrey):
plot(plot::Integral(f, IntMethod = RiemannLower), f)

This call is equivalent to:

plot(plot::Integral(f, IntMethod = RiemannLower,
                  ShowInfo = [2, IntMethod, Integral]), f):

The text can be changed:

plot(plot::Integral(f, IntMethod = RiemannLower,
       ShowInfo = [IntMethod = "value of the lower Riemann sum",
                   Integral = "exact numerical value",
                   Error = "difference"]), f)

delete f:

Example 2

The position can be specified explicitely. In this case, the entries to be displayed must be specified explicitely, too. The text attribute VerticalAlignment aligns the text object:

f := plot::Function2d(x^2, x = -5..5, Color = RGB::DarkGrey):
plot(plot::Integral(f, IntMethod = RiemannUpper, Color = RGB::Lime,
                       ShowInfo = [IntMethod, Integral,
                                   Position = [-5, -1]],
                       VerticalAlignment = Top),
     plot::Integral(f, IntMethod = RiemannLower, Color = RGB::Gold,
                       ShowInfo = [IntMethod,
                                   Position = [0, -1]],
                       VerticalAlignment = Top),
     f)

delete f:

Example 3

The number of digits after the decimal point can be specified for each value. In the following example all values are displayed with four digits:

f := plot::Function2d(x^2*(x-4)*(x+2), x = -3..5,
                      Color = RGB::Black):
plot(plot::Integral(f, 4, IntMethod = Simpson, 
                    LineColor = RGB::Red,
                    ShowInfo = [4, IntMethod, Integral, Error]),
     f)

Only the error shall be displayed with four digits after the decimal point. All other values are shown with only one digit:

plot(plot::Integral(f, 4, IntMethod = Simpson, LineColor = RGB::Red,
                    ShowInfo = [1, IntMethod, Integral, 4, Error]),
     f)

delete f:

Example 4

Two approximation objects shall be displayed in one plot. To prevent collision of the automatically positioned texts, we insert an empty line into the text of one of the objects to prevent collision of the automatically positioned texts:

f := plot::Function2d(x^2, x = -5..5, Color = RGB::DarkGrey):
plot(plot::Integral(f, IntMethod = RiemannUpper, Color = RGB::Rose,
                       ShowInfo = [IntMethod, "", Integral]),
     plot::Integral(f, IntMethod = RiemannLower,
                       ShowInfo = [IntMethod, Integral]),
     f)

Alternatively, the position can be given explicitly:

f := plot::Function2d(x^2, x = -5..5, Color = RGB::DarkGrey):
plot(plot::Integral(f, IntMethod = RiemannUpper, Color = RGB::Lime,
                       ShowInfo = [IntMethod, Integral,
                                   Position = [-5, -1]],
                       VerticalAlignment = Top),
     plot::Integral(f, IntMethod = RiemannLower, Color = RGB::Gold,
                       ShowInfo = [IntMethod,
                                   Position = [0, -1]],
                       VerticalAlignment = Top),
     f)

delete f:

Example 5

The text may contain additional messages:

f := plot::Function2d(x^2, x = -5..5):
plot(plot::Integral(f, IntMethod = RiemannUpper, 
        ShowInfo = ["Approximation value:", IntMethod = "",
                    "\nUsed rectangles:", Nodes = ""],
        Color = RGB::Rose),
     f)

delete f:
Was this topic helpful?