Re: NIntegrate Confusion
- To: mathgroup at smc.vnet.net
- Subject: [mg109185] Re: NIntegrate Confusion
- From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
- Date: Fri, 16 Apr 2010 05:50:56 -0400 (EDT)
- References: <hq4152$3cp$1@smc.vnet.net>
I don't think you have a real problem. NIntegrate is doing a relative error check (by default), and when the answer is close to zero, this presents a divide by a small number problem. You can use absolute accuracy as the accuracy goal by specifying the number of decimal places accuracy you want. For example, with your problem, you can specify 12 place accuracy as follows: coef = 2/\[Pi] Table[ NIntegrate[f[t] Sin[n t], {t, 0, \[Pi]} , AccuracyGoal -> 12], {n, 1, M}] Kevin 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 >