# NIntegrate outputs huge value compared to expected [closed]

I'm trying to replicate something that my professor has done. He's done this on the software MATHCAD but I'm more familiar with Mathematica.

p=0.03

Rxxn[a_, b_, t_] := (p^2 (a - b))/(Sqrt[(a - b)^2 + t^2 + p^2] ((a - b)^2 + t^2)) + (a - b)/Sqrt[(a - b)^2 + t^2 + p^2]  + (a - b)/Sqrt[(a - b)^2 + t^2]
Rxxnavg[a_, t_, k_?NumericQ] := (Rxxn[a, 0.5, t] - Rxxn[a, -0.5, t]) *Cos[k t]
Rxx[a_?NumericQ] := NIntegrate[Rxxnavg[a, t, 0], {t, 0, \[Infinity]}]
Rxx


I get the following error:

During evaluation of In:= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in t near {t} = {6.13224*10^28}. NIntegrate obtained -47117.7 and 39303.336387089155 for the integral and error estimates.

Out= -47117.7

According to what he's done we are expected to find that Rxx is close to -1. However I get this answer. I'm not sure how to remedy this.

## closed as off-topic by rhermans, garej, MarcoB, Öskå, Michael E2Jul 31 at 17:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – rhermans, garej, MarcoB, Öskå, Michael E2
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to Mathematica.SE! What is p in your first function? I get error about non-numerical values, as it is obiously the case with p being a Symbol. – Alx Jul 20 at 7:24
• If I just Integrate[Rxxnavg[0, t, 0],t] I get -1. ArcSinh[2. t] - 2. p ArcTan[(2. p t)/Sqrt[0.25 + p^2 + t^2]] - 1. Log[t + Sqrt[0.25 + p^2 + t^2]], looks like this integral diverges. Mathematica says that definite integral from 0 to Infinity does not converge on {0,\[Infinity]}. – Alx Jul 20 at 7:32
• Woops I forgot to add p, p <<1, i've set it was 0.03. – user217 Jul 20 at 7:49
• Now I get your errors, I think this means the integral diverges, probably something is wrong with functions, some typo etc., you should make a ckeck. – Alx Jul 20 at 7:58
• The integral doesn't converge, not much to do then. – rhermans Jul 20 at 10:47

MMA says the integral diverges for real $$p$$, like this:

r1 = (p^2 (a - b))/(Sqrt[(a - b)^2 + t^2 + p^2] ((a - b)^2 +
t^2)) + (a - b)/Sqrt[(a - b)^2 + t^2 + p^2] + (a - b)/
Sqrt[(a - b)^2 + t^2];

r2 = ( (r1 /. b -> 1/2) - (r1 /. b -> -1/2) )*Cos[k t];

r3 = r2 /. k -> 0 /. a -> 0;

s = Integrate[r3, {t, 0, τ}, Assumptions -> {τ > 0, Im[p] == 0}];
s // TeXForm


$$-\frac{1}{2} \log \left(\frac{4 \tau \left(\sqrt{4 p^2+4 \tau ^2+1}+2 \tau \right)+4 p^2+1}{4 p^2+1}\right)-\\2 p \tan ^{-1}\left(\frac{2 p \tau }{\sqrt{p^2+\tau ^2+\frac{1}{4}}}\right)-\sinh ^{-1}(2 \tau )$$

And then, Limit[s, τ -> ∞]` evaluates to $$-\infty$$.

• Looks like I'll have to follow up with my professor. Thanks for this. – user217 Jul 21 at 5:34