# Identical integral evaluating differently

I am trying to compute an integral but am getting two different answers using two near-identical methods. I wish to know why they differ.

f[x_] := x^2 + 1
g[x_] := 1/(2 π) 1/(x^2 + (1/4))

Simplify[
Assuming[λ ∈ Reals,
Integrate[(
f[x] g[x])/(λ + I x), {x, -∞, ∞},
PrincipalValue -> True
]
],
λ > 0
]
(* Answer: (5+2λ)/(2+4λ) if λ < 1/4*)

Assuming[λ > 0,
Integrate[
(f[x] g[x])/(λ + I x), {x, -∞, ∞},
PrincipalValue -> True
]
]
(* Answer: (2+λ)/(1+2λ)  if λ <= 1/4*)


As shown in the code, the two answers are different. I think the latter answer is correct mathematically. However, based on the underlying physics from which this equation arose, the first answer is correct. (I need the integral to yield 2.5 as lambda goes to 0.) I would like to know what causes this mismatch.

• What's your Mathematica version? v12.2 says integral doesn't converge! Jan 24 at 12:13
• I have v12.2 Student Edition. Maybe you didn't use the principal value option? Jan 24 at 12:25
• If I use the option Mathematica gives a result with the restriction Re[\[Lambda]] == 0 Jan 24 at 12:28
• The first integral without simplification contains "Log"'s. As Log is a multivalued function it is no surprise that different results can be obtained. Jan 24 at 19:29
• With v13.0, for the first integral I do not get a conditional result, just (5 + 2*λ)/(2 + 4*λ) and the second integral gives this same result if the assumption is changed to 0 < λ <= 1/4 Jan 25 at 4:07

If you expand the integrand to ReIm

reim=(f[x] g[x])/(\[Lambda] + I x) // ComplexExpand[ReIm[#]] & // Simplify
(*{(2 (1 + x^2) \[Lambda])/(\[Pi] (1 + 4 x^2)(x^2 + \[Lambda]^2)), -((2 (x + x^3))/(\[Pi] (1 + 4 x^2)(x^2 + \[Lambda]^2)))}*)


integration gives (Mathematica v12.2)

Integrate[reim, {x, -Infinity, Infinity}]


$$\left\{\fbox{\frac{\lambda +2}{2 \lambda +1}\text{ if }\Re(\lambda )>0},\int_{-\infty }^{\infty } -\frac{2 \left(x^3+x\right)}{\pi \left(4 x^2+1\right) \left(\lambda ^2+x^2\right)} \, dx\right\}$$

That means only integration over real part converges.

• Yes, I do understand that $(\lambda+2)/(2\lambda+1)$ is the correct answer that matches numerics. However, why does the difference arise in what I ran? The answer to that may be important as highlighted in my question. Thanks for your inputs. Jan 24 at 12:28