Integrates the following double integral, using user-defined functions f, g1 and g2 and scalars a and b:
intgrat2(&f, xl, gl)¶
&f (scalar) – pointer to the procedure containing the function to be integrated.
xl (2x1 or 2xN matrix) – the limits of x. These must be scalar limits.
gl (2x1 or 2xN matrix) –
Function pointers to functions defining the limits of y.
For xl and gl, the first row is the upper limit and the second row is the lower limit. N integrations are computed.
y (Nx1 vector) – of the estimated integral(s) of \(f(x, y)\), evaluated between the limits given by xl and gl.
scalar, the order of the integration. The larger _intord, the more precise the final result will be. _intord may be set to 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40. Default = 12.
proc (1) = f(x, y); retp((cos(x) + 1).*(sin(y) + 1)); endp; proc (1) = g1(x); retp(sqrt(1 - x^2)); endp; proc (1) = g2(x); retp(0); endp; // Limits xl = 1|-1; // Create vector of function pointers g0 = &g1|&g2; // Order of integration _intord = 40; // Integrate y = intgrat2(&f, xl, g0);
This will integrate the function
f(x, y) = (cos(x) + 1)(sin(y) + 1)
over the upper half of the unit circle. Note the use of the
.* operator instead of just
* in the
definition of \(f(x, y)\). This allows f to return a vector or matrix of function values.
The user-defined functions specified by f and gl must either
Return a scalar constant
- or -
Return a vector of function values.
intgrat2()will pass to user-defined functions a vector or matrix for x and y and expect a vector or matrix to be returned. Use