# Evaluating two equivalent integrals apparently gives two different results

I have a integral and I use two different symbols in an interchangeable way, but I do not get same expressions when I swap them. Can some one explain why?

Integrate[1/Sqrt[(x - t) (y - t)], {t, 0, y}, Assumptions -> 0 < y < x]

Log[(x + y + 2 Sqrt[x y])/(x - y)]

Integrate[1/Sqrt[(x - t) (y - t)], {t, 0, x}, Assumptions -> 0 < x < y]

2 ArcTanh[Sqrt[x/y]]

• Please post code, not images – Dr. belisarius Sep 24 '15 at 14:02
• Actually the two results differ by the constant I π and integration results can always differ by a constant. – m_goldberg Sep 24 '15 at 17:01
• @m-goldberg, how can integration results always differ by a constant if you specify the range of integration? – xjtan Sep 24 '15 at 17:19

I assume it has something to do with how the Groebner basis is applied for the reduction (i.e. simplification) of the expressions. We can see that the observed behavior holds for other variables with the same alphabetical order of their symbols names.

In:= Integrate[1/Sqrt[(a - t)*(y - t)], {t, 0, y},
Assumptions -> 0 < y < a]

Out= Log[(a + y + 2*Sqrt[a*y])/(a - y)]

In:= Integrate[1/Sqrt[(a - t)*(b - t)], {t, 0, a},
Assumptions -> 0 < a < b]

Out= 2*ArcTanh[Sqrt[a/b]]

In:= Integrate[1/Sqrt[(c - t)*(b - t)], {t, 0, c},
Assumptions -> 0 < c < b]

Out= Log[(b + c + 2*Sqrt[b*c])/(b - c)]

• I'd be surprised if GroebnerBasis is used in any way in these simplifications. There are no equations in sight, just inequalities. – Daniel Lichtblau Sep 24 '15 at 19:26
• I assumed that Groebner basis usage might explain the lexicographical dependency of the results... – Anton Antonov Sep 24 '15 at 21:57

The two evaluate to the same values.

f = 1/Sqrt[(x - t)*(y - t)];
v1 = Integrate[f, {t, 0, y}, Assumptions -> {0 < y < x}]

(* Log[(x + y + 2 Sqrt[x y])/(x - y)] *)

v2 = Integrate[f, {t, 0, x}, Assumptions -> {0 < x < y}]

(* 2 ArcTanh[Sqrt[x/y]] *)

v3 = v2 /. {y -> x, x -> y}
g = v1/v3;
Table[g /. {x -> 10}, {y, 1, 9, 1}] // N

(* {1., 1., 1., 1., 1., 1., 1., 1., 1.} *)

• This is probably better demonstrated with the code: FullSimplify[(Log[(x + y + 2*Sqrt[x*y])/(x - y)] /. {y -> x, x -> y}) - 2*ArcTanh[Sqrt[x/y]], Assumptions -> 0 < x < y] – Anton Antonov Sep 24 '15 at 14:29
• I feel like the question is more to do with why the different results for expressions which are all but lexicographically equivalent. – IPoiler Sep 24 '15 at 14:40
• Actually the two results differ by the constant I π – m_goldberg Sep 24 '15 at 15:12
• @m_goldberg, I noticed that too but realized it was only for x=y=0 which is outside the range of assumptions. Were you noticing that somewhere else within the assumption constraints? – IPoiler Sep 24 '15 at 16:41
• @It'sPronouncedOiler. Oops! Posted in wrong place. Should have posted my observation as a comment to the main question. Thanks for the tip. – m_goldberg Sep 24 '15 at 17:04

One gets a different answer depending upon the alphabetical order of the symbols used.

All that is done below is to swap one symbol for another.

Starting with the first expression.

Integrate[1/Sqrt[(x - t) (y - t)], {t, 0, y}, Assumptions -> 0 < y < x]


Log[(x + y + 2 Sqrt[x y])/(x - y)]

Swap a for x

Integrate[1/Sqrt[(a - t) (y - t)], {t, 0, y},  Assumptions -> 0 < y < a]


Log[(a + y + 2 Sqrt[a y])/(a - y)]

Swap b for y

Integrate[1/Sqrt[(a - t) (b - t)], {t, 0, b}, Assumptions -> 0 < b < a]


Log[(a + b + 2 Sqrt[a b])/(a - b)]

Now swap y for a

Integrate[1/Sqrt[(y - t) (b - t)], {t, 0, b}, Assumptions -> 0 < b < y]


2 ArcTanh[Sqrt[b/y]]

This appears to be a different answer.

Test the two expressions

Based upon Asim's result let's check if the two answers are equivalent.

FullSimplify[Log[(x + y + 2 Sqrt[x y])/(x - y)] - 2 ArcTanh[Sqrt[y/x]],
Assumptions -> x > y > 0]


The answer is 0 indicating that they are indeed equivalent with the given assumptions.

We are left with the interesting question as to why we get two different, but equivalent, expressions when we merely swap the symbols.