Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am not very used to do numerical simulations on Mathematica. I have a problem with numerical integration of this function. Is there any way for this calculation?

Input:

α := 0.07

A := Sin[θ]*Sin[θ2]*Cos[φ - φ2] + Cos[θ]*Cos[θ2]
B := Sin[θ]*Sin[θ3]*Cos[φ - φ3] + Cos[θ]*Cos[θ3]
V := Sin[θ2]*Sin[θ3]*Cos[φ2 - φ3] + Cos[θ2]*Cos[θ3]

c2 := (B*c*c3 - c3*c3)/(A*c - c3*V)

integrand := 
 1/2 1/((-1 + E^(c^2 - α)) (-1 + E^(c2^2 - α)) Abs[A c - c3 V]) 
 c^4 c2^2 c3^2 (1 + 1/(-1 + E^(c^2 - α))) (1 + 1/(-1 + E^(c3^2 - α)))
 (1 + 1/(-1 + E^(c^2 + 2 A c c2 + c2^2 - B c c3 + c3^2 - 2 c2 c3 V - α))) 
 (1 + 3 Cos[2 θ]) (c Cos[θ] - c3 Cos[θ3])
 (c2 Cos[θ2] - c3 Cos[θ3]) Sin[θ] Sin[θ2] Sin[θ3]

NIntegrate[integrand, 
    {c3, 0, ∞}, {θ3, 0, π}, {θ2, 0, π}, 
    {φ3, 0, 2 π}, {φ2, 0, 2 π}, {c, 0, ∞}, {θ, 0, π}, {φ, 0, 2 π}, 
    Method -> "MultiDimensional"]

Output:

    NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the
 following: singularity, value of the integration is 0, highly oscillatory integrand, or
 WorkingPrecision too small. >>

    NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more
 than 2000 times. The global error is expected to decrease monotonically after a number of
 integrand evaluations. Suspect one of the following: the working precision is insufficient
 for the specified precision goal; the integrand is highly oscillatory or it is not a 
(piecewise) smooth function; or the true value of the integral is 0. Increasing the value of
 the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical 
integration. NIntegrate obtained -27257.8 and 652260.228217954` for the integral and error
 estimates. >>

I am using Mathematica 8.0

share|improve this question
1  
In Mathematica 9.0.1 I get -49639.1345 with no errors. The only thing I did differently was use Set(=) instead of SetDelayed(:=) to define the variables. –  RunnyKine Mar 22 at 15:01

1 Answer 1

I can confirm that using SetDelayed instead of Set is the culprit here. As I get the same error you got with SetDelayed but not with Set

The following works fine:

α = 0.07;
A = Sin[θ]*Sin[θ2]*Cos[φ - φ2] + Cos[θ]*Cos[θ2];
B = Sin[θ]*Sin[θ3]*Cos[φ - φ3] + Cos[θ]*Cos[θ3];
V = Sin[θ2]*Sin[θ3]*Cos[φ2 - φ3] + Cos[θ2]*Cos[θ3];
c2 = (B*c*c3 - c3*c3)/(A*c - c3*V);

integrand = 1/2 1/((-1 + E^(c^2 - α)) (-1 + E^(c2^2 - α)) Abs[A c - c3 V]) 
 c^4 c2^2 c3^2 (1 + 1/(-1 + E^(c^2 - α))) (1 + 1/(-1 + E^(c3^2 - α)))
 (1 + 1/(-1 + E^(c^2 + 2 A c c2 + c2^2 - B c c3 + c3^2 - 2 c2 c3 V - α))) 
 (1 + 3 Cos[2 θ]) (c Cos[θ] - c3 Cos[θ3])
 (c2 Cos[θ2] - c3 Cos[θ3]) Sin[θ] Sin[θ2] Sin[θ3];

NIntegrate[integrand, {c3, 0, ∞}, {θ3, 0, π}, {θ2, 0, π}, 
    {φ3, 0, 2 π}, {φ2, 0, 2 π}, {c, 0, ∞}, {θ, 0, π}, {φ, 0, 2 π}, 
    Method -> "MultiDimensional"]

This gives:

-49639.1345

Note This is on Mathematica 9.0.1

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.