Multivariable calculus

Double Integral of x e^(xy) Over [0,1] by [0,2]

The double integral of x times e to the xy over the rectangle x from 0 to 1 and y from 0 to 2 equals (e squared minus 3) divided by 2, about 2.19453. Integrate in y first: the factor x is exactly the derivative the substitution needs, so the inner integral is e to the 2x minus 1.

f(x,y)=xexyf(x,y) = x e^{xy}
0102xexydydx=e2322.19453\int_{0}^{1}\int_{0}^{2} x e^{xy}\,dy\,dx = \frac{e^2 - 3}{2} \approx 2.19453

Numerically 2.194528, confirmed by quadrature on every build.

Pick the order that avoids integration by parts

With xx frozen, yexy=xexy\frac{\partial}{\partial y} e^{xy} = x e^{xy}. The integrand is already an exact derivative in yy, so the inner integral needs no work at all.

02xexydy=[exy]y=0y=2=e2x1\int_{0}^{2} x e^{xy}\,dy = \left[e^{xy}\right]_{y=0}^{y=2} = e^{2x} - 1
01(e2x1)dx=[e2x2x]01=e22112=e232\int_{0}^{1} \left(e^{2x} - 1\right)\,dx = \left[\frac{e^{2x}}{2} - x\right]_{0}^{1} = \frac{e^2}{2} - 1 - \frac{1}{2} = \frac{e^2 - 3}{2}

Numerically that is about 2.19453. The lower limit contributes the 12-\frac{1}{2} from e02\frac{e^0}{2}, which is easy to lose.

What the other order costs

Integrating in xx first means xexydx\int x e^{xy}\,dx with yy frozen, and now the factor xx is not the derivative of the exponent. That needs integration by parts.

01xexydx=eyyey1y2\int_{0}^{1} x e^{xy}\,dx = \frac{e^{y}}{y} - \frac{e^{y} - 1}{y^{2}}

That function is fine on (0,2](0,2] and has a removable discontinuity at y=0y = 0, where the limit is 12\frac{1}{2}. Integrating it from 0 to 2 does return 2.19453, so the order is a choice about labour rather than about correctness.

The rule of thumb: look for the variable whose differential the extra factor already matches. Here xdyx\,dy pairs with d(exy)d\left(e^{xy}\right), so integrate in yy first.

The mistake: dividing by the wrong variable

The antiderivative of exye^{xy} with respect to yy is exyx\frac{e^{xy}}{x}: you divide by y(xy)=x\frac{\partial}{\partial y}(xy) = x. Dividing by yy instead produces exyy\frac{e^{xy}}{y}, whose yy derivative is not the integrand.

  • Integrating in yy, divide by y(xy)=x\frac{\partial}{\partial y}(xy) = x.
  • Integrating in xx, divide by x(xy)=y\frac{\partial}{\partial x}(xy) = y.
  • Here the leading xx cancels that 1x\frac{1}{x} exactly, which is what makes this order clean.

No division by zero sneaks in at x=0x = 0. The cancellation happens before the division, and the inner result e2x1e^{2x} - 1 is simply 0 there, matching an integrand that is 0 along that whole edge.

Frequently asked questions

How do I know to integrate in y first?

Look at the loose factor. Here it is xx, and y(exy)=xexy\frac{\partial}{\partial y}\left(e^{xy}\right) = x e^{xy}, so xx is exactly what the yy substitution consumes. Integrating in xx first leaves xx unmatched and forces integration by parts.

What happens at x = 0, where the antiderivative has a 1/x in it?

Nothing goes wrong. The factor xx in front cancels the 1x\frac{1}{x} before the limits are applied, leaving exye^{xy}. At x=0x = 0 the inner integral is e0e0=0e^{0} - e^{0} = 0, which matches an integrand of 0 along that edge.