I have a very complicated pair of functions $F(x,y), G(x,y)$ that are used in a differential equation $0 = x'' + F(x,y)$, $0 =y '' + G(x,y)\,. $ $F$ and $G$ are roughly sums of products of the Bessel functions $J_n(x) J_m(y)$. In a differential equation, it is very costly to have to recompute the sum of these special functions at each step. Is there a way to make this process more efficient? I would like, for example, to precompute an interpolating function for use in NDSolve but I find NDSolve has trouble with these types of functions.
1 Answer
NDSolve
does not have problems with interpolating functions. Not from my experience at least. Can you post an example where you run into problems?
A few other thoughts:
- Are you by any chance using
BesselJZero
in $F$ and $G$ (BesselJZero
is even slower thanBesselJ
) - Bessel functions have other parametrizations which you could try
- Try using
Compile
- Check this question: How to improve performance of BesselJ to the level of GSL?
Method->"Splines"
it typically works well theNDSolve
from my limited experience. $\endgroup$