Hi everyone,

I wrote a Jacobian function for Sage, as follows:

def jacobian(fs, varz):
        # Compute the derivatives of fs for each of the varz
        # the number of columns is the length of vars
        # the number of rows is the length of fs
        numcols = len(varz)
        numrows = len(fs)
        array   = range(0, numcols * numrows)
        for i in range(0, numcols):
                for j in range(0, numrows):
                        array[i * numrows + j] = derivative(fs[j], varz[i])
        return matrix(numrows, numcols, array)

Now, I run this example:
sage: x = var('x')
sage: y = var('y')
sage: m = jacobian([sin(x), cos(y)], [x, y])
sage: m

[ cos(x)       0]
[      0 -sin(y)]

OK, so it computes the Jacobian correctly. Now I would like to
evaluate the Jacobian at some point.
Say:
sage: x = pi / 2
sage: y = pi

Now, how do I get a matrix of numbers out of m?

Thanks,

Aleks

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to