Method on @sym: diff (f)
Method on @sym: diff (f, x)
Method on @sym: diff (f, x, x, …)
Method on @sym: diff (f, x, n)
Method on @sym: diff (f, x, y)
Method on @sym: diff (f, x, x, y, y, …)
Method on @sym: diff (f, x, n, y, m, …)

Symbolic differentiation.

Examples:

syms x
f = sin (cos (x));
diff (f)
  ⇒ (sym) -sin(x)⋅cos(cos(x))
diff (f, x)
  ⇒ (sym) -sin(x)⋅cos(cos(x))
simplify (diff (f, x, x))
  ⇒ (sym)
           2
      - sin (x)⋅sin(cos(x)) - cos(x)⋅cos(cos(x))

Partial differentiation:

syms x y
f = cos(2*x + 3*y);
diff(f, x, y, x)
  ⇒ (sym) 12⋅sin(2⋅x + 3⋅y)
diff(f, x, 2, y, 3)
  ⇒ (sym) -108⋅sin(2⋅x + 3⋅y)

Other examples:

diff(sym(1))
  ⇒ (sym) 0

Partial derivatives are assumed to commute:

syms f(x, y)
diff(f, x, y)
  ⇒ ans(x, y) = (symfun)

         2
        ∂
      ─────(f(x, y))
      ∂y ∂x

diff(f, y, x)
  ⇒ ans(x, y) = (symfun)

         2
        ∂
      ─────(f(x, y))
      ∂y ∂x

See also: @sym/int.

Package: symbolic