Back to Symbolic Mathematics

diff

Symbolic differentiation

Syntax

df = diff(f, x)
df = diff(f, x, n)

Description

Computes the symbolic derivative of f with respect to x. If n is specified, computes the nth derivative. Supports all elementary functions including trigonometric, exponential, and logarithmic.

Parameters

NameDescription
fSymbolic expression to differentiate
xVariable to differentiate with respect to
n(optional)Order of derivative (default: 1)

Returns

Derivative expression

Examples

Try It
>> syms x; diff(x^3, x)
3*x^2
Try It
>> syms x; diff(sin(x), x)
cos(x)
Try It
>> syms x; diff(x^3, x, 2)
6*x

See Also