Why WolframAlpha gives different results?

353 Views Asked by At

Any idea why WolframAlpha gives different answers when computing the indefinite integral of these functions with respect to x first or with respect to y first?

enter image description here

Left Right

enter image description here

Left Right

enter image description here

Left Right

This question emerge from splitting this deleted question into two question because I thought it was too messy.

1

There are 1 best solutions below

1
On BEST ANSWER

The short answer is that WolframAlpha produces different results because Mathematica produces different results:

integrand = (x*(x - y)^2)/(x^2 + y^2);
anti1 = Integrate[integrand, x, y];
anti2 = Integrate[integrand, y, x];
Simplify[anti1 - anti2]

(* Out: 2x^3/9 *)

This is not a bug, as the mixed partials of both expressions are the same.

Simplify[D[anti1, x, y] - D[anti2, x, y]]

(* Out: 0 *)

More generally, there is no reason to expect that $$\iint f(x,y) \, dx \, dy = \iint f(x,y) \, dy \, dx,$$ as there is a choice of an arbitrary constant for the first integral. As a very simple example, $$\int 0 \, dx = 1 \mbox{ and } \int 0 \, dx = y^2$$ are both reasonable choices for an integral with respect to $x$, assuming that the integrand is implicitly a function of $x$ and $y$. The next integral with respect to $y$ then depends on which choice was made.

What is true is that (under reasonable assumptions on $f$), $$\int_0^X \int_0^Y f(x,y) \, dx \, dy = \int_0^Y \int_0^X f(x,y) \, dy \, dx.$$ This is called Fubini's theorem.

Thus,

anti3 = Integrate[integrand, {x, 0, X}, {y, 0, Y},
  Assumptions -> {X > 0, Y > 0}];
anti4 = Integrate[integrand, {y, 0, Y}, {x, 0, X},
 Assumptions -> {X > 0, Y > 0}];
Simplify[Simplify[anti3 - anti4] /. 
  ArcTan[Y/X] -> Pi/2 - ArcTan[X/Y]]

(* Out: 0 *)

Note that the ArcTan[Y/X] -> Pi/2 - ArcTan[X/Y] is a simplification that didn't happen automatically.