# Integrate

Advanced Analysis Library Only

AnalysisLibErrType Integrate (double inputArray[], int numberOfElements, double samplingInterval, double initialCondition, double finalCondition, double outputArray[]);

## Purpose

Calculates the discrete integral of the input array Simpson's Rule for discrete evaluation. Integrate obtains the element of the resulting array using the following formula:

where | X–1 is the initial condition
| Xn is the final condition
| i is the array index
| n is the number of elements
| dt is the sampling interval

The values are accumulated into the output array. Thus, the last element of the array contains the area under the curve.

Integrate can perform the operation in place; that is, the input and output arrays can be the same.

### Example

/* Generate an array with random numbers and integrate it. */
double x[200], y[200];
double dt, xInit, xFinal;
int n;
n = 200;
dt = 0.001;
xInit = -0.5;
xFinal = -0.25;
Uniform (n, 17, x);
Integrate (x, n, dt, xInit, xFinal, y);

## Parameters

Input
Name | Type | Description
inputArray | double-precision array | Input array to integrate.
numberOfElements | integer | Number of elements used to compute the integral value of the input array.
samplingInterval | double-precision | Sampling interval used in the integration. Default Value: 1.0.
initialCondition | double-precision | Initial condition. When the integration formula is applied to each array element, the value of the preceding array element is used. initialCondition specifies the value preceding the first element of the input array. In other words, initialCondition can be thought of as the value of X–1. Default Value: 0.0.
finalCondition | double-precision | Final condition. When the integration formula is applied to each array element, the value of the next array element is used. finalCondition specifies the value following the last element of the input array. In other words, finalCondition can be thought of as the value of Xn. Default Value: 0.0.
Output
Name | Type | Description
outputArray | double-precision array | Integrated array.

## Return Value

Name | Type | Description
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.