@sym
: jacobian (f) ¶@sym
: jacobian (f, x) ¶Symbolic Jacobian of symbolic expression.
The Jacobian of a scalar expression is:
syms f(x, y, z) jacobian(f) ⇒ (sym 1×3 matrix) ⎡∂ ∂ ∂ ⎤ ⎢──(f(x, y, z)) ──(f(x, y, z)) ──(f(x, y, z))⎥ ⎣∂x ∂y ∂z ⎦
x can be a scalar, vector or cell list. If omitted,
it is determined using symvar
.
Example:
f = sin(x*y); jacobian(f) ⇒ (sym) [y⋅cos(x⋅y) x⋅cos(x⋅y)] (1×2 matrix) jacobian(f, [x y z]) ⇒ (sym) [y⋅cos(x⋅y) x⋅cos(x⋅y) 0] (1×3 matrix)
For vector input, the output is a matrix:
syms f(x,y,z) g(x,y,z) jacobian([f; g]) ⇒ (sym 2×3 matrix) ⎡∂ ∂ ∂ ⎤ ⎢──(f(x, y, z)) ──(f(x, y, z)) ──(f(x, y, z))⎥ ⎢∂x ∂y ∂z ⎥ ⎢ ⎥ ⎢∂ ∂ ∂ ⎥ ⎢──(g(x, y, z)) ──(g(x, y, z)) ──(g(x, y, z))⎥ ⎣∂x ∂y ∂z ⎦
Example:
jacobian([2*x + 3*z; 3*y^2 - cos(x)]) ⇒ (sym 2×3 matrix) ⎡ 2 0 3⎤ ⎢ ⎥ ⎣sin(x) 6⋅y 0⎦
See also: @sym/divergence, @sym/gradient, @sym/curl, @sym/laplacian, @sym/hessian.
Package: symbolic