I have a system of differential equations and need to calculate the Jacobian. The code below throws AttributeError: 'list' object has no attribute 'ravel'
. What am I missing?
import numpy as np
import numdifftools as ndt
def rhs(z, t=0):
x,y = z
xdot = (x/5 + y)*(-x**2+1)
ydot = -x*(-y**2+1)
return [xdot, ydot]
Jfun = ndt.Jacobian(rhs)
Jfun([1,1])
Just do:
return np.array([xdot, ydot])
instead. This should work...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With