Function reference · Calculus
diff
Differentiates an expression with respect to a variable.
It uses the product, quotient, power and chain rules on algebraic expressions and the built-in functions. Pass an order for higher derivatives.
Notation
diff(expression[, variable][, order])
Write it in an expression: nerdamer('diff(x^2+2*x+1,x)'), or in the Playground.
nerdamer.diff
nerdamer.diff(expression: Expression, variable?: ExpressionInput, order?: number | Expression): Expression
A method on the default import. Arguments can be strings, as in Notation.
import { diff }
import { diff } from 'nerdamer/calculus';
diff(expression: ExpressionInput, variable?: ExpressionInput, order?: number | Expression): Expression
Import only this function, from nerdamer/calculus.
Parameters
expression- Expression to differentiate.
variable- Variable to differentiate with respect to.
order- Optional derivative order.
Examples
The chain rule through a power of a sine.
diff(5*sin(x^2)^2,x)
// → 20*x*cos(x^2)*sin(x^2)Open in PlaygroundA variable raised to a variable power.
diff(x^sin(x),x)
// → x^sin(x)*(x^-1*sin(x)+cos(x)*log(x))Open in PlaygroundA value stored under the variable's name isn't substituted, so this is still 2*x.
x:5; diff(x^2,x)
// → 2*xOpen in PlaygroundGood to know
- Without a variable,
diffuses the only variable left after stored values are substituted: afterx:5,diff(x^2)gives0. With more than one variable, give it:diff(x*y)is an error.
