I have an integral that I compute with Mathematica and as a result I get a seemingly complex expression (i.e. the expression contains the imaginary unit, $i$, at some places). However, if I try to numerically compute the values of this expression at some values of my variables, I notice that in fact the value of the result is always real (for real values of variables); the imaginary parts cancel out in a right way to make the result real. This is also evident from the fact that the expression is a solution to a physical problem that is supposed to give a real solution.
How do I make Mathematica simplify the expression so that it doesn't contain any imaginary units anymore?
Edit:
The expression I'm trying to simplify is:
$$\frac{\sqrt{1-\frac{2}{-i x+y+1}}}{x+i (y-1)}+\frac{\sqrt{1-\frac{2}{i x+y+1}}}{x-i (y-1)}$$
In Mathematica form:
Sqrt[1 - 2/(1 - I x + y)]/(x + I (-1 + y)) + Sqrt[1 - 2/(1 + I x + y)]/(x - I (-1 + y))
ComplexExpand
. Otherwise please provide a sample problem. $\endgroup$With[{x = -1, y = -1}, FullSimplify[ Sqrt[(1 - 2/(-I x + y + 1))/(x + I (y - 1))] + Sqrt[( 1 - 2/(I x + y + 1))/(x - I (y - 1))]]]
which yields2 I
. This post shows how one could approach similar problems Simplifying expressions with square roots. $\endgroup$f[x_, y_] := Sqrt[(1 - 2/(-I x + y + 1))]/(x + I (y - 1)) + Sqrt[(1 - 2/(I x + y + 1))]/(x - I (y - 1))
which is real-valued (at least at -1,-1). $\endgroup$