Next: D110 Gaussian Quadrature Up: CERNLIB Previous: D107 N-Point Gaussian

D108 Trapezoidal Rule Integration with an Estimated Error

Routine ID: D108
Author(s): K.S. KölbigLibrary: MATHLIB
Submitter: Submitted: 01.03.1968
Language: FortranRevised:

Let a function $f\left(x\right)$ be given by its values at certain discrete points $x$ν(ν=1,2,...,n) . Let the function values $y$ν be accompanied by an estimated standard deviation $\epsilon$ν (square root of the variance). Subroutine subprogram TRAPER then approximates the integral

$I = \int$ABf(x)dx ∑νwνyν

by a linear combination of the $y$ν using the trapezoidal rule. It calculates the standard deviation $\sigma$ of I by

$\sigma =\sum$νwν2εν2.

The function values $f\left(A\right)$ and $f\left(B\right)$ are calculated by linear interpolation.

Structure:

SUBROUTINE subprogram
User Entry Names: TRAPER

Usage:

```    CALL TRAPER(X,Y,E,N,A,B,RE,SD)
```
X,Y,E
( REAL) Arrays of length $\ge n$ containing $x$ν,yνν , respectively.
N
( INTEGER) Number of function values
A,B
( REAL) Limits of integration.
RE
( REAL) On exit, RE contains an approximate value of the integral I.
SD
( REAL) On exit, SD contains an approximate value of the standard deviation $\sigma$ .
If no $\epsilon$ν are given, the array E should be filled with zeros.

Restrictions:

Although there are no restrictions on A and B ( B may be less than A), care must be taken if one or both of them is either smaller than X(1) or bigger than X(N). In these cases $f\left(A\right)$ or $f\left(B\right)$ are extrapolated linearly from Y(1) and Y(2) or Y(N-1) and Y(N) respectively, which may lead to unreasonable results. If $A = B$ or $N < 2$ , RE and SD will be set to zero. It is assumed that all the $x$ν are distinct. No test is made for this.

Notes:

This program should only be used for the problem described above. For general-purpose numerical integration to a preassigned accuracy use GAUSS (D103).
$•$

Next: D110 Gaussian Quadrature Up: CERNLIB Previous: D107 N-Point Gaussian

Janne Saarela
Mon Apr 3 15:06:23 METDST 1995