# Real integral giving complex result [duplicate]

I'm trying to calculate the following indefinite integral:

$$\int \log \left(\left(\frac{\lambda ^2}{a \lambda ^2+b}+\text{\Delta 0}\right)^2\right) \, d\lambda$$

which is producing the following result:

$$\lambda \log \left(\left(\frac{\lambda ^2}{a \lambda ^2+b}+\text{\Delta 0}\right)^2\right)+\frac{4 \sqrt{b} \sqrt{\text{\Delta 0}} \tan ^{-1}\left(\frac{\lambda \sqrt{a \text{\Delta 0}+1}}{\sqrt{b} \sqrt{\text{\Delta 0}}}\right)}{\sqrt{a \text{\Delta 0}+1}}-\frac{4 \sqrt{b} \tan ^{-1}\left(\frac{\sqrt{a} \lambda }{\sqrt{b}}\right)}{\sqrt{a}}$$

This results seems correct except that for some values of a, b, and $\Delta_0$, it is returning a complex number. For example:

Integrate[Log[(Δ0 + λ^2/(a λ^2 + b))^2], λ]
/. a -> 0.87 /. b -> 2000 /. Δ0 -> -1.1 /. λ -> 300


gives the result

-1706.06 - 1421.21 I


Numerically integrating the function it seems as if the real part of the expression is correct. For example:

NIntegrate[
Log[(Δ0 + λ^2/(a λ^2 + b))^2] /. a -> 0.87 /. b -> 2000 /. Δ0 -> -1.1,
{λ, 0, 300}]


gives

-1706.05


My question is twofold:

1. Why is Mathematica returning an expression for this integral which can evaluate to a complex number?

2. Is it possible to obtain an expression which always evaluates to a real number, ideally one which contains no complex numbers as intermediate results in the expression?

• A numerical value for an integral only really makes sense if you specify limits. I suggest you determine suitable limits, and you may then find that you get a purely real answer. Jul 10 '18 at 20:41
• @mikado I'm evaluating the expression from $\lambda$ = 0 to $\lambda$ = 300. Jul 10 '18 at 20:43
• @user545424 Then use Integrate[..., {λ, 0, 300}] instead of Integrate[..., λ]. Jul 10 '18 at 20:45
• In evaluating an indefinite integral, Mathematica makes certain assumptions about the symbolic parameters. If you then substitute values that don't satisfy these assumptions, it can give you the wrong answer. Jul 10 '18 at 21:08
• Just found this post blog.wolfram.com/2008/01/19/… which seems to explain things pretty well. Thanks! Jul 10 '18 at 21:24