# Definite and indefinite integral give different results

I'm trying to find an expression that, given $x$, $y$, and $R$, gives the indefinite 2D integral of a function at the circle centered on $(x_0, y_0)$ with radius $R$.

With $g$ as defined below, I'd expect $g(R, x_0, y_0)$ to always equal $\pi R^2$ regardless of $x_0$ and $y_0$:

f[x_, y_] := 1;
g[R_, x0_, y0_] := ConditionalExpression[Integrate[f[x, y], {x, x0 - R, x0 + R},
{y, -Sqrt[R^2 - (x - y0)^2], Sqrt[R^2 - (x - y0)^2]}], R > 0 &&
{x0, y0, R} \[Element] Reals]


This works as expected when $x_0$ and $y_0$ are defined:

g[1, 0, 0]


Pi

Simplify[g[R, 1, 1]]


ConditionalExpression[Pi R^2, R [Element] Reals && R > 0]

However, when all three variables are left as symbols, something goes wrong:

Simplify[g[R, x0, y0]]


ConditionalExpression[(R + x0 - y0) Sqrt[-(x0 - y0) (2 R + x0 - y0)] + (R - x0 + y0) Sqrt[(x0 - y0) (2 R - x0 + y0)] - R^2 ArcTan[(-R - x0 + y0)/Sqrt[-(x0 - y0) (2 R + x0 - y0)]] + R^2 ArcTan[(R - x0 + y0)/Sqrt[(x0 - y0) (2 R - x0 + y0)]], R > 0 && (x0 | y0 | R) [Element] Reals && ((1/(Im[R] Re[R]))(-Im[x0] Re[R] + Im[y0] Re[R] + Im[R] (Re[x0] - Re[y0])) (Re[R]^2 (Im[x0] Re[R] - Im[y0] Re[R] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0]))) + Im[R]^2 (-Im[x0] Re[R] + Im[y0] Re[R] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 > + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] > (Re[x0] - Re[y0]))) + Im[R]^3 (Re[x0] - Re[y0]) + Im[R] Re[R]^2 (-Re[x0] + Re[y0])) == 0 || Re[(1/(Im[R] Re[R]))(Im[x0] Re[R] - Im[y0] Re[R] + Im[R] Re[x0] + [Sqrt] ((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0])) - Im[R] Re[y0])] == -2 || Re[(1/(Im[R] Re[R])) (Im[x0] Re[R] - Im[y0] Re[R] + Im[R] Re[x0] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0])) - Im[R] Re[y0])] == 2 || (1/(Im[R]^2 Re[R]^2))(-Im[x0] Re[R] + Im[y0] Re[R] + Im[R] (Re[x0] - Re[y0])) (Re[R]^2 (Im[x0] Re[R] - Im[y0] Re[R] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0]))) + Im[R]^2 (-Im[x0] Re[R] + Im[y0] Re[R] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0]))) + Im[R]^3 (Re[x0] - Re[y0]) + Im[R] Re[R]^2 (-Re[x0] + Re[y0])) >= 0 || Re[(1/(Im[R] Re[R])) (Im[x0] Re[R] - Im[y0] Re[R] + Im[R] Re[x0] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0])) - Im[R] Re[y0])] >= 2 || Re[(1/(Im[R] Re[R]))(Im[x0] Re[R] - Im[y0] Re[R] + Im[R] Re[x0] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0])) - Im[R] Re[y0])] <= -2 || (1/(Im[R] Re[R]))(Im[x0] Re[R] - Im[y0] Re[R] + Im[R] Re[x0] + [Sqrt]((Im[x0] - Im[y0])^2 Re[R]^2 + Im[R]^2 (4 Re[R]^2 + (Re[x0] - Re[y0])^2) - 2 Im[R] (Im[x0] - Im[y0]) Re[R] (Re[x0] - Re[y0])) - Im[R] Re[y0]) [NotElement] Reals)]

Even stranger, the above function doesn't give the same result as the definite cases I tried above. In fact, it's undefined when x0 == y0 because of the (-R - x0 + y0)/Sqrt[-(x0 - y0) (2 R + x0 - y0)] terms. Therefore, the function returned by the indefinite integral cannot be correct.

Where's my mistake?

EDIT: one additional data point: running $g(R, 10, 1)$ gives:

ConditionalExpression[3 (9 + R) (Sqrt[-9 - 2 R] + Sqrt[-9 + 2 R]) + R^2 (ArcTan[(9 + R)/(3 Sqrt[-9 - 2 R])] + ArcTan[(-9 + R)/(3 Sqrt[-9 + 2 R])]), R > 0 && R [Element] Reals && Re[R] > 9 && (-Sqrt[-81 + Re[R]^2] <= Im[R] < 0 || 0 < Im[R] <= Sqrt[-81 + Re[R]^2])]

which also doesn't simplify to $\pi R^2$ when $R=1$.

• Your integration limits are off, I think... The points on the circle satisfy (x-x0)^2 + (y-y0)^2 == R^2, so for a point x in the range [x0-R,x0+R] the limits on y are {y0 - Surd[R^2 - (x-x0)^2,2],y0 + Surd[R^2-(x-x0)^2,2]}. I use Surd here because MMA may simplify more easily than with Sqrt, since Sqrt is more general. May 23 '16 at 14:02
• @MariusLadegårdMeyer thank you! I knew it was something careless like that. If you make your comment into an answer, I'll accept it. May 23 '16 at 17:15
– user9660
Jun 6 '16 at 14:17

(x-x0)^2 + (y-y0)^2 == R^2

so for a point x in the range [x0-R,x0+R] the limits on y are
{y0 - Surd[R^2 - (x-x0)^2,2],y0 + Surd[R^2-(x-x0)^2,2]}

I use Surd here because MMA may simplify more easily than with Sqrt, since Sqrt is more general.