MathGroup Archive 2014

[Date Index] [Thread Index] [Author Index]

Search the Archive

Pure functions vs rule based functions inside NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132262] Pure functions vs rule based functions inside NIntegrate
  • From: Yi Wang <tririverwangyi at gmail.com>
  • Date: Sun, 26 Jan 2014 03:14:41 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Hello,

As I was told, only pure functions can be compiled. Also, NIntegrate or NDSolve first compiles a function before doing numerical operations. Thus, I would have expected that using pure functions in NIntegrate or NDSolve could be faster than rule based functions.

However, in tests I didn't find such a difference. For example,

f1[x_, y_] := Sin[Sin[x Sin[y]]];
AbsoluteTiming@NIntegrate[f1[x, y], {x, 0, 100}, {y, 0, 100}]

and

f2 = Sin[Sin[#1 Sin[#2]]] &
AbsoluteTiming@NIntegrate[f2[x, y], {x, 0, 100}, {y, 0, 100}]

takes about the same time. How can I tell if both are compiled, or neither, and why?

Thanks!
Yi



  • Prev by Date: Need Help With Locator in a Manipulate
  • Next by Date: How Can I Change the Appearance of a Locator in Manipulate
  • Previous by thread: Re: Need Help With Locator in a Manipulate
  • Next by thread: Re: Pure functions vs rule based functions inside NIntegrate