| Applying science to business management |
  
integral
Format: integral( f(x), x, x1, x2,
samples )
Arguments: (num) f(x) Function or expression to
be integrated
(node) x Name of the input variable in f(x)
(num) x1 Lower limit
(num) x2 Upper limit
(int) samples Optional minimum number of sample points;
default = 8
Returns: (num) The definite integral of f(x) in
the range x=x1 to x2
Description: Integral is equivalent to the standard
mathematical expression
This primitive approximates the integral of f(x) by
sampling it at various points between x1 and x2. An
adaptive algorithm is used that concentrates samples in areas
where convergence is slowest. This process minimizes the number
of samples needed and allows integral to handle functions
with discontinuities in the range of integration; e.g., a step
function. Integral continues adding samples until the
integral is approximated to the desired level of precision as set
by the precision primitive.
Because it is impossible to know how precise a result is without
knowing the exact solution, integral stops converging when
it is LIKELY that the result is within the desired precision
range.
Either or both limits of integration can be set to infinity
using the infinity primitive;
e.g., integral(Normal(x),x,-infinity,infinity).
In these cases, the function being integrated is assumed to
converging to zero at rate of at least 1/x^2 as x
approaches infinity.
The function being integrated does not have to be defined at
either the lower or upper limit of integration. For example, integral
will properly integrate the function sin(x)/x
in the range 0 to 1 even though sin(0)/0
is not defined. The function must be defined throughout the
interior range of integration.
It is possible in rare cases for integral to miss
important features of a function if the function contains
discontinuities, such as a pulse, or rapid oscillations. If integral
gives you an answer that does not seem reasonable, you can force integral
to use a finer mesh of sample points by providing a value for samples.
Samples should be a power of 2; e.g., 8, 16, 32, 64, ...
This argument determines the minimum number of equally spaced
samples that will be used. It is likely that integral will
generate many more samples in areas of slow convergence.
Note: If the expression f(x) is a tree node
rather than a function based on x, the reset primitive must be used to
cause the tree to recalculate on each iteration. Constants retain
their value from the first evaluation and return this value on
all subsequent evaluations. To cause the constant to be
reevaluated, use an expression similar to
integral({reset,f},x,x1,x2)
rather than
integral(f,x,x1,x2)
Examples: integral(sin(x),x,0,PI)
= 2
f(x):=x^2
integral(f(x),x,0,3) = 9
integral(1/x^2,x,1,infinity) = 1
See Also: derivative,
precision, infinity
|