INTEGRAL Function
The INTEGRAL function is used to evaluate an integral and in the solution of differential equations. There are two basic forms of the integral function that differ in the reliance on the Parametric Table.
Table-based Integral function
The table-based Integral function uses the Parametric Table to provide the limits and step size of the integration variable. The format of this function is INTEGRAL(Integrand, VarName). The function returns the integral of the expression represented by Integrand with respect to the variable VarName, i.e., +∫ (Integrand) d(VarName). This form of the Integral function can be used only in conjunction with the Parametric Table. VarName must be a legal variable name that has values defined in one of the columns of the table. Integrand can be a variable or any implicit or explicit algebraic expression involving variables, values, and the integration variable, VarName.
Equation-based Integral function
The equation-based integral function serves the same purpose as the table-based integral function but it does not require the use of the Parametric Table. The format for the equation-based integral function is
F = INTEGRAL(Integrand, VarName, LowerLimit, UpperLimit, StepSize)
or
F = INTEGRAL(Integrand, VarName, LowerLimit, UpperLimit) {automatic step size}
Integrand can be any EES variable or expression for which the integral is desired. The expression may involve VarName and it may be an implicit function. Note that EES uses numerical integration to arrive at an estimate of the integral. EES cannot reliably integrate expressions for which the integrand may be infinite or undefined during the integration process, such as 1/X when X=0.
VarName is the integration variable.
LowerLimit and UpperLimit are the lower and upper limits of the integration variable. These limits may be specified with a constant or with an EES expression. However, the limits cannot be a function of VarName or any other variable that changes during the course of the integration.
StepSize is the increment EES will use for the integration variable while numerically evaluating the integral between the specified limits. StepSize can be a constant or a variable whose value varies during the course of the integration. Note that specification of StepSize is optional. If StepSize is not provided or if StepSize is set to 0, EES will select the step size using an automatic step size adjustment algorithm with parameters set in the Integration tab of the Tolerances dialog. Note that Richardson extrapolation can be employed if a fixed step size is provided in the function call or if the "Use fixed step size" button is selected in the Integration tab of the Preferences dialog. The automatic step size parameters can also be specified with the $IntegralAutoStep directive.
EES uses a second-order predictor-corrector algorithm for evaluating the integral. This algorithm is designed for solving combined algebraic differential equations that result when the integrand is an implicit function of other variables. The algorithm is especially suited to stiff equations.
EES uses the INTEGRAL function to solve initial value differential equations. Any first-order differential equation can be transformed into an appropriate form by integrating both sides. For example, the differential equation dy/dx = f(x,y) can be equivalently written as
y=y0 +∫ f(x,y) dx
where y0 is the initial value of y. This equation can be solved using either the table-based or equation-based form of the INTEGRAL function. The table-based form would be entered into the EES Equations Window as
y = y0 + INTEGRAL(fxy, x)
where fxy is an EES variable or expression. To solve the equation it is necessary to create a Parametric Table containing a column for variable x. Values of x are entered into the Parametric Table with the value in first row corresponding to the lower limit of x and the value in the last row corresponding to the upper limit. The step size is determined by the difference between the value of x in successive rows and need not be a fixed value. The integral is evaluated when the Solve Table command is applied.
The equation-based form would appear in the EES Equations window as
y = y0 + INTEGRAL(fxy, x, low, high)
y0 and fxy are as defined above. Low and high are the lower and upper limits for x. Since the step size is not specified, EES will use automatic step size selection. The parameters that control the step size selection are set in the Tolerances dialog. Note that the integral limits, low and high, can be EES variables, but their values can not be undetermined or vary with the integration variable. It is possible to solve problems that determine the lower or upper limit of the integral as described in the example, Finding a Limit of Integration.
Higher order differential equations can also be solved by additional integration. Shown below is an EES program that solved a second-order differential equation using the equation-based form of the INTEGRAL function. A $IntegralTable directive is used to automatically generate an Integral Table holding intermediate values of specified integrated quantities.
"This example illustrates how EES can solve a differential equation using a small integration
step size while reporting integrated values at larger specified intervals using the $IntegralTable
directive.
This process is illustrated by solving the following 2nd order differential equation:
y``+y`-2y=4x with y`(0)=0 and y(0)=1 for x between 0 and 1.
The $IntegralTable directive automatically constructs a table of values for x, y, y`, and y`` at x
increments of 0.1. Automatic step size is used in the integration. The net result is that small
increments of x may are used to evaluate the integral, but values are only reported in the
Integral table for x increments of 0.1.
"
y``=4*x+2*y-y`
y`=y`_i+integral(y``,x,0,x_f)
y=y_i+integral(y`,x,0,x_f)
y_i=1
y`_i=0
x_f=1
$IntegralAutoStep Vary=1 Min=50 Max=2000 Reduce=1e-3 Increase=1e-5
$Integraltable x:0.1, y, y`, y``
(Note: use a semicolon instead of a comma as the list separator when using the European numerical format).
Integral function calls can be nested to provide multiple-variable integration.
Chapter 7 of Mastering EES provides more detailed information relating to the use of the integral function.
See also: $IntegralTable