AI笔记: 数学基础之方向导数的计算和梯度

方向导数

定理

  • 若函数f(x,y,z)在点P(x,y,z)处可微,沿任意方向l的方向导数
  • ∂ f ∂ l = ∂ f ∂ x c o s α + ∂ f ∂ y c o s β + ∂ f ∂ z c o s γ \frac{\partial f}{\partial l} = \frac{\partial f}{\partial x} cos \alpha + \frac{\partial f}{\partial y} cos \beta + \frac{\partial f}{\partial z} cos \gamma lf=xfcosα+yfcosβ+zfcosγ
  • 其中 α , β , γ \alpha, \beta, \gamma α,β,γ 为l的方向角
  • 证明
    • 由函数 f ( x , y , z ) f(x,y,z) f(x,y,z)在点P可微
    • △ f = ∂ f ∂ x △ x + ∂ f ∂ y △ y + ∂ f ∂ z △ z + o ( ρ ) \triangle f = \frac{\partial f}{\partial x} \triangle x + \frac{\partial f}{\partial y} \triangle y + \frac{\partial f}{\partial z} \triangle z + o(\rho) f=xfx+yfy+zfz+o(ρ)
    • = ρ ( ∂ f ∂ x c o s α + ∂ f ∂ y c o s β + ∂ f ∂ z c o s γ ) + o ( ρ ) = \rho(\frac{\partial f}{\partial x} cos \alpha + \frac{\partial f}{\partial y} cos \beta + \frac{\partial f}{\partial z} cos \gamma) + o(\rho) =ρ(xfcosα+yfcosβ+zfcosγ)+o(ρ)
    • ∂ f ∂ l = lim ⁡ ρ → 0 △ f ρ = ∂ f ∂ x c o s α + ∂ f ∂ y c o s β + ∂ f ∂ z c o s γ \frac{\partial f}{\partial l} = \lim_{\rho \to 0} \frac{\triangle f}{\rho} = \frac{\partial f}{\partial x} cos \alpha + \frac{\partial f}{\partial y} cos \beta + \frac{\partial f}{\partial z} cos \gamma lf=limρ0ρf=xfcosα+yfcosβ+zfcosγ
AI笔记: 数学基础之方向导数的计算和梯度_第1张图片
备注:图片托管于github,请确保网络的可访问性

  • 对于二元函数f(x,y)在点P(x,y)处沿着方向l(方向角为 α , β \alpha, \beta α,β)的方向导数为
  • ∂ f ∂ l = lim ⁡ ρ → 0 f ( x + △ x , y + △ y ) − f ( x , y ) ρ = f x ′ ( x , y ) c o s α + f y ′ ( x , y ) c o s β \frac{\partial f}{\partial l} = \lim_{\rho \to 0} \frac{f(x+\triangle x, y + \triangle y) - f(x,y)}{\rho} = f_x'(x,y)cos \alpha + f_y'(x,y) cos \beta lf=limρ0ρf(x+x,y+y)f(x,y)=fx(x,y)cosα+fy(x,y)cosβ
    • ρ = ( △ x ) 2 + ( △ y ) 2 \rho = \sqrt{(\triangle x)^2 + (\triangle y)^2} ρ=(x)2+(y)2
    • △ x = ρ c o s α \triangle x = \rho cos \alpha x=ρcosα
    • △ y = ρ c o s β \triangle y = \rho cos \beta y=ρcosβ
  • 特别地
    • l与x轴同向( α = 0 , β = π 2 \alpha = 0, \beta = \frac{\pi}{2} α=0,β=2π)时,有 ∂ f ∂ l = ∂ f ∂ x \frac{\partial f}{\partial l} = \frac{\partial f}{\partial x} lf=xf
    • l与x轴反向( α = π , β = π 2 \alpha = \pi, \beta = \frac{\pi}{2} α=π,β=2π)时,有 ∂ f ∂ l = − ∂ f ∂ x \frac{\partial f}{\partial l} = -\frac{\partial f}{\partial x} lf=xf
AI笔记: 数学基础之方向导数的计算和梯度_第2张图片
备注:图片托管于github,请确保网络的可访问性

