[SciPy-user] Jacobian matrix
Nils Wagner
nwagner at mecha.uni-stuttgart.de
Thu Mar 17 10:59:25 CST 2005
Hi all,
Is there a simpler way (built-in function) to compute the Jacobian of a
vector function ?
How about higher order derivatives of vector-valued functions ?
from scipy import *
def f(x):
#
tmp = zeros(5,Float)
tmp[0] = x[0] + x[1] + x[2]**2 + x[3]**2 + x[4]**2 - 2
tmp[1] = x[0] - x[1] + x[2]**2 + x[3]**2 + x[4]**2
tmp[2] = -x[2]**2 + x[3]**2 + x[4]**2
tmp[3] = x[2]**2 - x[3]**2 + x[4]**2
tmp[4] = x[2]**2 + x[3]**2 - x[4]**2
return tmp
x0 = array(([1.02,1.02,0.02,0.02,0.02]))
eps = 1.e-5
J = zeros((5,5),Float)
for i in arange(0,5):
ei = zeros(5,Float)
ei[i] = 1.0
J[:,i] = (f(x0+eps*ei)-f(x0))/eps
Any pointer would be appreciated.
Thanks in advance
Nils
More information about the SciPy-user
mailing list