X
4336

Using Double Integration in IDL

Calling the QROMB, QROMO, and QSIMP routines within the user-supplied function of these same routines allows the user to calculate double and triple integrals. This Help Article contains an example demonstrating double integration.

Each term of an integrand (the equation within the integral) can contain another integration method. The double and triple integrations are performed over each term of the integrand. The following example uses double integration to calculate the area of a surface over a specified region.

Integrating Over a Surface (Double Integration): this example calculates the area of the surface defined by

area_equation1.jpg

over the region defined by 0 <= x <= 1 and 0 <= y <= 1. The solution can be found by evaluating the double integral

area_equation.jpg

Note that the correct solution to this integral is 3.

This example program is made up of four routines: the main routine, the integration in the y direction, the second integration of the x term, and the second integration of the x^2 term. The main routine is the last routine in the program. The file containing this program should be named the same as the main routine (integratingOverASurface.pro).

Code Example:

FUNCTION xSquaredTerm, x

; Integration of the x squared term.
secondIntegration = 9.*x^2
RETURN, secondIntegration

END

FUNCTION xTerm, x

; Integration of the linear x term.
secondIntegration = x
RETURN, secondIntegration

END

FUNCTION yDirection, y

; Re-write equation to consider both x terms.
firstIntegration = QROMB('xSquaredTerm', 0., 1.)*y^2 $
+ 4.*(QROMB('xTerm', 0., 1.))*y + 1.
RETURN, firstIntegration

END

PRO integratingOverASurface

; Determine the area of the surface represented
; by 9x^2y^2 + 4xy + 1.
area = QROMB('yDirection', 0., 1. )

; Output results.
PRINT, 'Resulting area: ', area

END
_________________________________________
Reviewed by BC on 09/05/2014