方向导数

  • 方向导数(directional derivative): 有时不仅仅需要知道函数在坐标轴上的变化率(即偏导数),还需要设法求得函数在其他特定方向上的变化率;
  • 而方向导数就是函数在其他特定方向上的变化率。
  • 如果函数 z = f ( x , y ) z=f(x,y) z=f(x,y)在点P(x,y)是可微分的,那么,函数在该点沿着任意方向L的方向导数都存在
  • 且计算公式为: ∂ f ∂ l = ∂ f ∂ x c o s α + ∂ f ∂ y c o s β \frac{\partial f}{\partial l} = \frac{\partial f}{\partial x} cos \alpha + \frac{\partial f}{\partial y} cos \beta lf=xfcosα+yfcosβ
AI笔记: 数学基础之方向导数的计算和梯度_第3张图片
备注:图片托管于github,请确保网络的可访问性

例1

  • 求函数 u = x 2 y z u = x^2yz u=x2yz 在点P(1,1,1)沿向量 l ⃗ = ( 2 , − 1 , 3 ) \vec{l} = (2, -1, 3) l =(2,1,3)的方向导数.
  • ∂ u ∂ l = ∂ u ∂ x c o s α + ∂ u ∂ y c o s β + ∂ u ∂ z c o s γ \frac{\partial u}{\partial l} = \frac{\partial u}{\partial x} cos \alpha + \frac{\partial u}{\partial y} cos \beta + \frac{\partial u}{\partial z} cos \gamma lu=xucosα+yucosβ+zucosγ
    • 向量 l ⃗ \vec{l} l 的方向余弦为: c o s α = 2 14 , cos ⁡ β = − 1 14 , c o s γ = 3 14 cos \alpha = \frac{2}{\sqrt{14}}, \cos \beta = \frac{-1}{\sqrt{14}}, cos \gamma = \frac{3}{\sqrt{14}} cosα=14 2,cosβ=14 1,cosγ=14 3
    • ∂ u ∂ l ∣ P = ( 2 x y z ∗ 2 14 ) − x 2 z ∗ 1 14 + x 2 y ∗ 3 14 ∣ ( 1 , 1 , 1 ) = 6 14 \left. \frac{\partial u}{\partial l} \right|_P = \left. (2xyz * \frac{2}{\sqrt{14}}) - x^2z * \frac{1}{\sqrt{14}} + x^2y * \frac{3}{\sqrt{14}} \right|_{(1,1,1)} = \frac{6}{\sqrt{14}} luP=(2xyz14 2)x2z14 1+x2y14 3(1,1,1)=14 6

例2

  • 求函数 z = x e 2 y z=xe^{2y} z=xe2y在点P(1,0)处沿从点P(1,0)到点Q(2, -1)的方向的方向导数
    • 方向l即向量 P Q = ( 1 , − 1 ) PQ = (1, -1) PQ=(1,1)的方向,与l同方向的单位向量 e l = ( 1 2 , − 1 2 ) . = ( c o s α , c o s β ) e_l = (\frac{1}{\sqrt{2}}, - \frac{1}{\sqrt{2}}). = (cos \alpha, cos \beta) el=(2 1,2 1).=(cosα,cosβ)
    • 因函数可微,且 ∂ z ∂ x ∣ ( 1 , 0 ) = e 2 y ∣ ( 1 , 0 ) = 1 , ∂ z ∂ y ∣ ( 1 , 0 ) = 2 x e 2 y ∣ ( 1 , 0 ) = 2 \left. \frac{\partial z}{\partial x} \right|_{(1,0)} = \left. e^{2y} \right|_{(1,0)} = 1, \left. \frac{\partial z}{\partial y} \right|_{(1,0)} = \left. 2xe^{2y} \right|_{(1,0)} = 2 xz(1,0)=e2y(1,0)=1,yz(1,0)=2xe2y(1,0)=2
    • 所以,所求方向导数为: ∂ z ∂ l ∣ ( 1 , 0 ) = 1 ∗ 1 2 + 2 ∗ ( − 1 2 ) = − 2 2 \left. \frac{\partial z}{\partial l} \right|_{(1,0)} = 1 * \frac{1}{\sqrt{2}} + 2 * (- \frac{1}{\sqrt{2}}) = - \frac{\sqrt{2}}{2} lz(1,0)=12 1+2(2 1)=22

