1
$\begingroup$

I need to solve the following definite integral: $$\int_0^1 \mathrm{d}s \int_0^{2\pi} \mathrm{d}\phi \int_0^{2\pi} \mathrm{d}\phi' \int \mathrm{d}\theta\,'\sin{\theta\,'} \text{,}$$

such that $$\theta_1 \leq \arctan{\frac{\sqrt{\cos^2{\theta\,'}+(s \sin{(\phi'-\phi)})^2\sin^2{\theta\,'}}}{\sqrt{1-(s \sin{(\phi'-\phi)})^2}\cdot\sin{\theta\,'}}} \text{ and } 0 \leq \theta\,'\leq\frac{\pi}{2} \text{,}$$

where $\theta_1$ is some given real number in $[0,\pi/2]$.


However, when I try to numerically solve this integral (with NSolve for the inequality condition) in Mathematica, with:

enter image description here

I get the following error:

enter image description here

It seems as though Mathematica wants to evaluate the inequality before actually feeding in the values of $s$,$\phi$, and $\phi'$ in the definite integral.

How can I numerically solve this integral--an integral with an inequality condition that cannot be simplified to lower bounds?


Mathematica Code:

θ1 = 1.183479725906243`;
NIntegrate[
  Sin[θp], {s, 0, 1}, {ϕ, 0, 2 π}, {ϕp, 0, 2 π}, 
  θp ∈ 
    NSolve[
      {ArcTan[
         Sqrt[Cos[θp]^2 + (s Sin[ϕp - ϕ])^2 Sin[θp]^2] / 
           (Sqrt[1 - (s Sin[ϕp - ϕ])^2] Sin[θp])] >= θ1, 
       0 < θp < π/2}, 
      θp, Reals]];
$\endgroup$

closed as unclear what you're asking by Anton Antonov, bbgodfrey, Öskå, José Antonio Díaz Navas, MarcoB Aug 25 '18 at 14:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ You'll want to copy and paste your Mathematica code into your question, so that those who wish to try answering it don't have to retype it themselves. [And you're more likely to get help that way, since it makes it easier to work on the question.] $\endgroup$ – theorist Aug 19 '18 at 20:38
  • $\begingroup$ @theorist That's a good point; thank you. $\endgroup$ – abeta201 Aug 19 '18 at 20:49
2
$\begingroup$

Use Boole:

NIntegrate[Sin[θp]
           Boole[
                 ArcTan[Sqrt[Cos[θp]^2 + (s Sin[ϕp - ϕ])^2 Sin[θp]^2]/(Sqrt[1 - (s Sin[ϕp - ϕ])^2] Sin[θp])] >= θ1
           ]
, {s, 0, 1}, {ϕ, 0, 2 π}, {ϕp, 0, 2 π}, {θp, 0, π/2}]

(* 4.02185 *)
$\endgroup$
  • 1
    $\begingroup$ Thank you! That's so simple and makes a lot of sense, in hindsight. $\endgroup$ – abeta201 Aug 21 '18 at 2:48

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