向量的导数
向量的导数取决于你对向量的上下文和所涉及的变量维度。常见情况下,我们主要讨论以下两种情况:
1. 标量函数对向量的导数
如果一个标量函数 f ( x ) f(\mathbf{x}) f(x) 是关于向量 x = [ x 1 , x 2 , … , x n ] ⊤ \mathbf{x} = [x_1, x_2, \dots, x_n]^\top x=[x1,x2,…,xn]⊤ 的函数,其导数通常是梯度 ∇ f ( x ) \nabla f(\mathbf{x}) ∇f(x),表示为一个向量:
∇ f ( x ) = [ ∂ f ∂ x 1 ∂ f ∂ x 2 ⋮ ∂ f ∂ x n ] . \nabla f(\mathbf{x}) = \begin{bmatrix} \frac{\partial f}{\partial x_1} \\ \frac{\partial f}{\partial x_2} \\ \vdots \\ \frac{\partial f}{\partial x_n} \end{bmatrix}. ∇f(x)= ∂x1∂f∂x2∂f⋮∂xn∂f .
例如:若 f ( x ) = x 1 2 + x 2 2 f(\mathbf{x}) = x_1^2 + x_2^2 f(x)=x12+x22,则:
∇ f ( x ) = [ ∂ f ∂ x 1 ∂ f ∂ x 2 ] = [ 2 x 1 2 x 2 ] . \nabla f(\mathbf{x}) = \begin{bmatrix} \frac{\partial f}{\partial x_1} \\ \frac{\partial f}{\partial x_2} \end{bmatrix} = \begin{bmatrix} 2x_1 \\ 2x_2 \end{bmatrix}. ∇f(x)=[∂x1∂f∂x2∂f]=[2x12x2].
2. 向量函数对向量的导数
如果一个向量函数 f ( x ) \mathbf{f}(\mathbf{x}) f(x) 是关于向量 x = [ x 1 , x 2 , … , x n ] ⊤ \mathbf{x} = [x_1, x_2, \dots, x_n]^\top x=[x1,x2,…,xn]⊤ 的函数,导数是一个 雅可比矩阵(Jacobian matrix)。设:
f ( x ) = [ f 1 ( x ) f 2 ( x ) ⋮ f m ( x ) ] , \mathbf{f}(\mathbf{x}) = \begin{bmatrix} f_1(\mathbf{x}) \\ f_2(\mathbf{x}) \\ \vdots \\ f_m(\mathbf{x}) \end{bmatrix}, f(x)= f1(x)f2(x)⋮fm(x) ,
则雅可比矩阵是一个 m × n m \times n m×n 的矩阵:
J = ∂ f ∂ x = [ ∂ f 1 ∂ x 1 ∂ f 1 ∂ x 2 … ∂ f 1 ∂ x n ∂ f 2 ∂ x 1 ∂ f 2 ∂ x 2 … ∂ f 2 ∂ x n ⋮ ⋮ ⋱ ⋮ ∂ f m ∂ x 1 ∂ f m ∂ x 2 … ∂ f m ∂ x n ] . J = \frac{\partial \mathbf{f}}{\partial \mathbf{x}} = \begin{bmatrix} \frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \dots & \frac{\partial f_1}{\partial x_n} \\ \frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \dots & \frac{\partial f_2}{\partial x_n} \\ \vdots & \vdots & \ddots & \vdots \\ \frac{\partial f_m}{\partial x_1} & \frac{\partial f_m}{\partial x_2} & \dots & \frac{\partial f_m}{\partial x_n} \end{bmatrix}. J=∂x∂f= ∂x1∂f1∂x1∂f2⋮∂x1∂fm∂x2∂f1∂x2∂f2⋮∂x2∂fm……⋱…∂xn∂f1∂xn∂f2⋮∂xn∂fm .
例如:若 f ( x ) = [ x 1 2 x 1 x 2 e x 2 ] \mathbf{f}(\mathbf{x}) = \begin{bmatrix} x_1^2 \\ x_1x_2 \\ e^{x_2} \end{bmatrix} f(x)= x12x1x2ex2 ,则:
J = [ ∂ f 1 ∂ x 1 ∂ f 1 ∂ x 2 ∂ f 2 ∂ x 1 ∂ f 2 ∂ x 2 ∂ f 3 ∂ x 1 ∂ f 3 ∂ x 2 ] = [ 2 x 1 0 x 2 x 1 0 e x 2 ] . J = \begin{bmatrix} \frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} \\ \frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} \\ \frac{\partial f_3}{\partial x_1} & \frac{\partial f_3}{\partial x_2} \end{bmatrix} = \begin{bmatrix} 2x_1 & 0 \\ x_2 & x_1 \\ 0 & e^{x_2} \end{bmatrix}. J= ∂x1∂f1∂x1∂f2∂x1∂f3∂x2∂f1∂x2∂f2∂x2∂f3 = 2x1x200x1ex2 .
3. 向量函数对标量的导数
如果 x ( t ) \mathbf{x}(t) x(t) 是标量 t t t 的函数(即 x \mathbf{x} x 是一个随时间变化的向量),其导数是一个向量:
d x d t = [ d x 1 d t d x 2 d t ⋮ d x n d t ] . \frac{d\mathbf{x}}{dt} = \begin{bmatrix} \frac{dx_1}{dt} \\ \frac{dx_2}{dt} \\ \vdots \\ \frac{dx_n}{dt} \end{bmatrix}. dtdx= dtdx1dtdx2⋮dtdxn .