Re: NIntegrate Confusion

*To*: mathgroup at smc.vnet.net*Subject*: [mg109744] Re: NIntegrate Confusion*From*: Andrew Moylan <amoylan at wolfram.com>*Date*: Fri, 14 May 2010 08:28:11 -0400 (EDT)

By default NIntegrate seeks a result with a sufficiently small *relative* error (PrecisionGoal). Some of your integrals have 0 as the true integral, for which relative error is not meaningful. NIntegrate repeatedly subdivides but never obtains an error estimate sufficiently small compared with the integral estimate. It is similar to this example: In[9]:= NIntegrate[0, {x, 0, 1}] During evaluation of In[9]:= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x near {x} = {0.666031}. NIntegrate obtained 0.` and 0.` for the integral and error estimates. >> Out[9]= 0. In cases where the correct value of your integral might be 0, you should set the AccuracyGoal option, which specifies an acceptable *absolute* error (independent of the size of the integral). AccuracyGoal -> 6 specifies that 10^-6 is an acceptably small absolute error. In[12]:= NIntegrate[0, {x, 0, 1}, AccuracyGoal -> 6] Out[12]= 0. I suggest Adding AccuracyGoal -> 10 to your example. As Bob Hanlon suggested, you can also use Chop[...] to tidy up the numerical results. Andrew Moylan Wolfram Research On 4/14/2010 7:16 PM, sukhrob wrote: > Hi everybody, > I'm using Mathematica 7.0 , i would like integrate numerically something > like Fourier coefficients, my programe code contains: > > M = 50; f[t_] = 100 Sin[5 t]; > > basis = Table[Sin[n t], {n, 1, M}]; > > coef = 2/Pi*Table[NIntegrate[f[t] Sin[n t], {t, 0, Pi}], {n, 1, M}] > > in result it gives : > > NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after > 9 recursive bisections in t near {t} = {2.47283}. NIntegrate obtained > -3.88578*10^-15 and 7.654706546923104`*^-15 for the integral and error > estimates.>> > NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after > 9 recursive bisections in t near {t} = {2.47283}. NIntegrate obtained > -3.19189*10^-15 and 1.8799124112361456`*^-14 for the integral and error > estimates.>> > > NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after > 9 recursive bisections in t near {t} = {0.00254055}. NIntegrate obtained > 1.2045919817182948`*^-14 and 9.105942246869344`*^-13 for the integral and > error estimates.>> > > General::stop: Further output of NIntegrate::ncvb will be suppressed during > this calculation.>> > > Can anyone help me to solve that problem. Any help would be very much > appreciated. > Thanks in advance > Sukhrob >