例3

  • f ( x , y , z ) = x y + y z + z x f(x,y,z) = xy + yz + zx f(x,y,z)=xy+yz+zx 在点(1,1,2)沿方向l的方向导数,其中l的方向角分别为:60°, 45°, 60°
  • 解:
    • 与l同方向的单位向量 e l = ( c o s 60 ° , c o s 45 ° , c o s 60 ° ) = ( 1 2 , 2 2 , 1 2 ) e_l = (cos 60°, cos 45°, cos 60°) = (\frac{1}{2}, \frac{\sqrt{2}}{2}, \frac{1}{2}) el=(cos60°,cos45°,cos60°)=(21,22 ,21)
    • 因函数可微,且
      • f x ′ ( 1 , 1 , 2 ) = ( y + z ) ∣ ( 1 , 1 , 2 ) = 3 f_x'(1,1,2) = (y + z)|_{(1,1,2)} = 3 fx(1,1,2)=(y+z)(1,1,2)=3
      • f y ′ ( 1 , 1 , 2 ) = ( x + z ) ∣ ( 1 , 1 , 2 ) = 3 f_y'(1,1,2) = (x + z)|_{(1,1,2)} = 3 fy(1,1,2)=(x+z)(1,1,2)=3
      • f z ′ ( 1 , 1 , 2 ) = ( y + x ) ∣ ( 1 , 1 , 2 ) = 2 f_z'(1,1,2) = (y + x)|_{(1,1,2)} = 2 fz(1,1,2)=(y+x)(1,1,2)=2
    • 所以 ∂ f ∂ l ∣ ( 1 , 1 , 2 ) = 3 ∗ 1 2 + 3 ∗ 2 2 + 2 ∗ 1 2 = 1 2 ( 5 + 3 2 ) \frac{\partial f}{\partial l} |_{(1,1,2)} = 3*\frac{1}{2} + 3*\frac{\sqrt{2}}{2} + 2*\frac{1}{2} = \frac{1}{2}(5 + 3\sqrt{2}) lf(1,1,2)=321+322 +221=21(5+32 )

梯度

1 ) 概念

  • 在空间的每一个点都可以确定无限多个方向,因此,一个多元函数在某个点也必然有无限多个方向导数.
  • 在这无限多个方向导数中,最大的一个(它直接反映了函数在这个点的变化率的数量级)等于多少? 它是沿什么方向达到的?
  • 描述这个最大方向导数及其所沿方向的矢量,就是我们所讨论的梯度.
  • 梯度是场论里的一个基本概念.所谓"场", 它表示空间区域上某种物理量的一种分布
  • 从数学上看,这种分布常常表示为 Ω \Omega Ω 上的一种数值函数或向量函数
  • 能表示为数值函数u=u(x,y,z)的场,称为数量场,如温度场、密度场等

2 ) 方向导数公式

  • ∂ f ∂ l = ∂ f ∂ x c o s α + ∂ f ∂ y c o s β + ∂ f ∂ z c o s γ \frac{\partial f}{\partial l} = \frac{\partial f}{\partial x} cos \alpha + \frac{\partial f}{\partial y} cos \beta + \frac{\partial f}{\partial z} cos \gamma lf=xfcosα+yfcosβ+zfcosγ
    • 令向量 G ⃗ = ( ∂ f ∂ x , ∂ f ∂ y , ∂ f ∂ z ) \vec{G} = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}) G =(xf,yf,zf)
    • l ° ⃗ = ( c o s α , c o s β , c o s γ ) \vec{l°} = (cos \alpha, cos \beta, cos \gamma) l° =(cosα,cosβ,cosγ)
  • ∂ f ∂ l = G ⃗ ⋅ l ° ⃗ = ∣ G ⃗ ∣ c o s ( G ⃗ , l ° ⃗ )     ( ∣ l ° ⃗ ∣ = 1 ) \frac{\partial f}{\partial l} = \vec{G}·\vec{l°} = |\vec{G}|cos(\vec{G}, \vec{l°}) \ \ \ (|\vec{l°}| = 1) lf=G l° =G cos(G ,l° )   (l° =1)
  • l ° ⃗ \vec{l°} l° G ⃗ \vec{G} G 方向一致时,方向导数取最大值: m a x ( ∂ f ∂ l ) = ∣ G ⃗ ∣ max(\frac{\partial f}{\partial l}) = |\vec{G}| max(lf)=G
  • 可见: G ⃗ \vec{G} G
    • 方向:f 变化率最大的方向
    • 模:f 的最大变化率之值

