I have this integrand given by tinteg[z,zm,zh] where I want to integrate it in the range [0,zh]. However, the integrand is divergent at zh so I added a small parameter eps away from zh so that the integral range is now [0,zh+eps]. Doing this, I can then take the principal value of the integral for some eps.
d = 3;
ag = 20;
pg = 20;
wp = 40;
f[z_, zh_] := 1 - (z/zh)^(d + 1);
tinteg[z_, zm_, zh_] := -1/(f[z, zh] Sqrt[1 - (zm^(2 d) f[z, zh])/(z^(2 d) f[zm, zh])])
th[eps_?NumericQ, zh_?NumericQ] := Module[{epsr, zhr}, {epsr, zhr} = Rationalize[{eps, zh}, 0]; NIntegrate[tinteg[z, zhr + epsr, zhr], {z, 0, zhr, zhr + epsr}, Method -> PrincipalValue, AccuracyGoal -> ag, PrecisionGoal -> pg, WorkingPrecision -> wp]]
th[10^-9, 100]
0.0003162277660196573967272197281906499
th[10^-10, 100]
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in z near {z} = {99.9999999998213805278900613760597337931183240142657527684191416030996934771392010899316650}. NIntegrate obtained -57.3106917390753700387564367567637817259282112119845402535003746786552197747577990043682551 and 1.85452812514993194537323109011792300865115544959913889998941281161057638475694312252915879`90.*^-10 for the integral and error estimates.
0.0001000000000000889405834231780766118
th[10^-15, 100]
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in z near {z} = {99.9999999999997866007398081727804784995174546220786282909845407978056563093393638396629520}. NIntegrate obtained -57.3107914228724344179090132179535225292646529296309563458710154094184035242065488421646708 and 0.000096232917814206821120246506287335370896029249848796293573094556559070111933328788951276428`90. for the integral and error estimates.
3.161570082363756029776335213343*10^-7
The problem is, as I take eps to be smaller and smaller it will reach a point where error occurs which is related to convergence issues. For eps=10^-9, I can still get a result without error. However, for eps=10^-10 error already occurs.
I have set the corresponding AccuracyGoal,PrecisionGoal,WorkingPrecision to try and go over this problem however it seems not to be working. I think the smallest eps that I might need is around eps=10^-15 in order to justify the accuracy of what I'm doing, so if I can just push the convergence to this limit then everything will be good.
[0,zh]limits why do you expand the integration domain and to[0,zh+eps], wherezh>0andeps>0and take the principal value? These two are not equivalent. It does make sense mathematically. – yarchik Aug 08 '21 at 05:53zh. So I added an extremely small parametereps, say,eps=10^-10. Then I would say it is approximately the same as the original integral to some toleranceeps. The integrand diverges from below for less thanzhand diverges from above for greater thanzhso they cancel nearzhso I can take the principal value. – mathemania Aug 08 '21 at 07:32[0,zh+eps]originally then I just want to have convergence as I makeepssmaller, say,eps=10^-15. – mathemania Aug 08 '21 at 10:24