Re: compile a numerical integral
- To: mathgroup at smc.vnet.net
- Subject: [mg124576] Re: compile a numerical integral
- From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
- Date: Wed, 25 Jan 2012 07:05:37 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jflvvs$jr4$1@smc.vnet.net>
On Tue, 24 Jan 2012 10:09:00 -0000, Ruth Lazkoz S=E1ez <ruth.lazkoz at ehu.es> wrote: > Hi wise people, > > I am working to make a code faster using compile and failed at the very > beginning. > Is there a way to make a version that works? > > f=Compile[{u},NIntegrate[x*u,{x,0.,#}]&/@{1,2,3}] > > Best, > > Ruth Lazkoz > Sorry to disappoint, but no. NIntegrate cannot be compiled and, even if it could, it wouldn't provide any meaningful performance improvement (although sometimes the integrand can be compiled; if this is likely to be beneficial it will be done automatically, but you can try it manually using the option Compiled->True). However, one can often benefit by changing the Method option appropriately (see tutorial/NIntegrateIntegrationRules), although this can be quite involved and is obviously not a panacea. It is worth persisting, however: in an example from my own work, optimizing the Method yielded a fourfold reduction in calculation time versus the default setting when evaluating some complicated projection integrals, and I was only able to improve on this slightly (by another 40% or so) by pre-calculating the integration bounds analytically for special cases of the integrand instead of letting NIntegrate find the bounds itself.
- Follow-Ups:
- Re: compile a numerical integral
- From: Gabriel Landi <gtlandi@gmail.com>
- Re: compile a numerical integral