Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Another option is to use splines to approximate the curve. Here is some code inspired by https://stackoverflow.com/questions/31543775/how-to-perform-cubic-spline-interpolation-in-python

var('t y z')
P=desolve_system_rk4([z,-z^2*(-2+t/(1+t))-y],[y,z],ics=[0.1,10,2],ivar=t,end_points=100)
Q=[ [float(t1),float(z1)] for t1,y1,z1 in P]
x_points=([p[0] for p in Q])
y_points=([p[1] for p in Q])
tmp = interpolate.splrep(x_points, y_points)
f=lambda x: interpolate.splev(x, tmp)

You could then find a zero using:

find_root(f,12,20)

Also, you can compute the derivative using:

g=lambda x: interpolate.splev(x, tmp,der=1)

Then, find potential extrema using find_root.