2.13.1.3 Integration

The integ1 X-Function is capable of finding the area under a curve using integration. Both mathematical and absolute areas can be computed. In the following example, the absolute area is calculated:

//Import a sample data
newbook; 
fname$ = system.path.program$ + "Samples\Mathematics\Sine Curve.dat";
impasc;

//Calculate the absolute area of the curve and plot the integral curve
integ1 iy:=col(2) type:=abs plot:=1;

Once the integration is performed, the results can be obtained from the integ1 tree variable:

// Dump the integ1 tree
integ1.=;
// Get a specific value
double area = integ1.area;

The X-Function also allows specifying variable names for quantities of interest, such as:

double myarea, ymax, xmax;
integ1 iy:=col(2) type:=abs plot:=1 area:=myarea y0:=ymax x0:=xmax; 
type "area=$(myarea) %(CRLF)ymax=$(ymax) %(CRLF)xmax=$(xmax)";

Integration of two-dimensional data in a matrix can also be performed using the integ2 X-Function. This X-Function computes the volume beneath the surface defined by the matrix, with respect to the z=0 plane.

// Perform volume integration of 1st matrix object in first matrix sheet
range rmat=[MBook1]1!1;
integ2 im:=rmat integral:=myresult;
type "Volume integration result: $(myresult)";