1
$\begingroup$

I have the following code to evaluate the double integral of which the integrand contains summations.

a = 1.1798710705178221747709894550582188967078238417029640017201995589\
3552025364542807472418914015859414022112280461408148970194496741533076\
882157607415223127492391019655558195361182929703459`158.\
94383771058207*^12;
b = 2.26562500;
c = 1.81505148861869`*^-11;
d = 23.662621294619998242971428558039280847039065920403134745951781161\
6604691248947208857758189787681405721656941282488226858308051995862227\
03295794982365258929783937779449526906107493517940605539567`157.\
52081186501843;
f = 3.9762816693358413444242383928332521659243792714105963808597582172\
1677895928488587525623222082345413892578490996192857648555810218065386\
055620034160228548784193009119494778657256763`157.54308182919476*^-13;
g = 3.1306512217343699049816678338611844042940126102861569115946355055\
2379739233549991684436932580097276616360046758705039003579253070583704\
87306284924487233677956546263347280851687424`154.55339124819713*^-283;
h = 0.4663677854613281996964274099654771725449995576718401982649626901\
4979290048497524493727931929716644258598652635846126429619061653535457\
7552234258390027879122494699655811617457309249292766647653`158.\
10068151409945;
k = 1.7400621010179746539715325376531540776673407694803313887835074772\
7621820290231417060167325520004426731623808979659285973341841054088991\
377348701663084581319054270584192856482987849`158.6501729599253*^-13;
L = 12;
p = 1.7267086550014064377504396122758581898174212801982663320383980364\
4189130935666171318482175845230982997098739340274603421154239660049599\
7742129919272319043201530223139294218906027174185411646792`156.\
9155606199771*^-19;
m = {193.1974795021252244647940778330697265346831202988930438449952777\
2307847128160223047093925434704114309184915713826376925945458184231453\
466263054478004310746486964933973801043322`148.30510799763482, \
-1.9831415769102246753169203737597186440257929720747405282387824878992\
6107613692269553118408251584641941543185280916783314001387339467872143\
8413408725537146318896037644145`148.23545499521762*^14, 
   9.27130443465927962680463415680935518438025048895563739033406430779\
2196012034144989441708086252518980765588393670969227402958335184629953\
81754195556168420354856191202632726995515843`148.1802144267804*^25, \
-2.5800039865768300579393918422060974207019853041395228305982709910784\
5385543803983822395718755270344540849858353480555085709766499883993525\
5692481465734198491137803554398276`148.1336524600536*^37, 
   4.74051682958982877757253604628388253288384781482056602069781764081\
9228970772949442973000148032178390675200697268768942345714056423740914\
80354727904019873987134563343319805735897818842`148.09340643440623*^\
48, -6.045696336170963761979351988393444721239513638248359564313546590\
9718715772107181860271630911859080048890550740293482441710924532226834\
88785001561949827887583104602354991010789`148.05796717887392*^59, 
   5.48169129849067708749576724703553417939408966217748199411635112509\
3975998785626154086737477706943924734870295242554891109862338634996706\
52881122759735494841981860519139551755923247573972`148.02635144833272*^\
70, -3.558859598535019932696238577795555409895936844852263611105033721\
0375255058472565008180720204152692875351619018996231358541261075464815\
50993035152346687208320263348602766130493464`147.99786882797923*^81, 
   1.64170225303118668483536395284823903373718786459586837660122032491\
6095608079033229473848757844731529141963765405064759781082803855127965\
2691286574811194198800983167974295`147.97199851695797*^92, \
-5.2480764106579160571712590401723827187713866001169686217276690968556\
0720450830001550831782374704062930304936342651979107670945180568135634\
934777787696977134688463363076848049109484`147.94833381460728*^102, 
   1.10376762837378400256596151856877143314949611822933817186964398056\
6513468174587221258709945187779831909161277645871738123234551311287274\
78355158886780258679136222861840141`147.92655298710872*^113, \
-1.3717147483659623561567398067035113741497860704561052158773749470395\
4451131015780543446068263484385374754209550914285685014429230059159675\
6883122631756455319026263237240593696821711`147.9063994508292*^123, 
   7.62038321127089845343261988865253586612439689357390721954186078231\
7745858168312353448416091122119241968300105088661006951809593285174538\
28785418554487594420138798900387611`147.8876665311791*^132};
n = {1.355573243087520514288089562497260829417934974879258545226394709\
1581632390251949362448991535838854387828992200011014212046924115116342\
36774361520751754411719411168290762941843303838260921034729`154.\
7068137372351, \
-1.0245928740767489003861056984284775651988428602209840685472503196463\
8795930234592796835719935424571882137914261342592202874852760076112574\
416630451012360208651254471215128194043516110717`153.94630606168067*^\
13, 8.9274486445716723149532799214464202934486639009370371697876732811\
7309338540881124740225222195651232772519644118676062290969039522944619\
182163951555475885638710858185564149165684843`153.80921876999915*^25, \
-3.6759676683395569226361903550968200824615587798139936187422973093672\
7524993405149619110906669196324634865139505465691286936359213505175950\
82648234290038347371835858805085681`153.70951619258835*^38, 
   8.46890235524130159449486145084290474315429938343042316420562067986\
2851660903090850781750760926753333681142269036924244448156733221457952\
7284650316472932006583589556818127479776452351575`153.63641768743574*^\
50, -1.183963727932234048419892914574504119691001960215443363374579536\
6221799023716788793836145690916125278181883509910251692260914506526151\
991183549806618069041478638356123410370047646`153.58049547400296*^63, 
   1.05061217672427573937875620745709379002627336725498531970829595877\
3024659127091166260173635393986216201350663927669330845944472454001554\
7653381517564746234073087737793092403156290468681009911`153.\
53584270924242*^75, \
-6.0584630947562597856380562413442419518448978885525607665447920472335\
7004600791968921362280443938576083533065571634125571548632808959929629\
790577441227915620375110110148244720464105958`153.4990714580894*^86, 
   2.28274980013156097133562209543324362618017404654189411106310354580\
1316698809067147502956432483851929920100534744472639286623024080167418\
0951137035977035828949374744764910684041`153.46810663882243*^98, \
-5.5393276975669543411312359391170032422891499208542799478529688449103\
0657737312682644055014461777520413955788265776706075897708285932473509\
487959913970225597988826267142550230756354142547`153.44158425404342*^\
109, 8.289929266459807127028509719838011396311076683133447742366507269\
1426222477306422877783169874953638427457706706377785690078513120930488\
09383654486564976662124022080955027406652237`153.41855789644956*^120, \
-6.9209387452305809520831335905017476070978872825599662420473808654194\
8931991860905633911584754872433560379615186289074673651242807441129188\
233340512050802389488222073074566318608837938629357`153.\
39834390904957*^131, 
   2.45300100486846411742403054500030433066570931665654433746550128485\
1080592792054839789289213596711427047642684395418250860055631043057336\
48562402527422622838036053732378834470177372`153.3804328940518*^142};
NIntegrate[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(98\)]\(
\*FractionBox[\(
\*SuperscriptBox[\((a*x + b)\), \(i\)]*
     Exp[\(-\((a*x + b)\)\)]\), \(i!\)] \(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(L\)]
\*FractionBox[\(
\*SuperscriptBox[\((y + x - c)\), \(d\)] Exp[\(-\((y + x - c)\)\)/
         f] \((m[\([i + 1]\)] 
\*SuperscriptBox[\((y + x - c)\), \(i\)])\)\), \(g\)] \(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(L\)]
\*FractionBox[\(
\*SuperscriptBox[\(y\), \(h\)] Exp[\(-y\)/k] \((n[\([i + 1]\)] 
\*SuperscriptBox[\(y\), \(i\)])\)\), \(p\)]\)\)\)\), {x, c, 
  Infinity}, {y, 0, Infinity}, 
 Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 4000}, 
 MinRecursion -> 10, MaxRecursion -> 30]

