Integration

Syntax: | `vout = INTEGRAL(x,y) voud = INTEGRAL(x,y,'SMOOTH') voud = INTEGRAL(x,y,'TRAPEZOID')`

The `INTEGRAL` function integrates the vector `y`, the dependent variable, with respect to vector `x`, the independent variable. The output of this function is a vector with the same length as `x`. The last element of the output vector is the integral over the full range of `x`. Currently, integration using interpolating splines, using no keyword or the keyword `SMOOTH`, or the trapezoid rule, using keyword `TRAPEZOID`, are the only types available.

Interpolating splines

Syntax: | `vout = INTEGRAL(x,y) voud = INTEGRAL(x,y,'SMOOTH')`

This integration method utilizes an interpolating spline under tension. The spline tension used is the current value of `TENSION`, which may be changed with the `SET TENSION` command. The nature of the interpolating curve varies continuously from pure cubic splines, for `TENSION = 0`, to a piecewise linear curve, that is, points joined by straight line segments, for large `TENSION`.

`x` must be strictly monotonically increasing.

Example

The following code produces the picture below (except for the text which was added interactively).

     clear
     defaults
     !
     pi=acos(-1)
     generate x 0,,2*pi 100
     y = cos(x)^3+sin(x)^3
     graph x y
     !
     set linecolor red
     graph/overlay x integral(x,y)
     set linecolor black
     replot

Trapezoid rule

Syntax: `vout = INTEGRAL(x,y,'TRAPEZOID')`

This integration method uses the trapezoid rule.