# NDSolve much slower when using InterpolatingFunctions inside

I am solving an ODE system with Mathematica. Let's say the system is of the form (to simplify).

sol = NDSolve[{x'[t] == f[t] x[t] + g[t], x[0] == 0}, x, {t, 0, 1}]


The functions f[t] and g[t] are obtained from a different program. I either use a simple fit for f[t] and g[t] (say polynomial) or define them as InterpolationFunctions from data tables I have, i.e.

f = Interpolation[data]


In the latter case (which is more desirable as more accurate), the system takes 10 times longer to solve!

In detail, I actually loop over NDSolve for several additional parameters, and my ODE is with complex coefficients and 6-dimensional. So the system is already kind of long to solve, and 10 times longer is killing me...

Anyone has any advice on how to speed this up? Interpolating functions should be super fast, shouldn't they?

-
To actually try to speed up your code people need to see it - what I am saying is that it is useful to post a minimum working example that illustrates the problem :) –  Sektor Sep 13 '13 at 23:18

The InterpolatingFunction[] calc time is highly dependent on the number of points you use:
f[t_] := 1 + t + t^2;