Search code examples
maple

Jacobian using in Maple


How can I use the Jacobian written below as function from (x, y) ?

g := (x, y) -> x - y
u := (x, y) -> x^2 + y^2

J := jacobian([g(x, y), u(x, y)], [x, y]);

My idea was to make funcion like this

Jf := (u, v) -> subs(x = u, y = v, J(x, y))

but it returns ugly matrix with brakets inside.

P. S. I use Maple 17


Solution

  • The linalg package (which exports the jacobian command) and lowercase matrix are deprecated. Use LinearAlgebra and Matrix instead, and VectorCalculus:-Jacobian.

    Also, note the use of unapply.

    restart:
    
    g := (x, y) -> x - y:
    
    u := (x, y) -> x^2 + y^2:
    
    J:=VectorCalculus:-Jacobian([g(x,y),u(x,y)],[x,y]);
    
                                    [ 1     -1 ]
                               J := [          ]
                                    [2 x    2 y]
    
    Jf:=unapply(J,[x,y]):
    
    Jf(1,1);
    
                                   [1    -1]
                                   [       ]
                                   [2     2]
    
    Jf(s,t);
                                 [ 1     -1 ]
                                 [          ]
                                 [2 s    2 t]