However, I get two error messages, which are

  1. NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

  2. NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 4000 times. The global error is expected to decrease monotonically after a number of integrand evaluations. Suspect one of the following: the working precision is insufficient for the specified precision goal; the integrand is highly oscillatory or it is not a (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration. NIntegrate obtained 0.9999763600200141 and 0.0000461755863201869 for the integral and error estimates.

I have tried to increase MaxErrorIncreases to 20000. However, the above two error messages still exist. Why these errors happen? Is there a method to fix these issues?

Update:

NIntegrate[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(L\)]\(
\*FractionBox[\(
\*SuperscriptBox[\((y + x - c)\), \(d\)] Exp[\(-\((y + x - c)\)\)/
       f] \((m[\([\)\(i + 1\)\(]\)] 
\*SuperscriptBox[\((y + x - c)\), \(i\)])\)\), \(g\)] \(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(L\)]
\*FractionBox[\(
\*SuperscriptBox[\(y\), \(h\)] Exp[\(-y\)/k] \((n[\([\)\(i + 1\)\(]\)] 
\*SuperscriptBox[\(y\), \(i\)])\)\), \(p\)]\)\)\), {x, c, 
  Infinity}, {y, 0, Infinity}, 
 Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 4000}, 
 MinRecursion -> 10, MaxRecursion -> 30]
