# Integrating a incredibly long expression, whenever I try to use Monte Carlo I got complex answers

I am trying to integrate a recursion relation that is formulated via conformal invariance. The expression if copy and pasted from Mathematica to Word is over 20,000 pages long. Below is an infinitesimal sample of it. When I do Monte Carlo I calculate a complex answer which makes no sense. When the range for the w variable is large it is complex, but when it is small it is real as it should be. Can anyone tell me how do I integrate such a complicated beast of a function. Thanks!

-((2.26914 Abs[(1 - (((-E^Subscript[w, 2] Cos[Subscript[θ,
2]] + E^Subscript[w, 3]
Cos[Subscript[θ, 3]])^2 + (-E^Subscript[w, 2]
Cos[Subscript[ϕ, 2]] Sin[Subscript[θ,
2]] + E^Subscript[w, 3]
Cos[Subscript[ϕ, 3]] Sin[Subscript[θ,
3]])^2 + (-E^Subscript[w, 2] Sin[Subscript[θ,
2]] Sin[Subscript[ϕ, 2]] +
E^Subscript[w, 3]
Sin[Subscript[θ, 3]] Sin[Subscript[ϕ,
3]])^2) ((E^Subscript[w, 1]
Cos[Subscript[θ, 1]] -
E^Subscript[w, 4] Cos[Subscript[θ, 4]])^2 + (E^
Subscript[w, 1]
Cos[Subscript[ϕ, 1]] Sin[Subscript[θ,
1]] - E^Subscript[w, 4]
Cos[Subscript[ϕ, 4]] Sin[Subscript[θ,
4]])^2 + (E^Subscript[w, 1]
Sin[Subscript[θ, 1]] Sin[Subscript[ϕ,
1]] - E^Subscript[w, 4]
Sin[Subscript[θ, 4]] Sin[Subscript[ϕ,
4]])^2))/(((E^Subscript[w, 1]
Cos[Subscript[θ, 1]] -
E^Subscript[w, 3] Cos[Subscript[θ, 3]])^2 + (E^

Subscript[w, 1]
Cos[Subscript[ϕ, 1]] Sin[Subscript[θ,
1]] - E^Subscript[w, 3]
Cos[Subscript[ϕ, 3]] Sin[Subscript[θ,
3]])^2 + (E^Subscript[w, 1]
Sin[Subscript[θ, 1]] Sin[Subscript[ϕ,
1]] - E^Subscript[w, 3]
Sin[Subscript[θ, 3]] Sin[Subscript[ϕ,
3]])^2) ((E^Subscript[w, 2]
Cos[Subscript[θ, 2]] -
E^Subscript[w, 4] Cos[Subscript[θ, 4]])^2 + (E^
Subscript[w, 2]
Cos[Subscript[ϕ, 2]] Sin[Subscript[θ,
2]] - E^Subscript[w, 4]
Cos[Subscript[ϕ, 4]] Sin[Subscript[θ,
4]])^2 + (E^Subscript[w, 2]
Sin[Subscript[θ, 2]] Sin[Subscript[ϕ,
2]] - E^Subscript[w, 4]
Sin[Subscript[θ, 4]] Sin[Subscript[ϕ,
4]])^2)) + (((E^Subscript[w, 1]
Cos[Subscript[θ, 1]] -
E^Subscript[w, 2] Cos[Subscript[θ, 2]])^2 + (E^
Subscript[w, 1]
Cos[Subscript[ϕ, 1]] Sin[Subscript[θ,
1]] - E^Subscript[w, 2]

Cos[Subscript[ϕ, 2]] Sin[Subscript[θ,
2]])^2 + (E^Subscript[w, 1]
Sin[Subscript[θ, 1]] Sin[Subscript[ϕ,
1]] - E^Subscript[w, 2]
Sin[Subscript[θ, 2]] Sin[Subscript[ϕ,
2]])^2) ((E^Subscript[w, 3]
Cos[Subscript[θ, 3]] -
E^Subscript[w, 4] Cos[Subscript[θ, 4]])^2 + (E^
Subscript[w, 3]
Cos[Subscript[ϕ, 3]] Sin[Subscript[θ,
3]] - E^Subscript[w, 4]
Cos[Subscript[ϕ, 4]] Sin[Subscript[θ,
4]])^2 + (E^Subscript[w, 3]
Sin[Subscript[θ, 3]] Sin[Subscript[ϕ,
3]] - E^Subscript[w, 4]
Sin[Subscript[θ, 4]] Sin[Subscript[ϕ,
4]])^2))/(((E^Subscript[w, 1]
Cos[Subscript[θ, 1]] -
E^Subscript[w, 3] Cos[Subscript[θ, 3]])^2 + (E^
Subscript[w, 1]
Cos[Subscript[ϕ, 1]] Sin[Subscript[θ, 1]] -
E^Subscript[w, 3]
Cos[Subscript[ϕ, 3]] Sin[Subscript[θ,
3]])^2 + (E^Subscript[w, 1]
Sin[Subscript[θ, 1]] Sin[Subscript[ϕ, 1]] -

E^Subscript[w, 3]
Sin[Subscript[θ, 3]] Sin[Subscript[ϕ,
3]])^2)

Table[(i/i)*NIntegrate[(((
Out[23]/(4*Pi*W)^4)) Sin[Subscript[θ, 1]] Sin[
Subscript[θ, 2]] Sin[Subscript[θ, 3]] Sin[
Subscript[θ, 4]])((1/(4 (Cos[Subscript[θ, 1]]
Cos[Subscript[θ, 2]] -
Cosh[Subscript[w, 1]] Cosh[Subscript[w, 2]] +
Cos[Subscript[ϕ, 1] - Subscript[ϕ, 2]] Sin[
Subscript[θ, 1]] Sin[Subscript[θ, 2]] +
Sinh[Subscript[w, 1]] Sinh[Subscript[w, 2]]) (Cos[
Subscript[θ, 3]] Cos[Subscript[θ, 4]] -
Cosh[Subscript[w, 3]] Cosh[Subscript[w, 4]] +
Cos[Subscript[ϕ, 3] - Subscript[ϕ, 4]] Sin[
Subscript[θ, 3]] Sin[Subscript[θ, 4]] +
Sinh[Subscript[w, 3]] Sinh[Subscript[w,
4]])))^(0.5181489)), {Subscript[w, 1], 0,
W}, {Subscript[w, 2], 0, W}, {Subscript[w, 3], 0, W}, {Subscript[
w, 4], 0, W}, {Subscript[θ, 1], 0,
Pi}, {Subscript[θ, 2], 0, Pi}, {Subscript[θ, 3], 0,
Pi}, {Subscript[θ, 4], 0, Pi}, {Subscript[ϕ, 1], 0,
2*Pi}, {Subscript[ϕ, 2], 0, 2*Pi}, {Subscript[ϕ, 3], 0,
2*Pi}, {Subscript[ϕ, 4], 0, 2*Pi}, Method -> "MonteCarlo",
AccuracyGoal -> 4], {i, 1, 100}]

• TIP: don't use subscripts. Aug 23, 2018 at 18:40
• So instead of Subscript[w, 2] I should put in w2? Aug 23, 2018 at 18:45
• @DanielBerkowitz exactly, yes. Aug 23, 2018 at 20:15
• Or even better, w[2], or maybe myCoefficient[w,2] - that way, you can still use pattern matching on your variables Aug 24, 2018 at 5:46

I would look at using EvaluationMonitor to see if your expression is ever evaluated as complex e.g.
NIntegrate[Sqrt[x], {x, -1, 1},
`