Re: NIntegrate problem
- To: mathgroup at smc.vnet.net
- Subject: [mg27819] Re: NIntegrate problem
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Mon, 19 Mar 2001 01:29:10 -0500 (EST)
- References: <98vh78$8t6@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Martin,
I can't tell you what the problem is, but below I get the same answer
without warning messages by making some adjustments.
The problem seems to lie at about t = 2/3.
SeasonTab={{0/12,-0.5},{1/12,-.2},{2/12,-0.5},{3/12,-0.5},{4/12,0.-.25},{5/1
2,
0.1},{6/12,0.5},{7/12,0.7},{8/12,
1.1},{9/12,-0.3},{10/12,-0.7},{11/12,-0.6},{12/12,-0.5}};
SeasonFunction=
Interpolation[SeasonTab,PeriodicInterpolation->True,
InterpolationOrder->3];
NIntegrate[SeasonFunction[t]*Cos[2*Pi*t],{t,0,1}]
[messages
NIntegrate::slwcon: Numerical integration converging too slowly; suspect
one \
of the following: singularity, value of the integration being 0, oscillatory
\
integrand, or insufficient WorkingPrecision. If your integrand is
oscillatory \
try using the option Method->Oscillatory in NIntegrate.
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after
\
7 recursive bisections in t near t = 0.66796875`.
]
-0.283902
Here I respond to the first message by changing the range of integration to
[0.1, 1.1] (noting the periodicity)
and to the second message by increasing MaxRecursion.
NIntegrate[SeasonFunction[t]*Cos[2*Pi*t],{t,0.1,1.1},
MaxRecursion -> 7
]
-0.283903
For a second attempt I increase the GuassPoints
NIntegrate[SeasonFunction[t]*Cos[2*Pi*t],{t,0.,1.},
GaussPoints->25
]
-0.283903
The following seems to localize the problem
NIntegrate[SeasonFunction[t]*Cos[2*Pi*t],{t,.62,.7}
]
[message:
NIntegrate::slwcon: Numerical integration converging too slowly; suspect one
\
of the following: singularity, value of the integration being 0, oscillatory
\
integrand, or insufficient WorkingPrecision. If your integrand is
oscillatory \
try using the option Method->Oscillatory in NIntegrate.
]
-0.0426937
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Martin Richter" <mrMICE.fi at cbs.dk> wrote in message
news:98vh78$8t6 at smc.vnet.net...
> Hi
>
> I'm trying to integrate a simple function, defined as follows:
>
> SeasonTab = {{0/12, -0.5}, {1/12, -.2}, {2/12, -0.5}, {3/12, -0.5}, {4/12,
> 0. - .25}, {5/12, 0.1}, {6/12, 0.5}, {7/12, 0.7}, {8/12,
> 1.1}, {9/12, -0.3}, {10/12, -0.7}, {11/12, -0.6}, {12/12, -0.5}};
> SeasonFunction =
> Interpolation[SeasonTab, PeriodicInterpolation -> True,
> InterpolationOrder -> 3];
> NIntegrate[SeasonFunction[t]*Cos[2*Pi*t], {t, 0, 1}]
>
> I think I have tried every setting in NIntegrate.
>
> The function SeasonFunction[t]*Cos[2*Pi*t] is of course not C\infinity but
> it should not give any problems. So at the moment I'm just ignoring
> the error message but if anyone could tell what this the problem is it
would
> be great.
>
> Martin
>
>
> NIntegrate::"slwcon": "Numerical integration converging too slowly;
suspect
> \
> one of the following: singularity, value of the integration being 0, \
> oscillatory integrand, or insufficient WorkingPrecision. If your integrand
> is \
> oscillatory try using the option Method->Oscillatory in NIntegrate."
>
>
> --
> ---------------------------------------
> Please remove PET to reply by email
>
>
>