(*0.999976*)
(*NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.
NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 4000 times. The global error is expected to decrease monotonically after a number of integrand evaluations. Suspect one of the following: the working precision is insufficient for the specified precision goal; the integrand is highly oscillatory or it is not a (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration. NIntegrate obtained 0.9999763600200167` and 0.000046175586322940094` for the integral and error estimates.*)

Combine with the poisson pdf:

NIntegrate[
 SetPrecision[Sum[((a*x + b)^j*Exp[-(a*x + b)])/j!, {j, 0, 98}], 
   64] SetPrecision[
   Sum[(((y + x - c)^d*
         Exp[-(y + x - c)/f]*(m[[i + 1]]*(y + x - c)^i))/g)*
     Sum[(y^h*Exp[-y/k]*(n[[i + 1]]*y^i))/p, {i, 0, L}], {i, 0, L}], 
   64], {x, c, Infinity}, {y, 0, Infinity}, MinRecursion -> 3, 
 WorkingPrecision -> 32]
(*1.0000000030812388724654833722125*)
(*
NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 19 recursive bisections in y near {x,y} = {1.733749426269622122802915010608978488837265315801884727791202406575965983248912207*10^-9,1.610037995921788499566677793782828831793685299506806564866521408352787684409611295*10^-6}. NIntegrate obtained 1.000000003081238872465483372212524803405472370564982575528771716325065565992601043`82. and 2.937642115074185767546718140441621526496175969025481265504160565200333312980601489`82.*^-7 for the integral and error estimates.
*)

There are two errors after I combine with the poisson pdf. I have tried to increase the working precision and increase the MaxRecursion value. However, the errors still exist.

Update: The double integral of the same integrand and different intergral limits:

NIntegrate[
 SetPrecision[Sum[((a*x + b)^j*Exp[-(a*x + b)])/j!, {j, 0, 98}], 
   32] SetPrecision[
   Sum[(((y + x - c)^d*
         Exp[-(y + x - c)/f]*(m[[i + 1]]*(y + x - c)^i))/g)*
     Sum[(y^h*Exp[-y/k]*(n[[i + 1]]*y^i))/p, {i, 0, L}], {i, 0, L}], 
   32], {x, -Infinity, c}, {y, -(x - c), Infinity}, MinRecursion -> 3,
  WorkingPrecision -> 16]
(*
NIntegrate::inumri: The integrand (2.7182818284590450000000000000000^(-2.265625000000000-1.179871070517822*10^12 x)+2.7182818284590450000000000000000^(-2.265625000000000-1.179871070517822*10^12 x) (2.2656250000000000000000000000000+1.1798710705178220000000000000000*10^12 x)+<<48>>+<<49>>) (<<1>>) has evaluated to Overflow, Indeterminate, or Infinity for all sampling points in the region with boundaries {{0,0.1250000000000000},{0,0.1250000000000000}}.
*)

Why this warning message appears and how to fix this problem?

$\endgroup$
2
  • $\begingroup$ It seems that the true value of your integral could be zero. In these conditions NIntegrate will struggle to meet the default precision goal. Set an explicit finite accuracy goal instead, by adding e.g. AccuragyGoal -> 10. $\endgroup$
    – MarcoB
    Jun 3, 2020 at 13:57
  • $\begingroup$ Thank you for your reply! However, the true value is not zero. The first summation is the poisson pdf and the second and third summation are another pdf. Based on this observation, I guess the true value may around 1. The error may originate from the second and third summation. Since after I take out the poisson pdf, the errors still exist! I have put the calculation results in the question. $\endgroup$ Jun 4, 2020 at 1:22

1 Answer 1

1
$\begingroup$

Use higher working precision:

NIntegrate[SetPrecision[
     Sum[(((y + x - c)^d*Exp[-(y + x - c)/f]*
               (m[[i + 1]]*(y + x - c)^i))/g)*
         Sum[(y^h*Exp[-y/k]*(n[[i + 1]]*y^i))/p, 
           {i, 0, L}], {i, 0, L}], 32], 
   {x, c, Infinity}, {y, 0, Infinity}, 
   MinRecursion -> 3, WorkingPrecision -> 16]
(*  0.9999995560228801  *)
$\endgroup$
1
  • $\begingroup$ Many thanks! The second error is well solved by using higher working precision. However, after I multiply the poisson pdf to the integrand, two errors occur. The calculation results are updated in the question. $\endgroup$ Jun 4, 2020 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.