链式法则

链式法则，台湾地区亦称连锁律（英語：Chain rule），用于求合成函数的導數。 兩函數 f {\displaystyle f} 和 g {\displaystyle g} 的定義域 ( D f {\displaystyle D_{f}} 和 D g {\displaystyle D_{g}} ) 、值域 ( I f {\displaystyle I_{f}} 和 I g {\displaystyle I_{g}} ) 都包含於實數系 R {\displaystyle \mathbb {R} } ，若可以定義合成函數 g ∘ f {\displaystyle g\circ f} (也就是 I f ∩ D g ≠ ∅ {\displaystyle I_{f}\cap D_{g}\neq \varnothing } )，且 f {\displaystyle f} 於 a ∈ D f {\displaystyle a\in D_{f}} 可微分，且 g {\displaystyle g} 於 f ( a ) ∈ I f ∩ D g {\displaystyle f(a)\in I_{f}\cap D_{g}} 可微分，則 ( g ∘ f ) ′ ( a ) = g ′ [ f ( a ) ] ⋅ f ′ ( a ) {\displaystyle {(g\circ f)}^{\prime }(a)=g^{\prime }[f(a)]\cdot f^{\prime }(a)} 也可以寫成 d g [ f ( x ) ] d x | x = a = d g ( y ) d y | y = f ( a ) ⋅ d f d x | x = a {\displaystyle {\frac {dg[f(x)]}{dx}}{\bigg |}_{x=a}={\frac {dg(y)}{dy}}{\bigg |}_{y=f(a)}\cdot {\frac {df}{dx}}{\bigg |}_{x=a}} 求函数 f ( x ) = ( x 2 + 1 ) 3 {\displaystyle f(x)=(x^{2}+1)^{3}} 的导数。 设 g ( x ) = x 2 + 1 {\displaystyle g(x)=x^{2}+1} h ( g ) = g 3 → h ( g ( x ) ) = g ( x ) 3 . {\displaystyle h(g)=g^{3}\to h(g(x))=g(x)^{3}.} f ( x ) = h ( g ( x ) ) {\displaystyle f(x)=h(g(x))} f ′ ( x ) = h ′ ( g ( x ) ) g ′ ( x ) = 3 ( g ( x ) ) 2 ( 2 x ) = 3 ( x 2 + 1 ) 2 ( 2 x ) = 6 x ( x 2 + 1 ) 2 . {\displaystyle f'(x)=h'(g(x))g'(x)=3(g(x))^{2}(2x)=3(x^{2}+1)^{2}(2x)=6x(x^{2}+1)^{2}.} 求函数 arctan sin x {\displaystyle \arctan \,\sin \,x} 的导数。 d d x arctan x = 1 1 + x 2 {\displaystyle {\frac {d}{dx}}\arctan \,x\,=\,{\frac {1}{1+x^{2}}}} d d x arctan f ( x ) = f ′ ( x ) 1 + f 2 ( x ) {\displaystyle {\frac {d}{dx}}\arctan \,f(x)\,=\,{\frac {f'(x)}{1+f^{2}(x)}}} d d x arctan sin x = cos x 1 + sin 2 x {\displaystyle {\frac {d}{dx}}\arctan \,\sin \,x\,=\,{\frac {\cos \,x}{1+\sin ^{2}\,x}}} 嚴謹的證明需要以下連續函數的極限定理： f {\displaystyle f} 和 g {\displaystyle g} 都是实函数，若可以定義合成函數 g ∘ f {\displaystyle g\circ f} 且 lim x → a f ( x ) = L {\displaystyle \lim _{x\to a}f(x)=L} lim y → L g ( y ) = g ( L ) {\displaystyle \lim _{y\to L}g(y)=g(L)} 則有 lim x → a g [ f ( x ) ] = g ( L ) {\displaystyle \lim _{x\to a}g[f(x)]=g(L)} 只要展開極限的δ-ε定義，並考慮 f ( x ) {\displaystyle f(x)} 等於或不等於 L {\displaystyle L} 的兩種狀況，這個極限定理就可以得証。 為了證明連鎖律，定義一個函數 G {\displaystyle G} ，其定義域 D G = D g {\displaystyle D_{G}=D_{g}} ， 而對應規則為 G ( y ) = { g ( y ) − g [ f ( a ) ] y − f ( a ) y ≠ f ( a ) g ′ [ f ( a ) ] y = f ( a ) {\displaystyle G(y)={\begin{cases}\displaystyle {\frac {g(y)-g[f(a)]}{y-f(a)}}&y\neq f(a)\\\\g^{\prime }[f(a)]&y=f(a)\end{cases}}} 和一個函數 F {\displaystyle F} ，其定義域 D F = D f {\displaystyle D_{F}=D_{f}} ， 而對應規則為 F ( x ) = { f ( x ) − f ( a ) x − a x ≠ a f ′ ( a ) x = a {\displaystyle F(x)={\begin{cases}\displaystyle {\frac {f(x)-f(a)}{x-a}}&x\neq a\\\\f^{\prime }(a)&x=a\end{cases}}} 這樣，考慮到 g ∘ f {\displaystyle g\circ f} 於 a {\displaystyle a} 的導數是以下函數（定義域為 D g ∘ f {\displaystyle D_{g\,\circ f}} ）的極限 lim x → a g ( y ) − g [ f ( a ) ] x − a = lim x → a G [ f ( x ) ] ⋅ F ( x ) {\displaystyle \lim _{x\to a}{\frac {g(y)-g[f(a)]}{x-a}}=\lim _{x\to a}G[f(x)]\cdot F(x)} 因為可微則必連續（根據乘法的極限性質），所以 f {\displaystyle f} 於 a {\displaystyle a} 連續、 G {\displaystyle G} 於 f ( a ) {\displaystyle f(a)} 連續，故根據上面的極限定理有 lim x → a G [ f ( x ) ] = g ′ [ f ( a ) ] {\displaystyle \lim _{x\to a}G[f(x)]=g^{\prime }[f(a)]} 而且針對一開始可微的前提有 lim x → a F ( x ) = f ′ ( a ) {\displaystyle \lim _{x\to a}F(x)=f^{\prime }(a)} 再根據乘法的極限性質有 lim x → a g ( y ) − g [ f ( a ) ] x − a = g ′ [ f ( a ) ] ⋅ f ′ ( a ) {\displaystyle \lim _{x\to a}{\frac {g(y)-g[f(a)]}{x-a}}=g^{\prime }[f(a)]\cdot f^{\prime }(a)} 即為所求。 ◻ {\displaystyle \Box } 考虑函数z = f(x, y)，其中x = g(t)，y = h(t)，g(t)和h(t)是可微函数，那么：   d z d t = ∂ z ∂ x d x d t + ∂ z ∂ y d y d t . {\displaystyle {\ dz \over dt}={\partial z \over \partial x}{dx \over dt}+{\partial z \over \partial y}{dy \over dt}.} 假设z = f(u, v)的每一个自变量都是二元函数，也就是说，u = h(x, y)，v = g(x, y)，且这些函数都是可微的。那么，z的偏导数为： ∂ z ∂ x = ∂ z ∂ u ∂ u ∂ x + ∂ z ∂ v ∂ v ∂ x {\displaystyle {\partial z \over \partial x}={\partial z \over \partial u}{\partial u \over \partial x}+{\partial z \over \partial v}{\partial v \over \partial x}} ∂ z ∂ y = ∂ z ∂ u ∂ u ∂ y + ∂ z ∂ v ∂ v ∂ y . {\displaystyle {\partial z \over \partial y}={\partial z \over \partial u}{\partial u \over \partial y}+{\partial z \over \partial v}{\partial v \over \partial y}.} 如果我们考虑 r → = ( u , v ) {\displaystyle {\vec {r}}=(u,v)} 为一个向量函数，我们可以用向量的表示法把以上的公式写成f的梯度与 r → {\displaystyle {\vec {r}}} 的偏导数的数量积： ∂ f ∂ x = ∇ → f ⋅ ∂ r → ∂ x . {\displaystyle {\frac {\partial f}{\partial x}}={\vec {\nabla }}f\cdot {\frac {\partial {\vec {r}}}{\partial x}}.} 更一般地，对于从向量到向量的函数，求导法则为： ∂ ( z 1 , … , z m ) ∂ ( x 1 , … , x p ) = ∂ ( z 1 , … , z m ) ∂ ( y 1 , … , y n ) ∂ ( y 1 , … , y n ) ∂ ( x 1 , … , x p ) . {\displaystyle {\frac {\partial (z_{1},\ldots ,z_{m})}{\partial (x_{1},\ldots ,x_{p})}}={\frac {\partial (z_{1},\ldots ,z_{m})}{\partial (y_{1},\ldots ,y_{n})}}{\frac {\partial (y_{1},\ldots ,y_{n})}{\partial (x_{1},\ldots ,x_{p})}}.} 复合函数的最初几个高阶导数为： d ( f ∘ g ) d x = d f d g d g d x {\displaystyle {\frac {d(f\circ g)}{dx}}={\frac {df}{dg}}{\frac {dg}{dx}}} d 2 ( f ∘ g ) d x 2 = d 2 f d g 2 ( d g d x ) 2 + d f d g d 2 g d x 2 {\displaystyle {\frac {d^{2}(f\circ g)}{dx^{2}}}={\frac {d^{2}f}{dg^{2}}}\left({\frac {dg}{dx}}\right)^{2}+{\frac {df}{dg}}{\frac {d^{2}g}{dx^{2}}}} d 3 ( f ∘ g ) d x 3 = d 3 f d g 3 ( d g d x ) 3 + 3 d 2 f d g 2 d g d x d 2 g d x 2 + d f d g d 3 g d x 3 {\displaystyle {\frac {d^{3}(f\circ g)}{dx^{3}}}={\frac {d^{3}f}{dg^{3}}}\left({\frac {dg}{dx}}\right)^{3}+3{\frac {d^{2}f}{dg^{2}}}{\frac {dg}{dx}}{\frac {d^{2}g}{dx^{2}}}+{\frac {df}{dg}}{\frac {d^{3}g}{dx^{3}}}} d 4 ( f ∘ g ) d x 4 = d 4 f d g 4 ( d g d x ) 4 + 6 d 3 f d g 3 ( d g d x ) 2 d 2 g d x 2 + d 2 f d g 2 { 4 d g d x d 3 g d x 3 + 3 ( d 2 g d x 2 ) 2 } + d f d g d 4 g d x 4 . {\displaystyle {\frac {d^{4}(f\circ g)}{dx^{4}}}={\frac {d^{4}f}{dg^{4}}}\left({\frac {dg}{dx}}\right)^{4}+6{\frac {d^{3}f}{dg^{3}}}\left({\frac {dg}{dx}}\right)^{2}{\frac {d^{2}g}{dx^{2}}}+{\frac {d^{2}f}{dg^{2}}}\left\{4{\frac {dg}{dx}}{\frac {d^{3}g}{dx^{3}}}+3\left({\frac {d^{2}g}{dx^{2}}}\right)^{2}\right\}+{\frac {df}{dg}}{\frac {d^{4}g}{dx^{4}}}.} 乘积法则 除法定则