# Using interpolated curve on parametric plot

Hi,

my skills in numerics are very limited, thus maybe this is a silly question. Is it possible, in sage or python, to interpolate a numerical solution of a differential equation and use it as a symbolic expression? Let me explain my problem. I have the following differential equation and numerical solution

z = function('z')(x)
de = diff(z,x) == sqrt(-36*(2*x/sqrt(x^2 + 5) - (x^2 - 1)*x/(x^2 + 5)^(3/2))^2 + (x^2 + 5)/(x^2 - 1)^2)
var('nz')
de_sol = desolve_rk4(de.rhs(),dvar=nz,ics=[0,0],ivar=x,end_points=.93, step=.01)


I would like to use the above solution as z(x) and (at first) plot a parametric surface. For illustrating, I will use z = -log(1-x), that has a similar shape.

th = var('theta')
z = -log(1-x)
r = -6*(x^2 - 1)/sqrt(x^2 + 5)
parametric_plot3d([r*cos(th),r*sin(th),z],(th,0,2*pi), (x,0,.93))


I tried:

• spline: it fits greatly, but the output cannot be used as symbolic. Parametric plot is not allowed.
• lagrange_polynomial: it gives me a polynomial fit that can be used for parametric plot, but the interpolation fails "close" to the divergence at x=1.
• I've tried to follow this post, but 1) I didn't find out how to pass my de_sol to maxima (maxima('p:de_sol') doesn't work) and 2) I don't know how to turn the maxima charfun into sage piecewise. Maxima documentation doesn't help that much.

Any idea?

edit retag close merge delete