0
$\begingroup$

My problem is $\int_{0}^\pi\int_{0}^{1}\int_{0}^{\sqrt{2f(x)}} q^{2}\sin(\theta) F(q,\theta,p)\eta(f(x)-q^2/2)dqd\theta dx$, I'm trying to plot this over $p$. Function $F$ is a monster, let us consider something simple, for ex. $F=exp(\theta x^{2}/p)$, $f$ is given (see code), $\eta$ is Heaviside function. I tried following:

f[x_] := (1 + Sqrt[x] + x*Exp[-Sqrt[x]])^2 Exp[-2 Sqrt[x]]
R[x_] := Sqrt[2 f[x]]
Plot[NIntegrate[
  Exp[(\[Theta]*x^2)/p]*HeavisideTheta[f[x] - q^2/2]*q^2*
   Sin[\[Theta]], {q, 0, R_?NumericQ}, {\[Theta], 0, Pi}, {x, 0, 
   1}], {p, 0.02, 1}]

and got standard invalid limits of integration warning. How to deal with this function upper limit?

$\endgroup$
  • 1
    $\begingroup$ 1. HeavisideTheta[] is intended for purely symbolic work; for numerics, use UnitStep[]. 2. NIntegrate[] has a special syntax for variable limits; using the order in your $\LaTeX$ expression: NIntegrate[(* function *), {x, 0, π}, {θ, 0, 1}, {q, 0, Sqrt[2 f[x]]}]. $\endgroup$ – J. M. will be back soon Apr 5 '17 at 17:15
  • $\begingroup$ Thanks @J.M. Integration stuck for about 20-25 mins(ultimate gaming PC) for my actual F but all done! $\endgroup$ – satoru Apr 5 '17 at 17:50
  • $\begingroup$ You don't need the Heaviside \ unitstep at all since you've bounded the integral so that its always 1. $\endgroup$ – george2079 Apr 5 '17 at 18:51
  • $\begingroup$ Note also the integral over q can be done analytically, so you should do that first and reduce the numerical integration to 2d. ( the example shown actually reduces to 1-d but I guess for general F that's not going to happen.) $\endgroup$ – george2079 Apr 5 '17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.