I want to evaluate an integral with all variables real and positive. Specifically,
Integrate[
Log[\[Sqrt](r^2 + s^2 - 2 r s Cos[\[Theta]])], \[Theta],
Assumptions -> {r >= 0, s >= 0, \[Theta] \[Element] Reals}]
I expect the answer to be real, however Mathematica returns me an answer that is complex: it starts as
1/2 (\[Theta] Log[r^2 + s^2 - 2 r s Cos[\[Theta]]] -
1/(2 (r - s))
I (2 \[Pi] r \[Theta] - 2 \[Pi] s \[Theta] +
E^-ArcTanh[(r - s)/(r + s)] r Sqrt[(r s)/(r + s)^2] \[Theta]^2 - ...
i.e. there is an explicit imaginary part.
(Q0: When writing my questions here, how do I format Mathematica input and output so that it looks more human-readable, like it is in my Mathematica notebook?!)
Q1: Is there a way of telling Mathematica that I expect a real answer in this problem, apart from specifying real inputs using Assumptions
?
Q2: When calculating the definite integral between 0 and 2pi I get a sensible answer:
ConditionalExpression[- \[Pi] Log[2/(r^2 + s^2 + Abs[r^2 - s^2])],
r != 0 || s != 0]
However try as I might, I can't retrieve this answer by substituting 2pi and 0 into the above answer for the indefinite integral and subtracting the two. I've tried substituting into the full antiderivative, and taking the real part before substituting, but I just get a long complicated expression in either case. Can anyone help me understand why the definite integral looks so different to (and simpler than) substituting by hand into the indefinite integral and subtracting?