Contents Previous Next Subchapters

Two Dimensional Gaussian Quadrature Integration
Syntax gaussq2d(function fveclimx, function limy)
See Also quad2d , gaussq , gaussleg

Description
Returns a fifth-order Gaussian quadrature approximation for
      x2     y1(x)
     /      / 
     |  dx  |    f(xydy
     /      /
      x1     y1(x)

as a scalar with the same type as limx. The real or double-precision vector limx has three elements: the first is the lower limit for integration in the x direction (x1); the second is the upper limit (x2); and the third is a bound for the size of quadrature intervals in the x direction.

limy(x)
Returns a three-element vector with the same type as limx: the first is the lower limit for integration in the y direction [y1(x)]; the second is the upper limit [y2(x)]; and the third is a bound for the size of quadrature intervals in the y direction.

fvec(xyvec)
Returns the column vector
                                                        T
     [f(xyvec(1)), f(xyvec(2)), ... , f(xyvec(n))]

with the same type as limx, where the scalar x has the same type as limx and yvec is a column vector of length n with the same type as limx.

The third element or limx and of limy(x) control the accuracy and amount of work by determining how many quadrature intervals are necessary.

Example
The following program prints an approximation for the integral
      1    1            1       2  1         1
     /    /            /       y  |      1  /          1
     | dx | x y dy  =  | dx x --- |   =  -  | x dx  =  - 
     /    /            /       2  |      2  /          4
      0    0            0          0         0


clear
#
function fvec(x, yvec) begin
     return x % yvec
end
function limy(x) begin
     y1   = 0.
     y2   = 1.
     ybnd = .2
     return {y1, y2, ybnd}
end
x1   = 0.
x2   = 1.
xbnd = .2
limx = {x1, x2, xbnd}
gaussq2d(function fvec, limx, function limy)