[AIT logo]

Institut für Astronomie und Astrophysik

Abteilung Astronomie

Sand 1, D-72076 Tübingen, Germany
New Address!   --   Neue Adresse!
[Uni logo]


QSIMP Source code in qsimp.pro

QSIMP

Name
       QSIMP
Purpose
       Integrate using Simpson's rule to specified accuracy.
Explanation
       Integrate a function to specified accuracy using the extended
       trapezoidal rule.   Adapted from algorithm in Numerical Recipes,
       by Press et al. (1992, 2nd edition), Section 4.2.     This procedure
       has been partly obsolete since IDL V3.5 with the introduction of the
       intrinsic function QSIMP(), but see notes below.
Calling Sequence
       QSIMP, func, A, B, S, [ EPS = , MAX_ITER =, _EXTRA =  ]
Input Parameters
       func - scalar string giving name of function of one variable to
               be integrated
       A,B  - numeric scalars giving the lower and upper bound of the
               integration
Output Parameters
       S - Scalar giving the approximation to the integral of the specified
               function between A and B.
Keyword Parameters
       EPS - scalar specifying the fractional accuracy before ending the
               iteration.  Default = 1E-6
       MAX_ITER - Integer specifying the total number iterations at which
               QSIMP will terminate even if the specified accuracy has not yet
               been met.   The maximum number of function evaluations will be
               2^(MAX_ITER).    Default value is MAX_ITER = 20
       Any other keywords are passed directly to the user-supplied function
       via the _EXTRA facility.
Note
       (1) The function QTRAP is robust way of doing integrals that are not
       very smooth.  However, if the function has a continuous 3rd derivative
       then QSIMP will likely be more efficient at performing the integral.
       (2) QSIMP can be *much* faster than the intrinsic QSIMP() function (as
       of IDL V5.3).   This is because the intrinsic QSIMP() function only
       requires that the user supplied function accept a *scalar* variable.
       Thus on the the 16th iteration, the intrinsic QSIMP() makes 32,767
       calls to the user function, whereas this procedure makes one call
       with a  32,767 element vector.  Also, unlike the intrinsic QSIMP(), this
       procedure allows keywords in the user-supplied function.
       (3) Since the intrinsic QSIMP() is a function, and this file contains a
       procedure, there should be no name conflict.
Example
       Compute the integral of sin(x) from 0 to !PI/3.
       IDL> QSIMP, 'sin', 0, !PI/3, S   & print, S
       The value obtained should be cos(!PI/3) = 0.5
Procedures Used
       TRAPZD, ZPARCHECK
Revision History
       W. Landsman         ST Systems Co.         August, 1991
       Continue after max iter warning message   W. Landsman   March, 1996
       Converted to IDL V5.0   W. Landsman   September 1997
       Pass keyword to function via _EXTRA facility  W. Landsman July 1999

Last modified by pro2html on 2002 April 27 at 03:41 UTC

[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]

Jörn Wilms (wilms@astro.uni-tuebingen.de)
Updated automatically