3 ) 梯度定义

  • 向量 G ⃗ \vec{G} G :称为函数 f ( P ) f(P) f(P)在点P处的梯度(gradient), 记做:grad f
  • g r a d   f = ( ∂ f ∂ x , ∂ f ∂ y , ∂ f ∂ z ) = ∂ f ∂ x i ⃗ + ∂ f ∂ y j ⃗ + ∂ f ∂ z k ⃗ grad \ f = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}) = \frac{\partial f}{\partial x} \vec{i} + \frac{\partial f}{\partial y} \vec{j} + \frac{\partial f}{\partial z}\vec{k} grad f=(xf,yf,zf)=xfi +yfj +zfk
  • 同样可定义二元函数f(x,y)在点P(x,y)处的梯度 g r a d   f = ∂ f ∂ x i ⃗ + ∂ f ∂ y j ⃗ = ( ∂ f ∂ x , ∂ f ∂ y ) grad \ f = \frac{\partial f}{\partial x} \vec{i} + \frac{\partial f}{\partial y} \vec{j} = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}) grad f=xfi +yfj =(xf,yf)
  • 说明:函数的方向导数为梯度在该方向上的投影
  • ∇ = ( ∂ ∂ x , ∂ ∂ y ) \nabla = (\frac{\partial}{\partial x}, \frac{\partial}{\partial y}) =(x,y), 引用记号,称为奈布拉(Nebla)算符,或称为向量微分算子或哈密顿(W.R.Hamilton)算子
  • 则梯度可记为: g r a d   f = ( ∂ f ∂ x , ∂ f ∂ y ) ∇ f grad \ f = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}) \nabla f grad f=(xf,yf)f
    • 函数f沿梯度grad f方向,增加最快(上升)
    • 函数f沿负梯度 -grad f方向,减小最快(下降)
  • g r a d   f ( x 0 , y 0 ) = f x ′ ( x 0 , y 0 ) i + f y ′ ( x 0 , y 0 ) j ) grad \ f(x_0, y_0) = f_x'(x_0, y_0)i + f_y'(x_0, y_0)j) grad f(x0,y0)=fx(x0,y0)i+fy(x0,y0)j)
    • ∇ f ( x 0 , y 0 ) = f x ′ ( x 0 , y 0 ) i + f y ′ ( x 0 , y 0 ) j = f x ′ ( x 0 , y 0 ) , f y ′ ( x 0 , y 0 ) \nabla f(x_0, y_0) = f_x'(x_0, y_0)i + f_y'(x_0, y_0) j = {f_x'(x_0, y_0), f_y'(x_0, y_0)} f(x0,y0)=fx(x0,y0)i+fy(x0,y0)j=fx(x0,y0),fy(x0,y0)
  • g r a d   f = ( ∂ f ∂ x , ∂ f ∂ y , ∂ f ∂ z ) = ∂ f ∂ x i ⃗ + ∂ f ∂ y j ⃗ + ∂ f ∂ z k ⃗ grad \ f = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}) = \frac{\partial f}{\partial x} \vec{i} + \frac{\partial f}{\partial y} \vec{j} + \frac{\partial f}{\partial z}\vec{k} grad f=(xf,yf,zf)=xfi +yfj +zfk
    • ∇ f ( x 0 , y 0 , z 0 ) = { f x ′ ( x 0 , y 0 , z 0 ) , f y ′ ( x 0 , y 0 , z 0 ) , f z ′ ( x 0 , y 0 , z 0 ) } = f x ′ ( x 0 , y 0 , z 0 ) i + f y ′ ( x 0 , y 0 , z 0 ) j + f z ′ ( x 0 , y 0 , z 0 ) k \nabla f(x_0, y_0, z_0) = \{f_x'(x_0, y_0, z_0), f_y'(x_0, y_0, z_0), f_z'(x_0, y_0, z_0)\} = f_x'(x_0, y_0, z_0)i + f_y'(x_0, y_0, z_0)j + f_z'(x_0, y_0, z_0)k f(x0,y0,z0)={fx(x0,y0,z0),fy(x0,y0,z0),fz(x0,y0,z0)}=fx(x0,y0,z0)i+fy(x0,y0,z0)j+fz(x0,y0,z0)k

说明

  • 以三元函数为例,设 u = f ( x , y , z ) u=f(x,y,z) u=f(x,y,z)在点P(x,y,z)处可微分,则函数在该点的梯度为 g r a d   f = ∇ f = ∂ f ∂ x i ⃗ + ∂ f ∂ y j ⃗ + ∂ f ∂ z k ⃗ = ( ∂ f ∂ x , ∂ f ∂ y , ∂ f ∂ z ) = ( ∂ ( f ) ∂ ( x , y , z ) ) grad \ f = \nabla f = \frac{\partial f}{\partial x} \vec{i} + \frac{\partial f}{\partial y} \vec{j} + \frac{\partial f}{\partial z}\vec{k} = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}) = (\frac{\partial (f)}{\partial(x,y,z)}) grad f=f=xfi +yfj +zfk =(xf,yf,zf)=((x,y,z)(f))
  • 梯度是函数 u = f ( x , y , z ) u=f(x,y,z) u=f(x,y,z)在点P处取得的最大方向导数的方向,最大方向导数为: ∣ g r a d   f ∣ = ( ∂ f ∂ x ) 2 + ( ∂ f ∂ y ) 2 + ( ∂ f ∂ z ) 2 |grad \ f| = \sqrt{(\frac{\partial f}{\partial x})^2 + (\frac{\partial f}{\partial y})^2 + (\frac{\partial f}{\partial z})^2} grad f=(xf)2+(yf)2+(zf)2
  • 函数 u = f ( x , y , z ) u=f(x,y,z) u=f(x,y,z)在点P处沿方向 l ⃗ \vec{l} l 的方向导数: ∂ f ∂ l ⃗ = g r a d   f ⋅ l ° ⃗ = ∇ f ⋅ l ° ⃗ \frac{\partial f}{\partial \vec{l}} = grad \ f·\vec{l°} = \nabla f · \vec{l °} l f=grad fl° =fl°

