# 梯度

• 梯度一詞有時用於斜度，也就是一個曲面沿著給定方向的傾斜程度。可以通過取向量梯度和所研究的方向的內積來得到斜度。梯度的數值有時也被稱為梯度。

## 形式化定義

${\displaystyle \nabla \varphi }$${\displaystyle \operatorname {grad} \varphi }$

${\displaystyle \nabla \varphi }$在三維直角座標中表示為

${\displaystyle \nabla \varphi ={\begin{pmatrix}{\frac {\partial \varphi }{\partial x}},{\frac {\partial \varphi }{\partial y}},{\frac {\partial \varphi }{\partial z}}\end{pmatrix}}}$

### 範例

${\displaystyle \nabla \varphi ={\begin{pmatrix}{\frac {\partial \varphi }{\partial x}},{\frac {\partial \varphi }{\partial y}},{\frac {\partial \varphi }{\partial z}}\end{pmatrix}}={\begin{pmatrix}{2},{6y},{-\cos(z)}\end{pmatrix}}}$

## 實純量函數的梯度[來源請求]

${\displaystyle \nabla _{\boldsymbol {x}}{\overset {\underset {\mathrm {def} }{}}{=}}\left[{\frac {\partial }{\partial x_{1}}},{\frac {\partial }{\partial x_{2}}},\cdots ,{\frac {\partial }{\partial x_{n}}}\right]^{T}={\frac {\partial }{\partial {\boldsymbol {x}}}}}$[來源請求]

### 對向量的梯度

${\displaystyle \nabla _{\boldsymbol {x}}f({\boldsymbol {x}}){\overset {\underset {\mathrm {def} }{}}{=}}\left[{\frac {\partial f({\boldsymbol {x}})}{\partial x_{1}}},{\frac {\partial f({\boldsymbol {x}})}{\partial x_{2}}},\cdots ,{\frac {\partial f({\boldsymbol {x}})}{\partial x_{n}}}\right]^{T}={\frac {\partial f({\boldsymbol {x}})}{\partial {\boldsymbol {x}}}}}$

m維行向量函數${\displaystyle {\boldsymbol {f}}({\boldsymbol {x}})=[f_{1}({\boldsymbol {x}}),f_{2}({\boldsymbol {x}}),\cdots ,f_{m}({\boldsymbol {x}})]}$相對於n維實向量x的梯度為一n×m矩陣，定義為

${\displaystyle \nabla _{\boldsymbol {x}}{\boldsymbol {f}}({\boldsymbol {x}}){\overset {\underset {\mathrm {def} }{}}{=}}{\begin{bmatrix}{\frac {\partial f_{1}({\boldsymbol {x}})}{\partial x_{1}}}&{\frac {\partial f_{2}({\boldsymbol {x}})}{\partial x_{1}}}&\cdots &{\frac {\partial f_{m}({\boldsymbol {x}})}{\partial x_{1}}}\\{\frac {\partial f_{1}({\boldsymbol {x}})}{\partial x_{2}}}&{\frac {\partial f_{2}({\boldsymbol {x}})}{\partial x_{2}}}&\cdots &{\frac {\partial f_{m}({\boldsymbol {x}})}{\partial x_{2}}}\\\vdots &\vdots &\ddots &\vdots \\{\frac {\partial f_{1}({\boldsymbol {x}})}{\partial x_{n}}}&{\frac {\partial f_{2}({\boldsymbol {x}})}{\partial x_{n}}}&\cdots &{\frac {\partial f_{m}({\boldsymbol {x}})}{\partial x_{n}}}\\\end{bmatrix}}={\frac {\partial {\boldsymbol {f}}({\boldsymbol {x}})}{\partial {\boldsymbol {x}}}}}$

### 對矩陣的梯度

