Skip to main content

differential equations - How to make use of an interpolating function outside of Mathematica?



I'm currently working on a project where I have to solve some partial differential equations. Initially, I made some approximations so that an analytic solution could be obtained, and my C++ code is set up using values calculated from the analytic expression.


I've now used Mathematica to obtain a numerical solution (using NDSolve), and would like to be able to use the values in the C++ code instead of the analytic expression. What would be the best way to approach this? (I don't want to use a C++ PDE solver, because even setting up the PDEs took a large amount of algebraic manipulation which I had to do with Mathematica).



Any help would be greatly appreciated!


EDIT: Thanks for the suggestions. So you think the best route would be to essentially generate a grid and export it? I would need to be able to evaluate for values in between those which are exported though (chosen at random), and so I suppose I would then have to write my own interpolation scheme.


EDIT: Thanks George, that seems a good way of approaching it. I should have mentioned earlier the functions are functions of two variables, but your method should be adaptable.




Comments