例1

  • g r a d   1 x 2 + y 2 grad \ \frac{1}{\sqrt{x^2 + y^2}} grad x2+y2 1
  • 解:
    • 这里 f ( x , y ) = 1 x 2 + y 2 f(x,y) = \frac{1}{x^2 + y^2} f(x,y)=x2+y21
    • ∂ f ∂ x = − 2 x ( x 2 + y 2 ) 2 , ∂ f ∂ y = − 2 y ( x 2 + y 2 ) 2 \frac{\partial f}{\partial x} = - \frac{2x}{(x^2 + y^2)^2}, \frac{\partial f}{\partial y} = - \frac{2y}{(x^2 + y^2)^2} xf=(x2+y2)22x,yf=(x2+y2)22y
    • 所以, g r a d   1 x 2 + y 2 = − 2 x ( x 2 + y 2 ) 2 i ⃗ − 2 y ( x 2 + y 2 ) 2 j ⃗ grad \ \frac{1}{\sqrt{x^2 + y^2}} = - \frac{2x}{(x^2 + y^2)^2} \vec{i} - \frac{2y}{(x^2 + y^2)^2} \vec{j} grad x2+y2 1=(x2+y2)22xi (x2+y2)22yj

例2

  • f ( x , y , z ) = x 3 − x y 2 − z f(x,y,z) = x^3 - xy^2 - z f(x,y,z)=x3xy2z, p ( 1 , 1 , 0 ) p(1,1,0) p(1,1,0).
  • 问f(x,y,z)在p处沿什么方向变化最快,在这方向的变化率是多少?
    • ∇ f = f x ′ i + f y ′ j + f z ′ k = ( 3 x 2 − y 2 ) i − 2 x y j − k \nabla f = f_x'i + f_y'j + f_z'k = (3x^2 - y^2)i - 2xyj - k f=fxi+fyj+fzk=(3x2y2)i2xyjk
    • ∇ f ( 1 , 1 , 0 ) = 2 i − 2 j − k \nabla f(1,1,0) = 2i - 2j - k f(1,1,0)=2i2jk
    • 沿 ∇ f ( 1 , 1 , 0 ) \nabla f(1,1,0) f(1,1,0) 方向,增加最快(上升)
    • 沿 − ∇ f ( 1 , 1 , 0 ) - \nabla f(1,1,0) f(1,1,0) 方向,增加最快(下降)
    • m a x { ∂ f ∂ l ∣ p } = ∣ g r a d   f ∣ = ∣ ∇ f ( 1 , 1 , 0 ) ∣ = 3 max\{\frac{\partial f}{\partial l} |_p\} = |grad \ f| = |\nabla f(1,1,0)| = 3 max{lfp}=grad f=f(1,1,0)=3
    • m i n { ∂ f ∂ l ∣ p } = − ∣ g r a d   f ∣ = − ∣ ∇ f ( 1 , 1 , 0 ) ∣ = − 3 min\{\frac{\partial f}{\partial l} |_p\} = -|grad \ f| = -|\nabla f(1,1,0)| = -3 min{lfp}=grad f=f(1,1,0)=3

你可能感兴趣的:(AI,Mathematics,AI,数学,方向导数,计算,梯度)