Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Pure functions vs rule based functions inside NIntegrate
Replies: 1   Last Post: Jan 28, 2014 6:08 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yi Wang

Posts: 33
Registered: 3/30/12
Pure functions vs rule based functions inside NIntegrate
Posted: Jan 26, 2014 3:05 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.