>  Docs Center  >  IDL Reference  >  Advanced Math and Stats  >  IMSL_INTFCN: Functions Containing a Sine or Cosine Factor

IMSL_INTFCN: Functions Containing a Sine or Cosine Factor

IMSL_INTFCN: Functions Containing a Sine or Cosine Factor

This version of the IMSL_INTFCN function integrates functions containing a sine or a cosine factor. To use this integration method, supply the Omega argument and one of the following keywords: SINE, or COSINE.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

This method is a special-purpose integrator that uses a globally adaptive scheme to reduce the absolute error. It computes integrals whose integrands have the special form w (x) f (x), where w (x) is either cos (wx) or sin (wx). Depending on the length of the subinterval in relation to the size of w, either a modified Clenshaw-Curtis procedure or a Gauss-Kronrod 7/15 rule is employed to approximate the integral on a subinterval. This method is based on the subroutine QAWO by Piessens et al. (1983).

If this method is used, the function should be coded to protect endpoint singularities if they exist.


The value of:

is computed. The exact answer is:

; Define the function to be integrated.
  RETURN, x^2
ans = IMSL_INTFCN('f', 0, 1, 3 * !Pi, /Sine)
; Call IMSL_INTFCN with Sine set and value for method
; parameter omega.
PM, 'Computed Answer:', ans

IDL prints:

Computed Answer:
exact = ((3 * !Pi)^2 - 2)/((3 * !pi)^3) - 2/(3 * !Pi)^3
PM, 'Exact - Computed:', exact - ans

IDL prints:

Exact - Computed:




Result = IMSL_INTFCN(F, A, B, Omega, /SINE | /COSINE [, MAX_MOMENTS=value])

Return Value

An estimate of the desired integral. If no value can be computed, the floating-point value NaN (Not a Number) is returned.



A scalar string specifying the name of a user-supplied function to be integrated. The function f accepts one scalar parameter and returns a single scalar of the same type.


A scalar expression specifying the lower limit of integration.


A scalar expression specifying the upper limit of integration.


A scalar expression specifying the frequency of the trigonometric weighting function.


In addition to the global IMSL_INTFCN keywords, the following keywords are available:

SINE (optional)

Set this keyword to use sin (ωx) for the integration weight function. If SINE is supplied, COSINE must not be present.

COSINE (optional)

Set this keyword to use cos (ωx) for the integration weight function. IF COSINE is supplied, SINE must not be present.

MAX_MOMENTS (optional)

Set this keyword equal to a scalar expression specifying an upper bound on the number of Chebyshev moments that can be stored. Increasing (decreasing) this number may increase (decrease) execution speed and space used. The default is 21.

Version History



See Also


© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us