I have a huge "black-box" f
function, which I want to integrate. Let's define it:
f[x_,y_,a_]:=a*Exp[-(a*10000)(x^3+y^3)]
as a simple toy model. My real function takes many parameters and impossible to write in closed form like a Exp
function. But the behavior is similar to this toy model function. So, the main idea is f[x,y,a]
returns a 'number'.
This function has a very sharp peak which I don't know where. Other than this peak, function is zero. Let's pretend that we don't know the peak at x=0
y=0
in this toy model. I am trying to integrate it but NIntegrate
missed the peak with some methods.
NIntegrate[f[x,y,2.],{x,-5.,5},{y,-5.,5.},Method->{"GlobalAdaptive","SymbolicProcessing"->False}]
So, I am integrating it with NDSolve
. The simplified code I use is:
eqn = {D[u[x,y],x,y] == f[x,y,2.], u[x,-5] == 0, u[-5,y] == 0}
NDSolve[eqn,u,{x,-5,5},{y,-5,5}]
However, while executing the declaration of function (eqn
line), Mathematica tries to execute this function symbolically, which takes very long time. Is there a way to avoid handling the function symbolically so that the function at line eqn
will return just a number whenever it is called?
(Similar to "SymbolicProcessing->False"
at NIntegrate
.)
Comments
Post a Comment