# ito_formula 函数

Itô 引理：对服从 Itô 过程的状态所构成表达式的微分。

## 怎么写

### ito_formula(f, states, drift, diffusion, time)

给出规则 ito_differential(f) -> {dt: ..., dw: \[...\]}；并附注说明它在何时成立。

**f**

由状态与时间构成的、被求微分的表达式。接受一个表达式。

**states**

状态变量，用方括号括起。接受变量列表或一个变量。

**drift**

每个状态的漂移项，用方括号括起。接受一个列表。

**diffusion**

噪声：每一行对应一个状态，每一列对应一个驱动。接受一个矩阵，写作行组成的列表。

**time**

时间，一个变量。接受一个变量或变量列表。

### ito_formula(f, states, drift, diffusion, time)

只有一个状态和一个驱动时，不用列表的调用；结果相同。

**f**

由状态与时间构成的、被求微分的表达式。接受一个表达式。

**states**

唯一的状态变量，不用列表。接受一个变量或变量列表。

**drift**

该状态的漂移项。接受一个表达式。

**diffusion**

该状态的噪声，对应一个驱动。接受一个表达式。

**time**

时间，一个变量。接受一个变量或变量列表。

## 示例

- $\displaystyle \operatorname{ito\_formula}\left(x^{2}, \left[ x \right], \left[ \mu x \right], \begin{pmatrix} \sigma x \end{pmatrix}, t\right) = \operatorname{ito\_differential}(x^{2}) \to \left[ \text{dt} \to \sigma^{2} x^{2}+2 \mu x^{2}, \text{dw} \to \left[ 2 \sigma x^{2} \right] \right]$

  `ito_formula(x^2, [x], [mu*x], [[sigma*x]], t)`

  在求解器中，`ito_formula(x^2, [x], [mu*x], [[sigma*x]], t)` 的结果是 `ito_differential(x^2) -> {dt: sigma^2*x^2 + 2mu*x^2, dw: [2sigma*x^2]}`。

  [在求解器中打开](https://zh.hilberon.com/?q=ito_formula%28x%5E2%2C%20%5Bx%5D%2C%20%5Bmu*x%5D%2C%20%5B%5Bsigma*x%5D%5D%2C%20t%29)
- $\displaystyle \operatorname{ito\_formula}\left(x y, \left[ x, y \right], \left[ 0, 0 \right], \begin{pmatrix} s_{1} \\ s_{2} \end{pmatrix}, t\right) = \operatorname{ito\_differential}(x y) \to \left[ \text{dt} \to s_{1} s_{2}, \text{dw} \to \left[ s_{2} x+s_{1} y \right] \right]$

  `ito_formula(x*y, [x, y], [0, 0], [[s1], [s2]], t)`

  在求解器中，`ito_formula(x*y, [x, y], [0, 0], [[s1], [s2]], t)` 的结果是 `ito_differential(x*y) -> {dt: s1*s2, dw: [s2*x + s1*y]}`。

  [在求解器中打开](https://zh.hilberon.com/?q=ito_formula%28x*y%2C%20%5Bx%2C%20y%5D%2C%20%5B0%2C%200%5D%2C%20%5B%5Bs1%5D%2C%20%5Bs2%5D%5D%2C%20t%29)
- $\displaystyle \mathrm{d}(X_{t}^{2}) \text{ 其中 } \mathrm{d}X_{t} = \mu X_{t}\,\mathrm{d}t+\sigma X_{t}\,\mathrm{d}W_{t} \Rightarrow \mathrm{d}(X_{t}^{2}) = (\sigma^{2} X_{t}^{2}+2 \mu X_{t}^{2})\,\mathrm{d}t+2 \sigma X_{t}^{2}\,\mathrm{d}W_{t}$

  `ito_formula(x^2, x, mu*x, sigma*x, t)`

  在求解器中，`ito_formula(x^2, x, mu*x, sigma*x, t)` 的结果是 `ito_differential(x^2) -> {dt: sigma^2*x^2 + 2mu*x^2, dw: [2sigma*x^2]}`。

  [在求解器中打开](https://zh.hilberon.com/?q=ito_formula%28x%5E2%2C%20x%2C%20mu*x%2C%20sigma*x%2C%20t%29)
- $\displaystyle \mathrm{d}(\ln(X_{t})) \text{ 其中 } \mathrm{d}X_{t} = \mu X_{t}\,\mathrm{d}t+\sigma X_{t}\,\mathrm{d}W_{t} \Rightarrow \mathrm{d}(\ln(X_{t})) = \left(\mu-\frac{\sigma^{2}}{2}\right)\,\mathrm{d}t+\sigma\,\mathrm{d}W_{t}$

  `ito_formula(ln(x), x, mu*x, sigma*x, t)`

  在求解器中，`ito_formula(ln(x), x, mu*x, sigma*x, t)` 的结果是 `ito_differential(ln(x)) -> {dt: mu - sigma^2/2, dw: [sigma]}`。

  [在求解器中打开](https://zh.hilberon.com/?q=ito_formula%28ln%28x%29%2C%20x%2C%20mu*x%2C%20sigma*x%2C%20t%29)

## 相关函数

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

  ito_formula 背后的认证记录：结果、有效性、证书与定理。
- [ito_integral](https://zh.hilberon.com/library/ito_integral)

  由维纳值 w 和时间 s 构成的表达式在 0 到 t 上的 Itô 积分。
- [ito_process](https://zh.hilberon.com/library/ito_process)

  由漂移项和扩散项给出的过程：dX = drift dt + diffusion dW。
- [geometric_sde_path](https://zh.hilberon.com/library/geometric_sde_path)

  dX = mu X dt + sigma X dW 的路径，表示为维纳过程在时刻 t 的取值 w 的函数。
- [geometric_brownian_motion_process](https://zh.hilberon.com/library/geometric_brownian_motion_process)

  以速率 mu 增长、相对噪声为 sigma、从 x0 出发的过程。
- [fit](https://zh.hilberon.com/library/fit)

  用若干函数的组合对点集作最小二乘拟合。

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