${\displaystyle \nabla _{\boldsymbol {A}}{\boldsymbol {f}}({\boldsymbol {A}}){\overset {\underset {\mathrm {def} }{}}{=}}{\begin{bmatrix}{\frac {\partial f({\boldsymbol {A}})}{\partial a_{11}}}&{\frac {\partial f({\boldsymbol {A}})}{\partial a_{12}}}&\cdots &{\frac {\partial f({\boldsymbol {A}})}{\partial a_{1n}}}\\{\frac {\partial f({\boldsymbol {A}})}{\partial a_{21}}}&{\frac {\partial f({\boldsymbol {A}})}{\partial a_{22}}}&\cdots &{\frac {\partial f({\boldsymbol {A}})}{\partial a_{2n}}}\\\vdots &\vdots &\ddots &\vdots \\{\frac {\partial f({\boldsymbol {A}})}{\partial a_{m1}}}&{\frac {\partial f({\boldsymbol {A}})}{\partial a_{m2}}}&\cdots &{\frac {\partial f({\boldsymbol {A}})}{\partial a_{mn}}}\\\end{bmatrix}}={\frac {\partial {\boldsymbol {f}}({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}}$

### 法則

• 線性法則：若${\displaystyle f({\boldsymbol {A}})}$${\displaystyle g({\boldsymbol {A}})}$分別是矩陣A的實純量函數，c1和c2為實常數，則
${\displaystyle {\frac {\partial [c_{1}f({\boldsymbol {A}})+c_{2}g({\boldsymbol {A}})]}{\partial {\boldsymbol {A}}}}=c_{1}{\frac {\partial f({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}+c_{2}{\frac {\partial g({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}}$
• 乘積法則：若${\displaystyle f({\boldsymbol {A}})}$${\displaystyle g({\boldsymbol {A}})}$${\displaystyle h({\boldsymbol {A}})}$分別是矩陣A的實純量函數，則
${\displaystyle {\frac {\partial f({\boldsymbol {A}})g({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}=g({\boldsymbol {A}}){\frac {\partial f({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}+f({\boldsymbol {A}}){\frac {\partial g({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}}$
${\displaystyle {\frac {\partial f({\boldsymbol {A}})g({\boldsymbol {A}})h({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}=g({\boldsymbol {A}})h({\boldsymbol {A}}){\frac {\partial f({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}+f({\boldsymbol {A}})h({\boldsymbol {A}}){\frac {\partial g({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}+f({\boldsymbol {A}})g({\boldsymbol {A}}){\frac {\partial h({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}}$
• 商法則：若${\displaystyle g({\boldsymbol {A}})\neq 0}$，則
${\displaystyle {\frac {\partial f({\boldsymbol {A}})/g({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}={\frac {1}{g({\boldsymbol {A}})^{2}}}\left[g({\boldsymbol {A}}){\frac {\partial f({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}-f({\boldsymbol {A}}){\frac {\partial g({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}\right]}$
• 鏈式法則：若A為m×n矩陣，且${\displaystyle y=f({\boldsymbol {A}})}$${\displaystyle g(y)}$分別是以矩陣A和純量y為變元的實純量函數，則
${\displaystyle {\frac {\partial g(f({\boldsymbol {A}}))}{\partial {\boldsymbol {A}}}}={\frac {dg(y)}{dy}}{\frac {\partial f({\boldsymbol {A}})}{\partial {\boldsymbol {A}}}}}$

## 流形上的梯度

${\displaystyle \langle \nabla f,\xi \rangle :=\xi f}$

${\displaystyle \xi (f\mid _{p}):=\sum _{j}a_{j}({\frac {\partial }{\partial x_{j}}}(f\circ \varphi ^{-1})\mid _{\varphi (p)})}$

${\displaystyle \nabla f=\sum _{ik}g^{ik}{\frac {\partial f}{\partial x^{k}}}{\frac {\partial }{\partial x^{i}}}}$

## 柱座標下的梯度（${\displaystyle \nabla }$）算符

${\displaystyle \nabla f(\rho ,\theta ,z)={\frac {\partial f}{\partial \rho }}\mathbf {e} _{\rho }+{\frac {1}{\rho }}{\frac {\partial f}{\partial \theta }}\mathbf {e} _{\theta }+{\frac {\partial f}{\partial z}}\mathbf {e} _{z}}$

## 球座標下的梯度（${\displaystyle \nabla }$）算符

${\displaystyle \nabla f(r,\theta ,\phi )={\frac {\partial f}{\partial r}}\mathbf {e} _{r}+{\frac {1}{r}}{\frac {\partial f}{\partial \theta }}\mathbf {e} _{\theta }+{\frac {1}{r\sin \theta }}{\frac {\partial f}{\partial \phi }}\mathbf {e} _{\phi }}$

## 參考

### 書籍

• （中文）張賢達. 矩陣分析與應用. 清華大學出版社. 2004年9月. ISBN 9787302092711.