Re: Re: Message: "Numerical interation converging too slowly"
- To: mathgroup at smc.vnet.net
- Subject: [mg83311] Re: [mg83263] Re: Message: "Numerical interation converging too slowly"
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Sat, 17 Nov 2007 05:23:05 -0500 (EST)
- References: <fhh7h5$8p4$1@smc.vnet.net> <473C8ACF.80000@gmail.com> <5270064.1195230612282.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
Version 6.0.1 has no problem with this, but for either version I'd suggest
a different approach:
lst = {{0, 0.0673209172484956`}, {0.003449278068524249`,
0.10109827933089396`}, {0.014031516572727063`,
0.19966139796005267`}, {0.04649737451028208`,
0.2870434103185859`}};
{lo, hi} = lst[[{1, -1}, 1]];
linN = Interpolation[lst, InterpolationOrder -> 1];
Clear[integral]
integral =
integral /.
First@NDSolve[{integral'[s] == linN[s], integral[lo] == 0},
integral, {s, lo, hi}];
Plot[integral[z], {z, 0, 0.045}]
Bobby
On Fri, 16 Nov 2007 04:33:17 -0600, Hoa Bui <hoabui05 at gmail.com> wrote:
>
> Thanks, Jean-Marc!
> Yes, I am using Mathematica 5.2 and I did get the same graph except
> that it goes along with the message previously mentioned.
>
> Also, check this out:
>
> It is okay to integrate from the first to the last point:
> In[89]:=NIntegrate[linN[s],{s,lst�1,1�,lst�4,1�}]
> Out[89]=0.00978246
>
> But if I do the same with a different set of points:
> lst2 = {{0, 0}, {0.005117241776887967`, 0.12109827984374989`}, \
> {0.015699480276911173`, 0.159661398624297`}, {0.04816533822543266`, \
> 0.2770434111412446`}}
> In[91]:=lin=Interpolation[lst2,InterpolationOrder\[Rule]1];
> In[92]:=NIntegrate[lin[s],{s,lst2�1,1�,lst2�4,1�}]
> I get another weird message:
> "NIntegrate::ncvb : NIntegrate failed to converge to prescribed
> accuracy after 7 recursive bisections in s near s 0.005079938015963601`.
> More... "
> Out[92]=0.00888437
>
> I have no idea what's going on here! Please help!
> Thanks,
> HB
>
>
>
> On 11/15/07, Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com> wrote:
>> Hoa Bui wrote:
>> > Hi all,
>> >
>> > Please help!
>> >
>> > I have a list of points:
>> >
>> lst={{0,0.0673209172484956`},{0.003449278068524249`,0.10109827933089396`},{\
>> > 0.014031516572727063`,0.19966139796005267`},{0.04649737451028208`,0.\
>> > 2870434103185859`}}
>> >
>> > I then define a function NN[x] that returns the linearly interpolated
>> > value at x:
>> > linN = Interpolation[lst, InterpolationOrder -> 1];
>> > NN[x_?NumberQ]:=linN[x];
>> >
>> > In[17]:=NN[0]
>> > Out[17]=0.0673209
>> >
>> > In[18]:=NIntegrate[NN[s],{s,0,0.45}]
>> > Out[18]=0.344713
>> >
>> > However, if I want to make the integral a function of the upper limit,
>> > and plot it:
>> > Plot[NIntegrate[NN[s],{s,0,z}],{z,0,0.045}],
>> > I get this 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."
>> >
>> > Maybe there's nothing wrong with the result, but I'm not sure. And the
>> > message is annoying, too.
>> > Does anyone know how to make Mathematica do the work without
>> complaining?
>> >
>> > I appreciate it.
>> > HB
>> >
>>
>> Hum, the posted code works fine (i.e. no warning nor error messages are
>> issued) with Mathematica 6.0.1. I have uploaded the following pdf on my
>> web site so you can check the graph produced by your version against
>> version 6:
>>
>> http://homepages.nyu.edu/~jmg336/mathematica/HoaBuiIntegration.pdf
>>
>> (Sorry, I am away from my machine with version 5.2 installed, so I
>> cannot investigate further.)
>>
>> Regards,
>> --
>> Jean-Marc
>>
>
>
--
DrMajorBob at bigfoot.com