TransWikia.com

How to eliminate error: Numerical integration converging too slowly

Mathematica Asked by Arghya Datta on February 9, 2021

While doing numerical integration, I am getting a result with the following error messages:

NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x1 near {x1} = {1.01524}. NIntegrate obtained 12433.33691256442` and 2169.647710597512` for the integral and error estimates.
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x1 near {x1} = {1.01562}. NIntegrate obtained 24157.820549928372` and 12118.146798980437` for the integral and error estimates.

I have tried to increase/decrease the AccuracyGoal, and every time I am getting these errors.

How can I resolve this problem?

Following is the code:

a = {1, 1.000030, 1.000033};
b = {5.58643*10^-12, 9.41267*10^-14, 1.42653*10^-14};
c[x_]:= Table[(x-a[[j]])/((x-a[[j]])^2+ a[[j]]b[[j]]),{j,1,3}];

Table[NIntegrate[(a[[j]]/x) * ((x/a[[j]]) + (x*c[x][[j]]) + (x^2/2)*c[x][[j]]^2) * BesselK[1,Sqrt[x]],{x,0,inf},MinRecursion-> 4,AccuracyGoal-> 5],{j,1,3}]

2 Answers

I have tried to increase/decrease the AccuracyGoal, and every time I am getting these errors.

The messages hint to also consider setting relevant values for PrecisionGoal and/or MaxRecursion.

Here is an example:

Clear[a, b, c]
a = {1, 1.000030, 1.000033};
b = {5.58643*10^-12, 9.41267*10^-14, 1.42653*10^-14};
c[x_] := Table[(x - a[[j]])/((x - a[[j]])^2 + a[[j]] b[[j]]), {j, 1, 3}];

Table[NIntegrate[(a[[j]]/x)*((x/a[[j]]) + (x*c[x][[j]]) + (x^2/2)*c[x][[j]]^2)*
   BesselK[1, Sqrt[x]], {x, 0, Infinity}, 
  MaxRecursion -> 40, 
  PrecisionGoal -> 4, 
  AccuracyGoal -> 5], 
{j, 1, 3}]

enter image description here

Answered by Anton Antonov on February 9, 2021

Let us first simplify the expression under the integral:

expr[j_,x_]:=(a[[j]]/x)*((x/a[[j]]) + (x*c[x][[j]]) + (x^2/2)*c[x][[j]]^2)*
  BesselK[1, Sqrt[x]] // Simplify;

And now let us evaluate the integrals

AbsoluteTiming[
 NIntegrate[expr[1, x], {x, 0, [Infinity]}, MinRecursion -> 4, 
  AccuracyGoal -> 5]]

(* {0.06447, 200011.}  *)

AbsoluteTiming[
 NIntegrate[expr[2, x], {x, 0, [Infinity]}, MinRecursion -> 7, 
  AccuracyGoal -> 5]]

(* {3.07002, 1.54089*10^6} *)

AbsoluteTiming[
 NIntegrate[expr[3, x], {x, 0, [Infinity]}, MinRecursion -> 8, 
  AccuracyGoal -> 7]]

(*  {6.28732, 3.95812*10^6}  *)

Have fun!

Answered by Alexei Boulbitch on February 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP