From previous threads I have read on the subject, it seems that Mathematica is known to simplify expressions to varying degrees depending on alphabetical order of chosen variable names. But none of the threads reported functionally different answers. In my case, when using a variable name alphabetically before the integration variable "r", the resulting expression is only defined on part of the domain!
Version info: "11.1.1 for Microsoft Windows (64-bit) (April 18, 2017)"
Is this a bug, or am I missing somthing?
Code starts with global assumptions:
$Assumptions = d > 0 && s > 0 && q > 0
Option 1
Integrate[(r^2*Sin[\[Theta]])/(r^2 + q^2 + 2*r*q*Cos[\[Theta]]),
{r, 0, d}, {\[Theta], 0, Pi}]
giving
ConditionalExpression[(2*q*(d - q*ArcTanh[q/d]) - d^2*Log[-1 + (2*d)/(d + q)])/(2*q), d >= q]
vs Option 2
Integrate[(r^2*Sin[\[Theta]])/(r^2 + s^2 + 2*r*s*Cos[\[Theta]]),
{r, 0, d}, {\[Theta], 0, Pi}]
giving
d + ((d^2 - s^2)*Log[(d + s)^2/(d - s)^2])/(4*s)
Edit: Nasser's answer below solves the problem of discrepancy. But I think MMA should provide another answer for the rest of the domain (d<s
or d<w
). The plot in the attached image can illustrate.