Re: NIntegrate Confusion

• To: mathgroup at smc.vnet.net
• Subject: [mg109161] Re: NIntegrate Confusion
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Wed, 14 Apr 2010 23:12:19 -0400 (EDT)

```M = 50;
f[t_] = 100 Sin[5 t];

basis = Table[Sin[n t], {n, 1, M}];

Do it exactly

coef = 2/Pi*Table[
Integrate[f[t] Sin[n t], {t, 0, Pi}],
{n, 1, M}]

{0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

coef = 2/Pi*Table[
NIntegrate[f[t] Sin[n t], {t, 0, Pi}],
{n, 1, M}] // Quiet // Chop

{0,0,0,0,100.,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

% == %%

True

Bob Hanlon

---- sukhrob <suhrob84 at bk.ru> 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.
Sukhrob

--
View this message in context: http://old.nabble.com/NIntegrate-Confusion-tp28239593p28239593.html
Sent from the MathGroup mailing list archive at Nabble.com.

```

• Prev by Date: Re: Equation problem
• Next by Date: Re: How to dynamically build a list of rules
• Previous by thread: NIntegrate Confusion
• Next by thread: Re: NIntegrate Confusion