Multivariable calculus

Triple Integral of z sin x cos y over a Box

The triple integral of z sin(x) cos(y), with x and y from 0 to pi/2 and z from 0 to 2, equals 2. The integrand separates into three one variable pieces: the integral of sin(x) is 1, the integral of cos(y) is 1, and the integral of z from 0 to 2 is 2.

f(x,y,z)=zsinxcosyf(x,y,z) = z\sin x\cos y
0π/20π/202zsinxcosydzdydx=2\int_0^{\pi/2} \int_0^{\pi/2} \int_0^{2} z\sin x\cos y \,dz\,dy\,dx = 2

Numerically 2.000000, confirmed by quadrature on every build.

Separate first, then do three easy integrals

Each factor uses exactly one variable and all six limits are constants, so the triple integral is a product. Group the factors with their own limits before integrating anything.

(0π/2sinxdx)(0π/2cosydy)(02zdz)\left(\int_0^{\pi/2} \sin x \,dx\right)\left(\int_0^{\pi/2} \cos y \,dy\right)\left(\int_0^{2} z \,dz\right)

The first factor is [cosx]0π/2=0(1)=1\left[-\cos x\right]_0^{\pi/2} = 0 - (-1) = 1. The second is [siny]0π/2=10=1\left[\sin y\right]_0^{\pi/2} = 1 - 0 = 1. The third is [z22]02=2\left[\frac{z^2}{2}\right]_0^2 = 2.

112=21 \cdot 1 \cdot 2 = 2

Both trigonometric factors run over a quarter period where the function is non negative, which is why each comes out to exactly 11.

The mistake: losing the sign on the sine integral

The antiderivative of sinx\sin x is cosx-\cos x, and the leading minus sign gets dropped constantly. Writing [cosx]0π/2=01=1\left[\cos x\right]_0^{\pi/2} = 0 - 1 = -1 turns the answer into 2-2, which cannot be right for an integrand that is non negative on the whole box.

Two habits prevent it.

  • Differentiate your antiderivative back before substituting limits: the derivative of cosx-\cos x is +sinx+\sin x, so the sign is right.
  • Check the sign of the integrand over the region first. Here sinx0\sin x \geq 0, cosy0\cos y \geq 0 and z0z \geq 0 throughout, so the answer must be positive.
  • Keep the limits in radians. A calculator left in degree mode reads the upper limit π21.5708\frac{\pi}{2} \approx 1.5708 as 1.57081.5708 degrees, a sliver of the quarter turn you wanted, and returns about 0.02150.0215 instead of 11.

What changes if the box changes

Push the yy limit out to π\pi and the cosine factor becomes [siny]0π=0\left[\sin y\right]_0^{\pi} = 0, so the whole triple integral collapses to zero. The positive part of cosy\cos y on [0,π2]\left[0, \frac{\pi}{2}\right] exactly cancels the negative part on [π2,π]\left[\frac{\pi}{2}, \pi\right].

That is worth noticing before doing any work, because a factor of zero makes the other two integrals irrelevant. With a separable integrand, one vanishing factor sets the whole answer to zero.

Frequently asked questions

Why is the value exactly 2 and not something with pi in it?

The π/2\pi/2 appears only in the limits, and sin\sin and cos\cos evaluated at 00 and π/2\pi/2 give the integers 00 and 11. The only non integer input cancels itself out, leaving 112=21 \cdot 1 \cdot 2 = 2.

Does the order dz dy dx matter here?

No. The limits are constants and the integrand factors, so all six orders give 22. Order matters when a limit depends on another variable, which never happens on a box.