Function reference · Calculus

diff

Differentiates an expression symbolically with respect to a variable.

Nerdamer applies the standard differentiation rules to algebraic expressions and supported functions, including product, quotient, power, and chain rules. Higher-order derivatives can be requested with the optional order argument.

Examples

These examples use Nerdamer Notation.

Differentiate a polynomial.

diff(x^2+2*x+1,x)
// → 2+2*x

Apply the chain rule through a trigonometric power.

diff(5*sin(x^2)^2,x)
// → 20*x*cos(x^2)*sin(x^2)

Differentiate a variable raised to a variable-dependent power.

diff(x^sin(x),x)
// → x^sin(x)*(x^-1*sin(x)+cos(x)*log(x))

Interfaces

The same operation is available through the interfaces below.

Nerdamer Notation · nerdamer API · Direct API

Nerdamer Notation

Use this form inside input passed to nerdamer(...).

diff(expression[, variable][, order])

Parameters

  • expression — Expression to differentiate.
  • variable — Variable to differentiate with respect to.
  • order — Optional derivative order.

nerdamer.diff

Call the operation through the default nerdamer import.

nerdamer.diff(x: ExpressionInput, variable?: ExpressionInput, n?: number | Expression): Expression

Parameters

NameTypeDescription
xExpressionInputExpression to differentiate.
variableExpressionInputVariable with respect to which the derivative is taken.
nnumber | ExpressionPositive integer derivative order. Defaults to the first derivative.

Returns

Expression — The symbolic derivative, or an unevaluated `diff(...)` call when the requested operation cannot be resolved.

Browse the nerdamer API →

Direct JavaScript / TypeScript API

Import the operation directly from its package entry point.

import { diff } from 'nerdamer/calculus';
diff(x: ExpressionInput, variable?: ExpressionInput, n?: number | Expression): Expression

Parameters

NameTypeDescription
xExpressionInputExpression to differentiate.
variableExpressionInputVariable with respect to which the derivative is taken.
nnumber | ExpressionPositive integer derivative order. Defaults to the first derivative.

Returns

Expression — The symbolic derivative, or an unevaluated `diff(...)` call when the requested operation cannot be resolved.

Browse nerdamer/calculus

← Back to Reference