# 导数（Derivative，diff）

表达式关于一个或多个变量的导数。

使用这个函数时，求解器只要找到步骤就会展示。

## 怎么写

### diff(f, x)

一阶导数。

**f**

要处理的表达式或函数。接受一个表达式。

**x**

用来求导的变量。接受一个变量。

### diff(f, x, n)

n 阶导数。

**f**

要处理的表达式或函数。接受一个表达式。

**x**

用来求导的变量。接受一个变量。

**n**

阶数：求导的次数。接受一个整数。

### diff(f, x, y)

混合偏导数。

**f**

要处理的表达式或函数。接受一个表达式。

**x**

第一个变量。接受一个变量。

**y**

第二个变量。接受一个变量。

## 示例

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

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

  在求解器中，`diff(sin(x^2), x)` 的结果是 `2x*cos(x^2)`。

  [在求解器中打开](https://zh.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)`

  在求解器中，`diff(x^5, x, 2)` 的结果是 `20x^3`。

  [在求解器中打开](https://zh.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)`

  在求解器中，`diff(x^2 y, x, y)` 的结果是 `2x`。

  [在求解器中打开](https://zh.hilberon.com/?q=diff%28x%5E2%20y%2C%20x%2C%20y%29)

## 示例中用到的函数

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

  角度的正弦，角度以弧度计。

## 相关函数

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

  表达式关于某个变量的全导数。
- [div](https://zh.hilberon.com/library/div)

  向量场的散度。
- [derivative](https://zh.hilberon.com/library/derivative)

  导数算子：derivative(n) 为 n 阶导数，derivative(0, 1) 为关于第二个自变量的偏导数。
- [grad](https://zh.hilberon.com/library/grad)

  表达式的梯度：其偏导数组成的列表。
- [curl](https://zh.hilberon.com/library/curl)

  三个变量的向量场的旋度。
- [hessian](https://zh.hilberon.com/library/hessian)

  表达式的 Hessian 矩阵：其二阶偏导数。

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