My goal is to plot a function psi that is setup as
k \[Element] Reals; k > 0;
Ck = HankelH2[1, k]/(HankelH2[1, k] + I HankelH2[0, k])
CGk = Ck (BesselJ[0, k] - I BesselJ[1, k]) + I BesselJ[1, k] //FullSimplify
FGk = Re[CGk]
GGk = Im[CGk]
\[Psi] = 2/\[Pi] NIntegrate[(FGk Cos[k] - GGk Sin[k])/k Sin[k s], {k,0, \[Infinity]}];
\[Psi]plot = Plot[\[Psi], {s, 0, 20}, PlotRange -> {{0, 20}, {0, 1}},PlotStyle -> {Thickness[.005], Blue}, AxesLabel -> {"s", "\[Psi](s)"}]
The function plots very poorly after about 30 minutes with frightening messages such as:
"NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in k near {k} = {169.7`}. NIntegrate obtained ...error estimates"
The error given in this picture doesn't seem like a lot, but as you can see further down, this function plots poorly compared to a true plot. I would like to increase resolution at the front end of the plot (small values of s).
The function should look more like these approximations:
\[Psi]a1 = 1 - 0.5 Exp[-0.13 s] - 0.5 Exp[-s]
\[Psi]a1plot = Plot[\[Psi]a1, {s, 0, 200}, PlotRange -> {{0, 25}, {0, 1}},
PlotStyle -> {Thickness[.005], Red}, AxesLabel -> {"s", "\[Psi](s)"}]
\[Psi]a2 = (s^2 + s)/(s^2 + 2.82 s + 0.8)
\[Psi]a2plot = Plot[\[Psi]a2, {s, 0, 200}, PlotRange -> {{0, 25}, {0, 1}},
PlotStyle -> {Thickness[.005], Orange}, AxesLabel -> {"s", "\[Psi](s)"}]
Show[\[Psi]plot, \[Psi]a1plot, \[Psi]a2plot, PlotRange -> {{0, 20}, {0, 1}}, AxesLabel -> {"s", "\[Psi](s)"}]
EDIT:
By reducing the interval of integration as discussed in Julien Kluge's post (thanks!), the "discontinuity" at s = 2
seems to smooth out into an oscillation. I still don't understand why the solution diverges from the correct values (red and orange plots) for values of s < 15
.
FINAL EDIT
I believe the function is plotting correctly because I found an error in the original formula. Once corrected, the final solution agrees with the approximate solutions. Changing the integration limits to 100 helped immensely to speed up the calculations.
//FunctionExpand
and//FullSimplify
as you recommended previously, the expression was reduced to only Bessel functions of the first and second kind. This may be helpful in the final computation, but has not corrected the plot or time required to plot as far as I can tell. Thanks for the tip. $\endgroup$