This entry is documented with its primary interface. Open the documentation →
nerdamer.diff
nerdamer.diff(x: ExpressionInput, variable?: ExpressionInput, n?: number | Expression): ExpressionDifferentiates an expression symbolically. The chain, product, sum, and power rules are applied recursively, together with the built-in derivative table for recognized functions. An omitted variable is inferred as the first variable in the expression. Existing Expression input is reused during normalization.
n requests a repeated derivative. A non-integer order, a non-variable
differentiation target, or an unsupported derivative is preserved as an
unevaluated diff(...) expression. Constants and expressions independent of
the selected variable differentiate to zero.
core!UnsupportedOperationError If variable is numeric.
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | Expression to differentiate. |
variable | ExpressionInput | Variable with respect to which the derivative is taken. |
n | number | Expression | Positive 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.
Examples
diff('sin(x^2)', 'x').text();
diff('x^4', 'x', 2).text();