Multivariable calculus

Double Integral of y sin(xy) Over [1,2] by [0, pi/2]

The double integral of y times sin(xy), with x running from 1 to 2 and y from 0 to pi/2, equals 1. Integrate in x first: the factor y is exactly what the substitution u = xy needs, so the inner integral is cos y minus cos 2y, and integrating that from 0 to pi/2 gives 1.

f(x,y)=ysin(xy)f(x,y) = y\sin(xy)
0π/212ysin(xy)dxdy=1\int_{0}^{\pi/2}\int_{1}^{2} y\sin(xy)\,dx\,dy = 1

Numerically 1.000000, confirmed by quadrature on every build.

Integrate in x first and the leading y disappears

Hold yy fixed and substitute u=xyu = xy, so du=ydxdu = y\,dx. The loose factor yy is consumed exactly, leaving sinudu\int \sin u\,du.

12ysin(xy)dx=[cos(xy)]x=1x=2=cosycos2y\int_{1}^{2} y\sin(xy)\,dx = \left[-\cos(xy)\right]_{x=1}^{x=2} = \cos y - \cos 2y

No xx survives, so the inner stage is done. The outer integral is now an ordinary trigonometric one.

0π/2(cosycos2y)dy=[sinysin2y2]0π/2=10=1\int_{0}^{\pi/2} \left(\cos y - \cos 2y\right)\,dy = \left[\sin y - \frac{\sin 2y}{2}\right]_{0}^{\pi/2} = 1 - 0 = 1

The second term vanishes because sinπ=0\sin \pi = 0, so the whole answer comes from sinπ2=1\sin\frac{\pi}{2} = 1.

The other order needs integration by parts

Integrating in yy first, the factor yy is no longer the derivative of anything convenient, since y(xy)=x\frac{\partial}{\partial y}(xy) = x. You would need parts with u=yu = y and dv=sin(xy)dydv = \sin(xy)\,dy.

ysin(xy)dy=sin(xy)x2ycos(xy)x\int y\sin(xy)\,dy = \frac{\sin(xy)}{x^2} - \frac{y\cos(xy)}{x}

It gets to the same 1 in the end. The point is that the loose factor tells you which order is cheap: match it against x(xy)=y\frac{\partial}{\partial x}(xy) = y and y(xy)=x\frac{\partial}{\partial y}(xy) = x and take the one that fits.

The mistake: dividing by the wrong variable

The antiderivative of sin(xy)\sin(xy) in xx is cos(xy)y-\frac{\cos(xy)}{y}, dividing by x(xy)=y\frac{\partial}{\partial x}(xy) = y. Dividing by xx instead leaves ycos(xy)x-\frac{y\cos(xy)}{x}, and differentiating that in xx does not return the integrand.

  • Multiply the correct antiderivative back out: y(cos(xy)y)=cos(xy)y \cdot \left(-\frac{\cos(xy)}{y}\right) = -\cos(xy), with the yy gone.
  • If the inner answer still contains the loose factor, you divided by the wrong variable.
  • Differentiating your antiderivative with respect to the integration variable settles it every time.

The edge y=0y = 0 is a useful check. There the integrand is 0, and the inner result cos0cos0=0\cos 0 - \cos 0 = 0 agrees, so no stray factor of 1y\frac{1}{y} ever appears in the final expression.

Frequently asked questions

Why does the leading y vanish from the answer?

Because the substitution u=xyu = xy in the xx integral has du=ydxdu = y\,dx, so the yy is absorbed into dudu. Equivalently, sin(xy)dx=cos(xy)y\int \sin(xy)\,dx = -\frac{\cos(xy)}{y}, and the yy in front cancels the 1y\frac{1}{y}.

What changes if x runs from 1 to 3 instead?

The inner integral becomes cosycos3y\cos y - \cos 3y, and 0π/2(cosycos3y)dy=1+13=43\int_{0}^{\pi/2}\left(\cos y - \cos 3y\right)\,dy = 1 + \frac{1}{3} = \frac{4}{3}, since sin3π2=1\sin\frac{3\pi}{2} = -1.