# Derivative (diff)

Derivative of an expression with respect to one or more variables.

With this function, the solver shows the steps whenever it finds them.

## How to write it

### diff(f, x)

The first derivative.

**f**

The expression or function to work on. Takes an expression.

**x**

The variable to differentiate by. Takes a variable.

### diff(f, x, n)

The derivative of order n.

**f**

The expression or function to work on. Takes an expression.

**x**

The variable to differentiate by. Takes a variable.

**n**

The order: how many times to differentiate. Takes a whole number.

### diff(f, x, y)

A mixed partial derivative.

**f**

The expression or function to work on. Takes an expression.

**x**

The first variable. Takes a variable.

**y**

The second variable. Takes a variable.

## Examples

- $\displaystyle \frac{d}{dx} \sin(x^{2}) = 2 x \cos(x^{2})$

  `diff(sin(x^2), x)`

  In the solver, `diff(sin(x^2), x)` gives `2x*cos(x^2)`.

  [Open in the solver](https://hilberon.com/?q=diff%28sin%28x%5E2%29%2C%20x%29)
- $\displaystyle \frac{d^{2}}{dx^{2}}(x^{5}) = 20 x^{3}$

  `diff(x^5, x, 2)`

  In the solver, `diff(x^5, x, 2)` gives `20x^3`.

  [Open in the solver](https://hilberon.com/?q=diff%28x%5E5%2C%20x%2C%202%29)
- $\displaystyle \frac{\partial^{2}}{\partial x \, \partial y}(x^{2} y) = 2 x$

  `diff(x^2 y, x, y)`

  In the solver, `diff(x^2 y, x, y)` gives `2x`.

  [Open in the solver](https://hilberon.com/?q=diff%28x%5E2%20y%2C%20x%2C%20y%29)

## Functions its examples use

- [sin](https://hilberon.com/library/sin)

  Sine of an angle in radians.

## Related functions

- [total_diff](https://hilberon.com/library/total_diff)

  Total derivative of an expression with respect to a variable.
- [div](https://hilberon.com/library/div)

  Divergence of a vector field.
- [derivative](https://hilberon.com/library/derivative)

  The derivative operator: derivative(n) is of order n, derivative(0, 1) is the partial in the second argument.
- [grad](https://hilberon.com/library/grad)

  Gradient of an expression: the list of its partial derivatives.
- [curl](https://hilberon.com/library/curl)

  Curl of a vector field in three variables.
- [hessian](https://hilberon.com/library/hessian)

  Hessian matrix of an expression: its second partial derivatives.

---
Source: https://hilberon.com/library/diff
