Integrates the following triple integral, using user-defined functions and scalars for bounds:
intgrat3(&f, xl, gl, hl)¶
- &f (scalar) – pointer to the procedure containing the function to be integrated. f is a function of (x, y, z).
- xl (2x1 or 2xN matrix) – the limits of x. These must be scalar limits.
- gl (2x1 or 2xN matrix) – function pointers. These procedures are functions of x.
- hl (2x1 or 2xN matrix) – function pointers. These procedures are functions of x and y.
y (Nx1 vector) – estimated integral(s) of \(f(x, y, z)\) evaluated between the limits given by xl, gl and hl.
|_intord||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.|
// Function to be integrated proc f(x, y, z); retp(2); endp; /* ** Function of x ** to be integrated */ proc g1(x); retp(sqrt(25 - x^2)); endp; /* ** Function of x ** to be integrated */ proc g2(x); retp(-g1(x)); endp; /* ** Function of x and y ** to be integrated */ proc h1(x, y); retp(sqrt(25 - x^2 - y^2)); endp; /* ** Function of x and y ** to be integrated */ proc h2(x, y); retp(-h1(x, y)); endp; // Limits of x xl = 5|-5; // Create pointer vectors g0 = &g1|&g2; h0 = &h1|&h2; // The order of the integration _intord = 40; // Find integral y = intgrat3(&f, xl, g0, h0);
This will integrate the function \(f(x, y, z)\) over the sphere of radius 5. The result will be approximately twice the volume of a sphere of radius 5.
User-defined functions f, and those used in gl and hl must either:
Return a scalar constant
- or -
Return a vector of function values.
intgrat3()will pass to user-defined functions a vector or matrix for x and y and expect a vector or matrix to be returned. Use
./operators instead of just