# symbolic Integration of a long function while retaining constants

I have the following function f

f=(4 (0.5 +nm) Γ (16 g2^4+8 g2^2 (κ1 κ2-4 ω^2)+(κ1^2+4 ω^2) (κ2^2+4 ω^2)))/(16
g2^4 (Γ^2+4 ω^2)+(κ2^2+4 ω^2) (16 g1^4+8 g1^2 (Γ κ1-4 ω^2)+(Γ^2+4 ω^2) (κ1^2+4
ω^2))+8 g2^2 ((κ1 κ2-4 ω^2) (Γ^2+4 ω^2)+4 g1^2 (Γ κ2+4 ω^2)))


(note the white spaces between terms just refers to product/multiplication. I directly copied from my output and I apologize for any confusion caused.)

My goal is to find the symbolic integral of f from -[\Infinity] to [\Infinity] as a function of ω with the remaining variables (g2, g1, κ1, κ2, Γ, nm) as constants. A straightforward attempt was given as follow:

Integrate[f, {ω, -[\Infinity], [Infinity]}]


However, upon returning, I get something like

ConditionalExpression[-((I (0.5 +
nm) Γ ((4 g2^2 + κ1 κ2)^2 \
(√Root[
16 g2^4 Γ^2 +
32 g1^2 g2^2 Γ κ2 +
8 g2^2 Γ^2 κ1 κ2 +
16 g1^4 κ2^2 +
8 g1^2 Γ κ1 κ2^2 + \
Γ^2 κ1^2 κ2^2 + (64 g1^4 +
128 g1^2 g2^2 + 64 g2^4 - 32 g2^2 Γ^2 +
32 g1^2 Γ κ1 + ...


and the list goes on. I am not sure what to make of it. I decided to mitigate the problem by only taking finite limits

Integrate[f, {ω, -1000, 1000}]


But this takes forever for the compiler to compile (I have yet to have it compile successfully).

I know it's possible to numerically integrate this using NIntegrate by defining all the constants

NIntegrate[
f /. {nm -> 300, Γ -> 10^-2, κ1 ->
1, κ2 -> 10, g1 -> 0.707, g2 -> 10}, {ω, -1000, 1000}]


and this returns a finite value. However I require the analytical expression of the integral so that I can study the behavior of that function in detail.

I appreciate any help that I can get in advance. Thanks!

• The solution given by Integrate seems quite complicated and this is only expected given that you have so many constants and each of them can be either positive, negative or 0, or even Complex. If you know that some of them are going to be positive (for example) then try Assumptions. – Lotus Apr 20 '18 at 7:03
• The "list" Mathematica evaluated is the analytic solution you're looking for! The listed conditions can be evaluated for given parameters. But it looks complicated. Perhaps you have additional information concerning the parameters, which could help to simplify the integrand using Apart[]... – Ulrich Neumann Apr 20 '18 at 7:09

Integrate[f, {ω, -[\Infinity], [Infinity]}] works just fine. The ConditionalExpression is used as you replace the constants with the number you want. The reason for the long expression is that you did not tell Mathematica the region of the constants, so Mathematica calculates every answer for all of the different region of the constants. To avoid getting such a long answer, you should add something like Assumptions->x>0 and others in the integrate. For example,

Integrate[Exp[-c x^2], {x, -\[Infinity], \[Infinity]}]


gives out

ConditionalExpression[Sqrt[\[Pi]]/Sqrt[c], Re[c] > 0]


by assuming Re[c]>0

Integrate[Exp[-c x^2], {x, -\[Infinity], \[Infinity]}, Assumptions -> Re[c] > 0]


it gives the right result

Sqrt[\[Pi]]/Sqrt[c]

• I have included assumptions for g1, g2, k1, k2 and [CapitalGamma] to be element of Reals. However, I'm getting the same ConditionalExpression in my output. Particularly, it has a sqrt[Root] that appears in it and I'm not sure what to make of it. What does this mean here? – kowalski Apr 23 '18 at 1:59
• @kowalski Exactly the same? That shouldn't be. Perhaps you should check what the conditions are. – t-smart Apr 23 '18 at 12:35