How to use splines in substitutions
Hello. I'm working on geodesics on a manifold for which the metric functions are only given in terms of numerical functions. I obtained the approximations of the functions using splines, which work very well. When it comes time to substitute for the metric functions, however, I run into a problem.
Here's a minimal example that reproduces the problem: Make straight line spline:
spltest=spline([(0,0), (1,1), (2,2)])
Create expression:
eq(r) = 2 * function('nu')(r)
Substitute:
eq.subs({nu(r): spltest(r)})
which throws out errors:
TypeError: cannot evaluate symbolic expression to a numeric value
TypeError: unable to simplify to float approximation
When spline is replaced with a PolynomialRing.lagrange_polynomial, the substitution works fine, but Lagrange polynomials do not behave well with the form of the function I need, and therefore cannot be used in general.
Any advice for making numeric data work with equations?