(ctx, f, x)
return J
Calculate the Jacobian matrix of a function at the point x0.

    This is the first derivative of a vectorial function:

        f : R^m -> R^n with m >= n
Calculate the Jacobian matrix of a function at the point x0.
Calculate the Jacobian matrix of a function at the point x0 .
def jacobian(ctx, f, x):
    """
    Calculate the Jacobian matrix of a function at the point x0.

    This is the first derivative of a vectorial function:

        f : R^m -> R^n with m >= n
    """
    x = ctx.matrix(x)
    h = ctx.sqrt(ctx.eps)
    fx = ctx.matrix(f(*x))
    m = len(fx)
    n = len(x)
    J = ctx.matrix(m, n)
    for j in xrange(n):
        xj = x.copy()
        xj[j] += h
        Jj = (ctx.matrix(f(*xj)) - fx) / h
        for i in xrange(m):
            J[i,j] = Jj[i]
    return J
def jacobian ( ctx , f , x ) : x = ctx . matrix ( x ) h = ctx . sqrt ( ctx . eps ) fx = ctx . matrix ( f ( * x ) ) m = len ( fx ) n = len ( x ) J = ctx . matrix ( m , n ) for j in xrange ( n ) : xj = x . copy ( ) xj [ j ] += h Jj = ( ctx . matrix ( f ( * xj ) ) - fx ) / h for i in xrange ( m ) : J [ i , j ] = Jj [ i ] return J