Re: NInegrate Bug
- To: mathgroup at smc.vnet.net
- Subject: [mg116526] Re: NInegrate Bug
- From: Gary Wardall <gwardall at gmail.com>
- Date: Fri, 18 Feb 2011 04:35:35 -0500 (EST)
- References: <ijispp$2dp$1@smc.vnet.net>
On Feb 17, 4:20 am, "Kurt TeKolste" <tekol... at fastmail.net> wrote: > Are the conditions under which the incorrect answer is returned known so > that a practitioner can implement a workaround of the form > > fixedNintegrate[function_,bounds_]:= > If[ conditions[function], > NIntegrate[function[t]*Sign[t],bounds],NIntegrate[function[t],bounds]] > > and be confident that one's analysis is not scrogged? > > Kurt TeKolste > > On Wed, 16 Feb 2011 04:36 -0500, "Andrew Moylan" <amoy... at wolfram.com> > wrote: > > > No, sorry. The fix is not available as a patch for version 7. > > > Andrew Moylan > > Wolfram Research > > > ----- Original Message ----- > > From: "Kurt TeKolste" <tekol... at fastmail.net> > > To: "Andrew Moylan" <amoy... at wolfram.com>, "Mathgroup" > > <mathgr... at smc.vnet.net> > > Sent: Tuesday, February 15, 2011 11:47:43 PM > > Subject: Re: NInegrate Bug > > > Comforting, but expensive. Do you have a patch for 7? > > > On Tue, 15 Feb 2011 23:17 +1100, "Andrew Moylan" <amoy... at wolfram.com> > > wrote: > > > Hi Kurt, > > > > You should not encounter any problem in Mathematica 8. E.g. > > > > In[1]:= NIntegrate[Sin[x^2], {x, -5, -2}] > > > > Out[1]= -0.276859 > > > > In[2]:= N[Integrate[Sin[x^2], {x, -5, -2}]] > > > > Out[2]= -0.276859 > > > > Andrew Moylan > > > Wolfram Research > > > > On Feb 15, 2011, at 10:34 PM, Kurt TeKolste wrote: > > > > > Has there been a resolution of the NIntegrate bug? > > > > > Apparently NIntegrate produces the negative of the right answer for > > > > integrations that start and end to the left of zero -- some of the time. > > > > (Cos[x] and Sin[x^2] get the wrong result, Sin[x] is good). > > > > > Since it is not clear what criterion Mathematica uses in deciding to > > > > give the wrong answer it is not clear when to use NIntegrate[] and when > > > > to use NIntegrate[*Sign[independent variable]]. > > > > > And this calls into question any results for analysis that uses > > > > NIntegrate -- not a happy situation. > > > > > Kurt TeKolste Kurt, Perfection is not guaranteed when working with people or people created things. Bugs, flaws and all other kinds of errors always creep in. The trick is to develop strategies to help one become cognizant of these errors. When working with numerical calculations a strategy that works well for me is to attack the problem from different and independent approaches. If I need to evaluate an integral numerically, say with NIntegrate in Mathematica, I will find an approximate function which I can integrate by hand or perhaps by using Integrate on Mathematica. With the approximate function it is usually pretty good and I would expect NIntegrate to yield a similar result. If NIntegrate's result is off then either I have bad approximate function, NItegrate is off, or perhaps both. Whatever, something is not right and more work needs to be done. By the way, I had a student a few years back, who did the same problem by the vary the same method three times, got the same answer each time and could not understand how his answer could possibly be wrong when he checked his twice and got the same answer on each of his checks. On every computer system, statistical software, spreadsheet, calculator or device I have ever used to do mathematical calculations always had some bugs with it. It's to be expected and needs to be dealt with. Good Luck Gary Wardall