Contents | Previous | Next | Subchapters |

Syntax |
`gaussq(function ` fvec`, ` a`, ` b`, ` bound`)` |

See Also | trapz , gaussq2d , gaussleg , quadint |

Returns a fifth-order (three point) Gaussian quadrature approximation for the integral of

*f*(*x*)

over the interval `[`*a*, *b*]

.
The return value is a scalar with the same type as *fvec*(*xvec*)

returns the column vector

*T*

[*f*(*xvec*(1)), *f*(*xvec*(2)), ... , *f*(*xvec*(*n*))]

with the same type as *n*

is the dimension of the column vector

The following example integrates the cosine function between 0 and

*pi*/2

.
The integration interval is broken into sub-intervals
each of which is at most 1 unit long and a fifth-order (three point)
Gaussian quadrature approximation is used on each sub-interval.
A special version of the cosine function is defined because
O-Matrix intrinsic functions cannot be passed as arguments.
```
```

function cosine(x) begin

return cos(x)

end

a = 0.

b = pi / 2

bound = 1.

gaussq(function cosine, a, b, bound)

returns
```
```

1

The exact integral is the difference in the sine function
between 0 and *pi*/2

which is 1.