I have numerically integrated a system of differential equations and now want to invert the solution in order to use it later in my code. Any help will be greatly appreciated.
System of differential equations:
def evolution(a,z):
w=0
q,y,h,v,x=a
dq = -(2*q**2+q-1)/(z+1)
dx = -(-x*(x-q)+2*(x+q)-3*(-v+x+q)+2)/(z+1)
dy = (2*q**2+q-1)/(z+1)
dv = (-x*(x-q)+2*(x+q)-3*(-v+x+q)+2+(-v+x+q)*(x-2*q+1)+2*q**2+q-1)/(z+1)
dh=h*(1+q)/(z+1)
dadt = [dq,dy,dh,dv,dx]
return dadt
Initial conditions: (Note that I take the initial conditions at z=20 and integrate backwards)
x0=0
h0=54.0176
q0=0.499
y0=1-q0
v0=0.5
N=3000
t=np.linspace(20.0,0.0,N)
a0=[q0,y0,h0,v0,x0]
sol=odeint(evolution,a0,t)
plt.plot(t,sol[:,1])
plt.show()
I am essentially plotting y=R(z) and want to get z(R) so that I can solve the differential equation v(z(R))=f/f'(R) i.e. get f(R)