I have a set of InterpolatingFunction returned by NDSolve which are valid over different (but overall continuous) domains. How do I splice them together into one single InterpolatingFunction over all the domains?
Piecewise seems to promising, but I can't manage to return the piecewise function from another function then use it later the same way as InterpolatingFunction.
I guess there is also the brute force way of generating a grid of points using the original set of InterpolatingFunction then interpolating points again, but that's very elaborate and CPU-consuming, not to mention potentially inaccurate if the interpolation grid is not chosen properly.
Thoughts?
Thanks to the answer from Mr. Wizard, this is the solution I ended up using:
JoinInterpolatingFunction[intervals_List, flist_List] :=
Module[{getGrid},
getGrid[f_InterpolatingFunction, min_?NumericQ,
max_?NumericQ] := {{min, f[min]}}~
Join~(Transpose@{f["Grid"] // Flatten, f["ValuesOnGrid"]} //
Select[#, (min < #[[1]] < max) &] & )~Join~{{max, f[max]}} // N;
Interpolation[
Table[getGrid[flist[[i]], intervals[[i]], intervals[[i + 1]]], {i,
Length@flist}] // Flatten[#, 1] & //
DeleteDuplicates[#, (#1[[1]] == #2[[1]]) &] &,
InterpolationOrder -> 2]]
JoinInterpolatingFunction[{I1,I2,..,In},{func1,func2,...func(n-1)}] gives an InterpolatingFunction that takes values of func1 between [I1,I2], func2 between (I2,I3], ... func(n-1) between (I(n-1),In].

