I am trying to get DiscretePlot of the following integral containing laguerre polynomial, the Mathematica code of which is given below:
A1[l0_, ρ_, n_, m_, q_, h_, M_,
v_] := (Sqrt[(2*(q - (Abs[m] + m)/2)!)/(l0^2*q!)])*
Exp[-((I/(2*h)*M*v*ρ^2)/l0)]*
Exp[-(ρ^2/(2*l0^2))]*((ρ^2/l0^2)^(Abs[m]/2))*
LaguerreL[q - (Abs[m] + m)/2, Abs[m], (ρ^2/l0^2)]*(Sqrt[(2*(n - (Abs[m] + m)/2)!)/(l0^2*n!)])*
Exp[-(ρ^2/(2*l0^2))]*((ρ^2/l0^2)^(Abs[m]/2))*
LaguerreL[n - (Abs[m] + m)/2, Abs[m], (ρ^2/l0^2)]*ρ
E0[q_, m_, w0_, Ω_,
h_] := (q + 1/2)*h*(w0 + Ω) + (q - m + 1/2)*
h (w0 - Ω) + (4 + 1/2)*h*10
p1[l0_, l1_, ρ_, n1_, m_, q_, h_, M_, v_,
w0_, Ω_, τ_] := (Sqrt[(
2*(n1 - (Abs[m] + m)/2)!)/(l1^2*n1!)])*
Exp[-(ρ^2/(2*l1^2))]*((ρ^2/l1^2)^(Abs[m]/2))*
LaguerreL[n1 - (Abs[m] + m)/2, Abs[m], (ρ^2/l1^2)]*(Sqrt[(2*(q - (Abs[m] + m)/2)!)/(l1^2*q!)])*
Exp[(I/(2*h)*M*v*ρ^2 -
I/h*l0*E0[q, m, w0, Ω, h]*τ)/l1]*
Exp[-(ρ^2/(2*l1^2))]*((ρ^2/l1^2)^(Abs[m]/2))*
LaguerreL[q - (Abs[m] + m)/2, Abs[m], (ρ^2/l1^2)]*ρ
p2[n_, q_] :=
NIntegrate[A1[1, ρ, n, 1, q, 1, 1, 5], {ρ, 0, Infinity}]*
NIntegrate[
p1[1, 2, ρ, 2, 1, q, 1, 1, 5, 10, 5, 10], {ρ, 0,
Infinity}]
p3[n_] := Sum[p2[n, q], {q, 1, 10}]
DiscretePlot[Abs[p3[n]]^2, {n, 1, 6, 1}, PlotStyle -> Red]
But it shows the following error:
NIntegrate::errprec: Catastrophic loss of precision in the global error estimate due to insufficient WorkingPrecision or divergent integral.
I searched in the already discussed question in Mathematica stack exchange related to this kind of error and I got a particular case under heading "Catastrophic loss of precision", where it is suggested to avoid the error by using Table command, but I could not follow the same properly in my case.
Would you kindly suggest me how to amend my code such that I can get the desired plot?
NIntegratecauses the error. Alternatively, the message is implying you should try increasingWorkingPrecision. (Tableseems an unlikely fix, though the separate integrals would be returned instead of their sum. That might be helpful.) – Michael E2 Sep 18 '22 at 16:42?NumericQon the arguments ofp2[], while it probably won't fix this problem, is good practice. – Michael E2 Sep 18 '22 at 16:48p2[n_?NumericQ,q_?NumericQ] := <..rest of definition..>is how it is shown in the "Applications" section of theNumericQdocumentation and the examples in the link in my previous comment. – Michael E2 Sep 18 '22 at 18:47p2[n_?NumericQ, q_?NumericQ] := NIntegrate[A1[1, \[Rho], n, 1, q, 1, 1, 5], {\[Rho], 0, Infinity}]* NIntegrate[ p1[1, 2, \[Rho], 2, 1, q, 1, 1, 5, 10, 5, 10], {\[Rho], 0, Infinity}]p3[n_?NumericQ] := Sum[p2[n?NumericQ, q?NumericQ], {q, 1, 10}]DiscretePlot[Abs[p3[n?NumericQ]]^2, {n, 1, 6, 1}, PlotStyle -> Red]– R. Bhattacharya Sep 18 '22 at 19:02?NumericQin more than the two places I indicated. (2) What does not show anything? (You said "it.") I did say I didn't think this would solve the problem with your code. To do that, you'll have to fix theNIntegratecall that gives the error. Have you determined which on that is? – Michael E2 Sep 18 '22 at 19:14