模块 4 定义了函数 f f f 在 x x x 处的导数为一个极限,
f ′ ( x ) = lim h → 0 f ( x + h ) − f ( x ) h , f'(x) = \lim_{h\to0}\frac{f(x + h) - f(x)}{h}, f ′ ( x ) = h → 0 lim h f ( x + h ) − f ( x ) ,
并对最简单的函数进行了推导:常数的导数为 0,且 d d x x n = n x n − 1 \dfrac{d}{dx}x^n = nx^{n-1} d x d x n = n x n − 1 对于每个正整数 n n n (即 幂法则 )都有导数。它还证明了两个规则,用于从已有导数构建新的导数:和或差的导数等于导数的和或差,即 ( f ± g ) ′ = f ′ ± g ′ , (f \pm g)' = f' \pm g'\mathclose{\text{,}} ( f ± g ) ′ = f ′ ± g ′ , 以及常数因子保持不变,即 ( c f ) ′ = c f ′ 。 (cf)' = cf'\mathclose{\text{。}} ( c f ) ′ = c f ′ 。 利用这些规则,可以逐项对多项式进行求导:
d d x ( 4 x 3 − 5 x 2 + 7 ) = 12 x 2 − 10 x . \frac{d}{dx}\big(4x^3 - 5x^2 + 7\big) = 12x^2 - 10x. d x d ( 4 x 3 − 5 x 2 + 7 ) = 12 x 2 − 10 x .
大多数函数都是由和与常数倍以外的运算构建而成。x 2 sin x x^2\sin x x 2 sin x 是一个乘积,1 1 + x 2 \dfrac{1}{1 + x^2} 1 + x 2 1 是一个商,sin ( x 2 ) \sin(x^2) sin ( x 2 ) 和1 + x 2 \sqrt{1 + x^2} 1 + x 2 是复合运算(第1.5节 )。每种情况都可以从定义出发进行求导,每次都需推导一个新的极限。本模块一次完成这项工作:它为每种将两个函数组合的方式证明一个规则,并求出三角函数的导数。之后,一个公式的导数将按照该公式是如何构建的来求得。
构建为
其导数
证明于
f + g f + g f + g
f ′ + g ′ f' + g' f ′ + g ′
模块 4
c f , cf\mathclose{\text{,}} c f , c c c 是一个常数
c f ′ cf' c f ′
模块 4
f g fg f g
f ′ g + f g ′ f'g + fg' f ′ g + f g ′
第5.2节
f g \dfrac{f}{g} g f
f ′ g − f g ′ g 2 \dfrac{f'g - fg'}{g^2} g 2 f ′ g − f g ′
第5.3节
f ( g ( x ) ) f\big(g(x)\big) f ( g ( x ) )
f ′ ( g ( x ) ) g ′ ( x ) f'\big(g(x)\big)\,g'(x) f ′ ( g ( x ) ) g ′ ( x )
第5.5节
证明使用了早期模块中的三个事实:在某一点可导的函数在该点连续(定理 4.1 );和、积、商的极限等于这些表达式的极限的和、积、商,前提是这些极限存在且分母不为零(极限法则 of 模块 2);以及对于三角函数,两个极限 模块 2 证明了,
lim θ → 0 sin θ θ = 1 , lim θ → 0 1 − cos θ θ = 0. \lim_{\theta\to0}\frac{\sin\theta}{\theta} = 1, \qquad \lim_{\theta\to0}\frac{1 - \cos\theta}{\theta} = 0. θ → 0 lim θ sin θ = 1 , θ → 0 lim θ 1 − cos θ = 0.
第5.2至5.5节证明了规则。第5.6至5.8节将它们应用于实际:一种将它们结合起来的策略,使用SymPy计算导数的方法,以及程序计算导数的方式。
和的导数是导数的和,因此你可能会希望积的导数是导数的积。实际上并非如此。取 f ( x ) = x f(x) = x f ( x ) = x 和 g ( x ) = x 2 。 g(x) = x^2\mathclose{\text{。}} g ( x ) = x 2 。 它们的积是 x 3 , x^3\mathclose{\text{,}} x 3 , 导数为 3 x 2 ; 3x^2\mathclose{\text{;}} 3 x 2 ; 它们的导数的积为 1 ⋅ 2 x = 2 x 。 1 \cdot 2x = 2x\mathclose{\text{。}} 1 ⋅ 2 x = 2 x 。 在 x = 1 x = 1 x = 1 处,它们分别为 3 和 2。
一个正在增长的矩形
为了找到正确的法则,想象一个乘积是一个面积。设 u = f ( x ) u = f(x) u = f ( x ) 和 v = g ( x ) v = g(x) v = g ( x ) 是一个矩形的边(为了图示,假设它们是正数),因此其面积是 A = u v 。 A = uv\mathclose{\text{。}} A = uv 。 当 x x x 增加 h h h 时,边的变化为
Δ u = f ( x + h ) − f ( x ) , Δ v = g ( x + h ) − g ( x ) , \begin{aligned} \Delta u &= f(x + h) - f(x), \\ \Delta v &= g(x + h) - g(x), \end{aligned} Δ u Δ v = f ( x + h ) − f ( x ) , = g ( x + h ) − g ( x ) ,
并且面积变为 ( u + Δ u ) ( v + Δ v ) 。 (u + \Delta u)(v + \Delta v)\mathclose{\text{。}} ( u + Δ u ) ( v + Δ v ) 。 图 5.1 将新的矩形切割成旧矩形、顶部一条面积为 u Δ v u\,\Delta v u Δ v 的条带、侧面一条面积为 v Δ u v\,\Delta u v Δ u 的条带,以及一个面积为 Δ u Δ v \Delta u\,\Delta v Δ u Δ v 的小角落:
Δ A = ( u + Δ u ) ( v + Δ v ) − u v = u Δ v + v Δ u + Δ u Δ v . \begin{aligned} \Delta A &= (u + \Delta u)(v + \Delta v) - uv \\ &= u\,\Delta v + v\,\Delta u + \Delta u\,\Delta v. \end{aligned} Δ A = ( u + Δ u ) ( v + Δ v ) − uv = u Δ v + v Δ u + Δ u Δ v .
图 5.1 乘积法则作为边长为 u = f ( x ) u = f(x) u = f ( x ) 和 v = g ( x ) v = g(x) v = g ( x ) 的增长矩形。当 x x x 变化 h h h 时,面积 u v uv uv 增加一个绿色条带 u Δ v 、 u\,\Delta v\mathclose{\text{、}} u Δ v 、 一个橙色条带 v Δ u v\,\Delta u v Δ u 和一个紫色角落 Δ u Δ v 。 \Delta u\,\Delta v\mathclose{\text{。}} Δ u Δ v 。 在右边, x x x 的变化减半,因此 Δ u \Delta u Δ u 和 Δ v \Delta v Δ v 大约减半:条带减半,但角落缩小到四分之一。
用 h h h 除以得到面积的平均变化率:
Δ A h = u Δ v h + v Δ u h + Δ u Δ v h . \frac{\Delta A}{h} = u\,\frac{\Delta v}{h} + v\,\frac{\Delta u}{h} + \Delta u\,\frac{\Delta v}{h}. h Δ A = u h Δ v + v h Δ u + Δ u h Δ v .
作为 h → 0 , h \to 0\mathclose{\text{,}} h → 0 , Δ v / h → g ′ ( x ) \Delta v/h \to g'(x) Δ v / h → g ′ ( x ) 和 Δ u / h → f ′ ( x ) , \Delta u/h \to f'(x)\mathclose{\text{,}} Δ u / h → f ′ ( x ) , 而 Δ u → 0 . \Delta u \to 0\mathclose{\text{.}} Δ u → 0 . 角落在这两个方向上都很小,因此即使除以 h h h 之后也会消失,剩下的就是 u g ′ ( x ) + v f ′ ( x ) : u\,g'(x) + v\,f'(x)\mathclose{\text{:}} u g ′ ( x ) + v f ′ ( x ) : 每一边的变化率乘以另一边。
定理 5.1乘积法则
如果 f f f 和 g g g 在 x x x 处可导,则它们的乘积 f g fg f g 也可导,并
( f g ) ′ ( x ) = f ′ ( x ) g ( x ) + f ( x ) g ′ ( x ) . (fg)'(x) = f'(x)\,g(x) + f(x)\,g'(x). ( f g ) ′ ( x ) = f ′ ( x ) g ( x ) + f ( x ) g ′ ( x ) .
在莱布尼茨记号中,对于 u = f ( x ) u = f(x) u = f ( x ) 和 v = g ( x ) : v = g(x)\mathclose{\text{:}} v = g ( x ) : d d x ( u v ) = d u d x v + u d v d x . \dfrac{d}{dx}(uv) = \dfrac{du}{dx}\,v + u\,\dfrac{dv}{dx}\mathclose{\text{.}} d x d ( uv ) = d x d u v + u d x d v .
证明
证明将图示转化为极限。设 f f f 和 g g g 分别为 f ( x ) f(x) f ( x ) 和 g ( x ) , g(x)\mathclose{\text{,}} g ( x ) , 对于 h ≠ 0 h \ne 0 h = 0 设 Δ f = f ( x + h ) − f ( x ) \Delta f = f(x + h) - f(x) Δ f = f ( x + h ) − f ( x ) 和 Δ g = g ( x + h ) − g ( x ) , \Delta g = g(x + h) - g(x)\mathclose{\text{,}} Δ g = g ( x + h ) − g ( x ) , 使得 f ( x + h ) = f + Δ f f(x + h) = f + \Delta f f ( x + h ) = f + Δ f 和 g ( x + h ) = g + Δ g 。 g(x + h) = g + \Delta g\mathclose{\text{。}} g ( x + h ) = g + Δ g 。 将乘积展开,如同矩形一样,并除以 h : h\mathclose{\text{:}} h :
f ( x + h ) g ( x + h ) − f g h = ( f + Δ f ) ( g + Δ g ) − f g h = Δ f h g + f Δ g h + Δ f Δ g h . \begin{aligned} &\frac{f(x + h)\,g(x + h) - fg}{h} \\ &\quad= \frac{(f + \Delta f)(g + \Delta g) - fg}{h} \\ &\quad= \frac{\Delta f}{h}\,g + f\,\frac{\Delta g}{h} + \Delta f\,\frac{\Delta g}{h}. \end{aligned} h f ( x + h ) g ( x + h ) − f g = h ( f + Δ f ) ( g + Δ g ) − f g = h Δ f g + f h Δ g + Δ f h Δ g .
现在令 h → 0 。 h \to 0\mathclose{\text{。}} h → 0 。 由于 f f f 和 g g g 在 x x x 处可微,故有 Δ f / h → f ′ ( x ) \Delta f/h \to f'(x) Δ f / h → f ′ ( x ) 和 Δ g / h → g ′ ( x ) 。 \Delta g/h \to g'(x)\mathclose{\text{。}} Δ g / h → g ′ ( x ) 。 又因为在 x x x 处可微的函数也在那里连续(定理 4.1),所以 Δ f → 0 。 \Delta f \to 0\mathclose{\text{。}} Δ f → 0 。 由和与积的极限法则,该式趋于 f ′ ( x ) g ( x ) + f ( x ) g ′ ( x ) + 0 ⋅ g ′ ( x ) , f'(x)\,g(x) + f(x)\,g'(x) + 0\cdot g'(x)\mathclose{\text{,}} f ′ ( x ) g ( x ) + f ( x ) g ′ ( x ) + 0 ⋅ g ′ ( x ) , 这就是乘积法则。
∎
导数的乘积法则:第一个因子的导数乘以第二个因子,加上第一个因子乘以第二个因子的导数。证明的最后一项 Δ f Δ g / h \Delta f\,\Delta g/h Δ f Δ g / h 是图的角落,而 f f f 的连续性使其消失。
假设是证明所需要的,而不是乘积需要导数的条件。如果 f f f 或 g g g 在 x x x 处不可导,定理则无话可说: ∣ x ∣ \abs{x} ∣ x ∣ 在 0 处没有导数(其图像在该点有拐角),但 ∣ x ∣ ⋅ ∣ x ∣ = x 2 \abs{x}\cdot\abs{x} = x^2 ∣ x ∣ ⋅ ∣ x ∣ = x 2 有。
例 5.1乘积的两种求导方法 ✓ 已检验
用乘积法则对 F ( x ) = ( x 2 + 1 ) ( x 3 − 2 x ) F(x) = (x^2 + 1)(x^3 - 2x) F ( x ) = ( x 2 + 1 ) ( x 3 − 2 x ) 求导,并通过先展开来验证。
对于 f ( x ) = x 2 + 1 f(x) = x^2 + 1 f ( x ) = x 2 + 1 和 g ( x ) = x 3 − 2 x , g(x) = x^3 - 2x\mathclose{\text{,}} g ( x ) = x 3 − 2 x , 导数分别是 f ′ ( x ) = 2 x f'(x) = 2x f ′ ( x ) = 2 x 和 g ′ ( x ) = 3 x 2 − 2 , g'(x) = 3x^2 - 2\mathclose{\text{,}} g ′ ( x ) = 3 x 2 − 2 , 因此
F ′ ( x ) = 2 x ( x 3 − 2 x ) + ( x 2 + 1 ) ( 3 x 2 − 2 ) = ( 2 x 4 − 4 x 2 ) + ( 3 x 4 + x 2 − 2 ) = 5 x 4 − 3 x 2 − 2. \begin{aligned} F'(x) &= 2x(x^3 - 2x) \\ &\quad + (x^2 + 1)(3x^2 - 2) \\ &= (2x^4 - 4x^2) + (3x^4 + x^2 - 2) \\ &= 5x^4 - 3x^2 - 2. \end{aligned} F ′ ( x ) = 2 x ( x 3 − 2 x ) + ( x 2 + 1 ) ( 3 x 2 − 2 ) = ( 2 x 4 − 4 x 2 ) + ( 3 x 4 + x 2 − 2 ) = 5 x 4 − 3 x 2 − 2.
先展开: F ( x ) = x 5 − 2 x 3 + x 3 − 2 x = x 5 − x 3 − 2 x , F(x) = x^5 - 2x^3 + x^3 - 2x = x^5 - x^3 - 2x\mathclose{\text{,}} F ( x ) = x 5 − 2 x 3 + x 3 − 2 x = x 5 − x 3 − 2 x , 因此 F ′ ( x ) = 5 x 4 − 3 x 2 − 2 , F'(x) = 5x^4 - 3x^2 - 2\mathclose{\text{,}} F ′ ( x ) = 5 x 4 − 3 x 2 − 2 , 相同的结果。
展开适用于多项式。乘积法则适用于所有乘积,包括无法展开的乘积,如 x 2 sin x x^2\sin x x 2 sin x (第 5.4 节),并且它仅需数字即可应用。
例 5.2电路中的功率 ✓ 已检验
一个元件所接收的电功率是 P = V I , P = VI\mathclose{\text{,}} P = V I , 等于其两端的电压乘以通过它的电流。假设在某一瞬间,电压为 12 V 并以 0.5 V 每秒的速率下降,而电流为 2 A 并以 0.1 A 每秒的速率上升。此时功率是增加还是减少?变化率是多少?
V V V 和 I I I 是时间 t t t 的函数,且在该时刻 V = 12 , V = 12\mathclose{\text{,}} V = 12 , V ′ = − 0.5 , V' = -0.5\mathclose{\text{,}} V ′ = − 0.5 , I = 2 I = 2 I = 2 和 I ′ = 0.1 。 I' = 0.1\mathclose{\text{。}} I ′ = 0.1 。 根据乘积法则,
P ′ = V ′ I + V I ′ = ( − 0.5 ) ( 2 ) + ( 12 ) ( 0.1 ) = − 1 + 1.2 = 0.2. \begin{aligned} P' &= V'I + VI' \\ &= (-0.5)(2) + (12)(0.1) \\ &= -1 + 1.2 = 0.2. \end{aligned} P ′ = V ′ I + V I ′ = ( − 0.5 ) ( 2 ) + ( 12 ) ( 0.1 ) = − 1 + 1.2 = 0.2.
功率正在增加,增加速率为 0.2 瓦特每秒:电流的增加超过了电压的减少。
乘积法则被使用两次,用于对三个函数的乘积进行求导:
( f g k ) ′ = ( ( f g ) k ) ′ = ( f g ) ′ k + ( f g ) k ′ = f ′ g k + f g ′ k + f g k ′ . \begin{aligned} (fgk)' &= \big((fg)k\big)' = (fg)'k + (fg)k' \\ &= f'gk + fg'k + fgk'. \end{aligned} ( f g k ) ′ = ( ( f g ) k ) ′ = ( f g ) ′ k + ( f g ) k ′ = f ′ g k + f g ′ k + f g k ′ .
每一项对一个因子进行求导,而对其他因子保持不变;练习 5.10 进一步说明了这一点。
注意
( f g ) ′ = f ′ g ′ (fg)' = f'g' ( f g ) ′ = f ′ g ′ 是错误的,如 x ⋅ x 2 x \cdot x^2 x ⋅ x 2 所示。记住正确法则的两种方法:每一项恰好对一个因子进行求导;在矩形中,每一边的变化在另一边扫出一个条带。
一个分数在分子变化时和分母变化时都会改变,这两种变化效果方向相反:分子变大使得分数变大,分母变大使得分数变小。这个规则包含这两种效果,中间用减号连接。
定理 5.2商法则
如果 f f f 和 g g g 在 x x x 和 g ( x ) ≠ 0 g(x) \ne 0 g ( x ) = 0 处可导,则 f / g f/g f / g 在 x x x 处可导,并且
( f g ) ′ ( x ) = f ′ ( x ) g ( x ) − f ( x ) g ′ ( x ) g ( x ) 2 . \Big(\frac{f}{g}\Big)'(x) = \frac{f'(x)\,g(x) - f(x)\,g'(x)}{g(x)^2}. ( g f ) ′ ( x ) = g ( x ) 2 f ′ ( x ) g ( x ) − f ( x ) g ′ ( x ) .
证明
首先,f / g f/g f / g 在 x x x 附近有定义。g g g 在 x x x 处连续,因此 h h h 充分接近 0 时,g ( x + h ) g(x + h) g ( x + h ) 接近非零的 g ( x ) , g(x)\mathclose{\text{,}} g ( x ) , 所以 g ( x + h ) ≠ 0 。 g(x + h) \ne 0\mathclose{\text{。}} g ( x + h ) = 0 。 对这样的 h ≠ 0 , h \ne 0\mathclose{\text{,}} h = 0 , 沿用定理 5.1 证明中的 f 、 f\mathclose{\text{、}} f 、 g 、 g\mathclose{\text{、}} g 、 Δ f 、 \Delta f\mathclose{\text{、}} Δ f 、 Δ g , \Delta g\mathclose{\text{,}} Δ g , 把两个分式通分:
f + Δ f g + Δ g − f g = ( f + Δ f ) g − f ( g + Δ g ) g ( g + Δ g ) = Δ f ⋅ g − f ⋅ Δ g g ( g + Δ g ) . \begin{aligned} &\frac{f + \Delta f}{g + \Delta g} - \frac{f}{g} \\ &\quad= \frac{(f + \Delta f)\,g - f\,(g + \Delta g)}{g\,(g + \Delta g)} \\ &\quad= \frac{\Delta f\cdot g - f\cdot\Delta g}{g\,(g + \Delta g)}. \end{aligned} g + Δ g f + Δ f − g f = g ( g + Δ g ) ( f + Δ f ) g − f ( g + Δ g ) = g ( g + Δ g ) Δ f ⋅ g − f ⋅ Δ g .
用 h h h 除以,
1 h ( f ( x + h ) g ( x + h ) − f ( x ) g ( x ) ) = Δ f h g − f Δ g h g ( g + Δ g ) . \begin{aligned} &\frac{1}{h}\Big(\frac{f(x + h)}{g(x + h)} - \frac{f(x)}{g(x)}\Big) \\ &\quad= \frac{\dfrac{\Delta f}{h}\,g - f\,\dfrac{\Delta g}{h}}{g\,(g + \Delta g)}. \end{aligned} h 1 ( g ( x + h ) f ( x + h ) − g ( x ) f ( x ) ) = g ( g + Δ g ) h Δ f g − f h Δ g .
如 h → 0 , h \to 0\mathclose{\text{,}} h → 0 , Δ f / h → f ′ ( x ) \Delta f/h \to f'(x) Δ f / h → f ′ ( x ) 和 Δ g / h → g ′ ( x ) , \Delta g/h \to g'(x)\mathclose{\text{,}} Δ g / h → g ′ ( x ) , 以及 Δ g → 0 \Delta g \to 0 Δ g → 0 因为 g g g 在 x x x 处连续。因此分母趋于 g ( x ) 2 , g(x)^2\mathclose{\text{,}} g ( x ) 2 , 不等于 0,根据极限法则,表达式趋于 f ′ ( x ) g ( x ) − f ( x ) g ′ ( x ) g ( x ) 2 。 \dfrac{f'(x)g(x) - f(x)g'(x)}{g(x)^2}\mathclose{\text{。}} g ( x ) 2 f ′ ( x ) g ( x ) − f ( x ) g ′ ( x ) 。
∎
分子是乘积法则的 f ′ g + f g ′ f'g + fg' f ′ g + f g ′ 带一个负号,因此顺序是有区别的:导数在上边的先求。有些人用口诀帮助记忆:“低导高减高导低,除以下面的平方”。
例 5.3多项式的商 ✓ 已检验
对 y = x 2 − 1 x 2 + 1 y = \dfrac{x^2 - 1}{x^2 + 1} y = x 2 + 1 x 2 − 1 求导,并找出其切线水平的点。
分母 x 2 + 1 x^2 + 1 x 2 + 1 永远不为 0,因此规则在每个 x x x 都适用。Both x 2 − 1 x^2 - 1 x 2 − 1 和 x 2 + 1 x^2 + 1 x 2 + 1 的导数都是 2 x : 2x\mathclose{\text{:}} 2 x :
y ′ = 2 x ( x 2 + 1 ) − ( x 2 − 1 ) ( 2 x ) ( x 2 + 1 ) 2 = 2 x 3 + 2 x − 2 x 3 + 2 x ( x 2 + 1 ) 2 = 4 x ( x 2 + 1 ) 2 . \begin{aligned} y' &= \frac{2x(x^2 + 1) - (x^2 - 1)(2x)}{(x^2 + 1)^2} \\ &= \frac{2x^3 + 2x - 2x^3 + 2x}{(x^2 + 1)^2} \\ &= \frac{4x}{(x^2 + 1)^2}. \end{aligned} y ′ = ( x 2 + 1 ) 2 2 x ( x 2 + 1 ) − ( x 2 − 1 ) ( 2 x ) = ( x 2 + 1 ) 2 2 x 3 + 2 x − 2 x 3 + 2 x = ( x 2 + 1 ) 2 4 x .
切线水平的点是 y ′ = 0 。 y' = 0\mathclose{\text{。}} y ′ = 0 。 分数为 0 当其分子为 0,因此 4 x = 0 : 4x = 0\mathclose{\text{:}} 4 x = 0 : 仅在 x = 0 x = 0 x = 0 处,点 ( 0 , − 1 ) 。 (0, -1)\mathclose{\text{。}} ( 0 , − 1 ) 。 这是图像的最低点。确实,写出 x 2 − 1 = ( x 2 + 1 ) − 2 x^2 - 1 = (x^2 + 1) - 2 x 2 − 1 = ( x 2 + 1 ) − 2 得到 y = 1 − 2 x 2 + 1 ; y = 1 - \dfrac{2}{x^2 + 1}\mathclose{\text{;}} y = 1 − x 2 + 1 2 ; 由于 x 2 + 1 ≥ 1 , x^2 + 1 \ge 1\mathclose{\text{,}} x 2 + 1 ≥ 1 , 分数最大为 2,因此 y ≥ 1 − 2 = − 1 。 y \ge 1 - 2 = -1\mathclose{\text{。}} y ≥ 1 − 2 = − 1 。 在 0 左边斜率为负,在右边斜率为正。
负幂
商法则完成整数幂法则。
定理 5.3整数幂法则
对于每个整数 n , n\mathclose{\text{,}} n ,
d d x x n = n x n − 1 , \frac{d}{dx}x^n = nx^{n-1}, d x d x n = n x n − 1 ,
对于每个 x , x\mathclose{\text{,}} x , 如果 n ≥ 1 , n \ge 1\mathclose{\text{,}} n ≥ 1 , 并且对于每个 x ≠ 0 , x \ne 0\mathclose{\text{,}} x = 0 , 如果 n ≤ 0 。 n \le 0\mathclose{\text{。}} n ≤ 0 。
证明
模块 4 证明了 n ≥ 1 n \ge 1 n ≥ 1 的情况。对于 n = 0 , n = 0\mathclose{\text{,}} n = 0 , x 0 = 1 x^0 = 1 x 0 = 1 是常数,导数为 0 = 0 ⋅ x − 1 。 0 = 0 \cdot x^{-1}\mathclose{\text{。}} 0 = 0 ⋅ x − 1 。 如果 n n n 为负数,写成 n = − m , n = -m\mathclose{\text{,}} n = − m , 其中 m m m 是正整数,使得 x n = 1 / x m x^n = 1/x^m x n = 1/ x m 对于 x ≠ 0 。 x \ne 0\mathclose{\text{。}} x = 0 。 根据商法则,分子为 1(导数为 0),分母为 x m x^m x m (导数为 m x m − 1 ), mx^{m-1}\mathclose{\text{),}} m x m − 1 ),
d d x 1 x m = 0 ⋅ x m − 1 ⋅ m x m − 1 ( x m ) 2 = − m x m − 1 x 2 m = − m x − m − 1 , \begin{aligned} \frac{d}{dx}\frac{1}{x^m} &= \frac{0 \cdot x^m - 1 \cdot mx^{m-1}}{(x^m)^2} \\ &= \frac{-mx^{m-1}}{x^{2m}} = -mx^{-m-1}, \end{aligned} d x d x m 1 = ( x m ) 2 0 ⋅ x m − 1 ⋅ m x m − 1 = x 2 m − m x m − 1 = − m x − m − 1 ,
和 − m x − m − 1 = n x n − 1 。 -mx^{-m-1} = nx^{n-1}\mathclose{\text{。}} − m x − m − 1 = n x n − 1 。
∎
例如, d d x 1 x = d d x x − 1 = − x − 2 = − 1 x 2 , \dfrac{d}{dx}\dfrac{1}{x} = \dfrac{d}{dx}x^{-1} = -x^{-2} = -\dfrac{1}{x^2}\mathclose{\text{,}} d x d x 1 = d x d x − 1 = − x − 2 = − x 2 1 , 这个数是 1 / x 1/x 1/ x 在区间 练习 1.9 中差商的极限。
例 5.4重力减弱的速度 ✓ 已检验
距离为 r r r 的两个物体之间的引力为 F ( r ) = k r 2 , F(r) = \dfrac{k}{r^2}\mathclose{\text{,}} F ( r ) = r 2 k , 其中 k > 0 k > 0 k > 0 是一个依赖于它们质量的常数。 F F F 随 r r r 变化有多快?
写出 F ( r ) = k r − 2 , F(r) = kr^{-2}\mathclose{\text{,}} F ( r ) = k r − 2 , 并使用幂法则,其中 n = − 2 : n = -2\mathclose{\text{:}} n = − 2 :
F ′ ( r ) = k ⋅ ( − 2 ) r − 3 = − 2 k r 3 . F'(r) = k \cdot (-2)r^{-3} = -\frac{2k}{r^3}. F ′ ( r ) = k ⋅ ( − 2 ) r − 3 = − r 3 2 k .
导数为负:距离增大时,引力减弱。将其与 F F F 本身进行比较:F ′ ( r ) = − 2 r ⋅ k r 2 = − 2 r F ( r ) 。 F'(r) = -\dfrac{2}{r}\cdot\dfrac{k}{r^2} = -\dfrac{2}{r}F(r)\mathclose{\text{。}} F ′ ( r ) = − r 2 ⋅ r 2 k = − r 2 F ( r ) 。 在 r r r 附近,函数 F F F 的图像接近其切线(模块 4),因此向外迈出一个小步 Δ r , \Delta r\mathclose{\text{,}} Δ r , 引力的变化大约为
F ′ ( r ) Δ r = − 2 Δ r r F ( r ) : F'(r)\,\Delta r = -2\,\frac{\Delta r}{r}\,F(r): F ′ ( r ) Δ r = − 2 r Δ r F ( r ) :
向外移动 1% 的距离,引力减弱约 2%。(精确值:1 / 1.01 2 ≈ 0.9803 , 1/1.01^2 \approx 0.9803\mathclose{\text{,}} 1/1.0 1 2 ≈ 0.9803 , 损失约 1.97%。)
注意
( f g ) ′ = f ′ g ′ \Big(\dfrac{f}{g}\Big)' = \dfrac{f'}{g'} ( g f ) ′ = g ′ f ′ 是错误的。对于 x ≠ 0 , x \ne 0\mathclose{\text{,}} x = 0 , 在 x 2 x = x \dfrac{x^2}{x} = x x x 2 = x 处导数为 1,但 ( x 2 ) ′ ( x ) ′ = 2 x 1 = 2 x 。 \dfrac{(x^2)'}{(x)'} = \dfrac{2x}{1} = 2x\mathclose{\text{。}} ( x ) ′ ( x 2 ) ′ = 1 2 x = 2 x 。 保持分子中的顺序 f ′ g − f g ′ : f'g - fg'\mathclose{\text{:}} f ′ g − f g ′ : 交换顺序会改变答案的符号。使用最简单的工具:对于 3 x 4 = 3 x − 4 , \dfrac{3}{x^4} = 3x^{-4}\mathclose{\text{,}} x 4 3 = 3 x − 4 , 幂法则比商法则更快,而对于 x 3 + x 5 , \dfrac{x^3 + x}{5}\mathclose{\text{,}} 5 x 3 + x , 分母为常数时,常数倍法则适用。
图5.2显示了sin x \sin x sin x 的图像及其部分切线。在x = 0 x = 0 x = 0 处,图像以斜率1上升;在峰顶x = π / 2 x = \pi/2 x = π /2 处,图像是水平的;在x = π x = \pi x = π 处,图像以斜率− 1 -1 − 1 下降;在谷底x = 3 π / 2 x = 3\pi/2 x = 3 π /2 处,图像再次是水平的;在x = 2 π x = 2\pi x = 2 π 处,图像再次以斜率1上升。这些斜率,即1 , 0 , − 1 , 0 , 1 , 1, 0, -1, 0, 1\mathclose{\text{,}} 1 , 0 , − 1 , 0 , 1 , 是cos x \cos x cos x 在相同点的值。该表格将sin x \sin x sin x 的差商与h = 0.001 h = 0.001 h = 0.001 在更多点与cos x \cos x cos x 进行了比较:
x x x sin ( x + 0.001 ) − sin x 0.001 \dfrac{\sin(x + 0.001) - \sin x}{0.001} 0.001 sin ( x + 0.001 ) − sin x cos x \cos x cos x 0 0 0 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 π 6 \frac{\pi}{6} 6 π 0.8658 0.8658 0.8658 0.8660 0.8660 0.8660 π 4 \frac{\pi}{4} 4 π 0.7068 0.7068 0.7068 0.7071 0.7071 0.7071 π 3 \frac{\pi}{3} 3 π 0.4996 0.4996 0.4996 0.5000 0.5000 0.5000 π 2 \frac{\pi}{2} 2 π − 0.0005 -0.0005 − 0.0005 0.0000 0.0000 0.0000 2 π 3 \frac{2 \pi}{3} 3 2 π − 0.5004 -0.5004 − 0.5004 − 0.5000 -0.5000 − 0.5000 π \pi π − 1.0000 -1.0000 − 1.0000 − 1.0000 -1.0000 − 1.0000
每一行的两列在0.0005以内一致,更小的h h h 会使一致性更接近。
图 5.2 顶:y = sin x y = \sin x y = sin x 在 0 、 0\mathclose{\text{、}} 0 、 π / 2 、 \pi/2\mathclose{\text{、}} π /2 、 π 、 \pi\mathclose{\text{、}} π 、 3 π / 2 3\pi/2 3 π /2 和 2 π 2\pi 2 π 处有切线,其斜率是 1 , 0 , − 1 , 0 , 1 。 1, 0, -1, 0, 1\mathclose{\text{。}} 1 , 0 , − 1 , 0 , 1 。 底:y = cos x y = \cos x y = cos x 恰好通过那些值(橙色点)。当正弦曲线平坦时,即在波峰和波谷处,余弦曲线穿过零点。
原因在于模块2中的加法公式和两个极限。
定理 5.4正弦和余弦的导数
对于每一个实数 x x x (以弧度为单位),
d d x sin x = cos x , d d x cos x = − sin x . \begin{aligned} \frac{d}{dx}\sin x &= \cos x, \\ \frac{d}{dx}\cos x &= -\sin x. \end{aligned} d x d sin x d x d cos x = cos x , = − sin x .
证明
根据加法公式 sin ( x + h ) = sin x cos h + cos x sin h \sin(x + h) = \sin x\cos h + \cos x\sin h sin ( x + h ) = sin x cos h + cos x sin h (第 1.4 节 ),
sin ( x + h ) − sin x h = sin x cos h − sin x + cos x sin h h = − sin x ⋅ 1 − cos h h + cos x ⋅ sin h h . \begin{aligned} &\frac{\sin(x + h) - \sin x}{h} \\ &\quad= \frac{\sin x\cos h - \sin x + \cos x\sin h}{h} \\ &\quad= -\sin x\cdot\frac{1 - \cos h}{h} + \cos x\cdot\frac{\sin h}{h}. \end{aligned} h sin ( x + h ) − sin x = h sin x cos h − sin x + cos x sin h = − sin x ⋅ h 1 − cos h + cos x ⋅ h sin h .
这里 x x x 是固定的,只有 h h h 变化。当 h → 0 h \to 0 h → 0 时,两个分数分别趋近于 0 和 1(模块 2),因此差商趋近于 − sin x ⋅ 0 + cos x ⋅ 1 = cos x 。 -\sin x \cdot 0 + \cos x \cdot 1 = \cos x\mathclose{\text{。}} − sin x ⋅ 0 + cos x ⋅ 1 = cos x 。
对于余弦函数,加法公式 cos ( x + h ) = cos x cos h − sin x sin h \cos(x + h) = \cos x\cos h - \sin x\sin h cos ( x + h ) = cos x cos h − sin x sin h 同样给出
cos ( x + h ) − cos x h = − cos x ⋅ 1 − cos h h − sin x ⋅ sin h h , \begin{aligned} &\frac{\cos(x + h) - \cos x}{h} \\ &\quad= -\cos x\cdot\frac{1 - \cos h}{h} - \sin x\cdot\frac{\sin h}{h}, \end{aligned} h cos ( x + h ) − cos x = − cos x ⋅ h 1 − cos h − sin x ⋅ h sin h ,
其趋近于 − cos x ⋅ 0 − sin x ⋅ 1 = − sin x 。 -\cos x \cdot 0 - \sin x \cdot 1 = -\sin x\mathclose{\text{。}} − cos x ⋅ 0 − sin x ⋅ 1 = − sin x 。
∎
( cos x ) ′ = − sin x (\cos x)' = -\sin x ( cos x ) ′ = − sin x 中的负号在图中体现出来:当 x x x 略大于 0 时,余弦函数从其峰值下降,而 sin x \sin x sin x 为正。
深入一步加法公式来源于何处
模块 1 引用了学校三角学中的加法公式。这里有一个来自单位圆的证明。设 P P P 和 Q Q Q 是单位圆上角度为 x x x 和 y y y 的点。将整个图形绕角度 − y -y − y 旋转,将 Q Q Q 移动到 ( 1 , 0 ) , (1, 0)\mathclose{\text{,}} ( 1 , 0 ) , 将 P P P 移动到角度为 x − y x - y x − y 的点,旋转不会改变距离。因此,点 P P P 到 Q Q Q 的平方距离等于点 ( cos ( x − y ) , sin ( x − y ) ) \big(\cos(x - y), \sin(x - y)\big) ( cos ( x − y ) , sin ( x − y ) ) 到 ( 1 , 0 ) (1, 0) ( 1 , 0 ) 的平方距离:
( cos x − cos y ) 2 + ( sin x − sin y ) 2 = ( cos ( x − y ) − 1 ) 2 + sin 2 ( x − y ) . \begin{aligned} &(\cos x - \cos y)^2 + (\sin x - \sin y)^2 \\ &\quad= \big(\cos(x - y) - 1\big)^2 + \sin^2(x - y). \end{aligned} ( cos x − cos y ) 2 + ( sin x − sin y ) 2 = ( cos ( x − y ) − 1 ) 2 + sin 2 ( x − y ) .
展开两边并使用 sin 2 θ + cos 2 θ = 1 : \sin^2\theta + \cos^2\theta = 1\mathclose{\text{:}} sin 2 θ + cos 2 θ = 1 : 左边是 2 − 2 ( cos x cos y + sin x sin y ) , 2 - 2(\cos x\cos y + \sin x\sin y)\mathclose{\text{,}} 2 − 2 ( cos x cos y + sin x sin y ) , 右边是 2 − 2 cos ( x − y ) 。 2 - 2\cos(x - y)\mathclose{\text{。}} 2 − 2 cos ( x − y ) 。 因此
cos ( x − y ) = cos x cos y + sin x sin y . \cos(x - y) = \cos x\cos y + \sin x\sin y. cos ( x − y ) = cos x cos y + sin x sin y .
一切其余内容由此推导得出。将 y y y 替换为 − y -y − y (余弦是偶函数,正弦是奇函数)可得到以下第一个公式;取 x = π / 2 , x = \pi/2\mathclose{\text{,}} x = π /2 , 其中余弦为 0,正弦为 1,可得到第二个公式:
cos ( x + y ) = cos x cos y − sin x sin y , cos ( π 2 − y ) = sin y . \begin{aligned} \cos(x + y) &= \cos x\cos y - \sin x\sin y, \\ \cos(\tfrac{\pi}{2} - y) &= \sin y. \end{aligned} cos ( x + y ) cos ( 2 π − y ) = cos x cos y − sin x sin y , = sin y .
用 π / 2 − y \pi/2 - y π /2 − y 替换 y , y\mathclose{\text{,}} y , 第二个公式表示 sin ( π / 2 − y ) = cos y 。 \sin(\pi/2 - y) = \cos y\mathclose{\text{。}} sin ( π /2 − y ) = cos y 。 最后,
sin ( x + y ) = cos ( ( π 2 − x ) − y ) = cos ( π 2 − x ) cos y + sin ( π 2 − x ) sin y = sin x cos y + cos x sin y . \begin{aligned} \sin(x + y) &= \cos\big((\tfrac{\pi}{2} - x) - y\big) \\ &= \cos(\tfrac{\pi}{2} - x)\cos y \\ &\quad + \sin(\tfrac{\pi}{2} - x)\sin y \\ &= \sin x\cos y + \cos x\sin y. \end{aligned} sin ( x + y ) = cos ( ( 2 π − x ) − y ) = cos ( 2 π − x ) cos y + sin ( 2 π − x ) sin y = sin x cos y + cos x sin y .
为什么使用弧度. 该极限 sin h h → 1 \dfrac{\sin h}{h} \to 1 h sin h → 1 成立是因为 h h h 以弧度为单位测量的,因为它是单位圆上的弧长(模块 2)。在度数中,导数中会出现一个额外因子 π / 180 \pi/180 π /180 (例 5.8)。弧度是使正弦函数导数恰好等于余弦函数的单位。
其他四个函数
商的法则从正弦和余弦的导数推导出其他四个三角函数的导数。
定理 5.5tan、cot、sec 和 csc 的导数
其中 cos x ≠ 0 , \cos x \ne 0\mathclose{\text{,}} cos x = 0 ,
d d x tan x = sec 2 x , d d x sec x = sec x tan x , \begin{aligned} \frac{d}{dx}\tan x &= \sec^2 x, \\ \frac{d}{dx}\sec x &= \sec x\tan x, \end{aligned} d x d tan x d x d sec x = sec 2 x , = sec x tan x ,
以及其中 sin x ≠ 0 , \sin x \ne 0\mathclose{\text{,}} sin x = 0 ,
d d x cot x = − csc 2 x , d d x csc x = − csc x cot x . \begin{aligned} \frac{d}{dx}\cot x &= -\csc^2 x, \\ \frac{d}{dx}\csc x &= -\csc x\cot x. \end{aligned} d x d cot x d x d csc x = − csc 2 x , = − csc x cot x .
证明
每个都是正弦和余弦(或 1 和其中之一)的商,因此使用商的法则,然后 sin 2 x + cos 2 x = 1 。 \sin^2 x + \cos^2 x = 1\mathclose{\text{。}} sin 2 x + cos 2 x = 1 。 其中 cos x ≠ 0 , \cos x \ne 0\mathclose{\text{,}} cos x = 0 ,
d d x sin x cos x = cos x cos x − sin x ( − sin x ) cos 2 x = cos 2 x + sin 2 x cos 2 x = 1 cos 2 x = sec 2 x , d d x 1 cos x = 0 ⋅ cos x − 1 ⋅ ( − sin x ) cos 2 x = 1 cos x ⋅ sin x cos x = sec x tan x . \begin{aligned} &\frac{d}{dx}\frac{\sin x}{\cos x} \\ &\quad= \frac{\cos x\cos x - \sin x(-\sin x)}{\cos^2 x} \\ &\quad= \frac{\cos^2 x + \sin^2 x}{\cos^2 x} \\ &\quad= \frac{1}{\cos^2 x} = \sec^2 x, \\[6pt] &\frac{d}{dx}\frac{1}{\cos x} \\ &\quad= \frac{0\cdot\cos x - 1\cdot(-\sin x)}{\cos^2 x} \\ &\quad= \frac{1}{\cos x}\cdot\frac{\sin x}{\cos x} = \sec x\tan x. \end{aligned} d x d cos x sin x = cos 2 x cos x cos x − sin x ( − sin x ) = cos 2 x cos 2 x + sin 2 x = cos 2 x 1 = sec 2 x , d x d cos x 1 = cos 2 x 0 ⋅ cos x − 1 ⋅ ( − sin x ) = cos x 1 ⋅ cos x sin x = sec x tan x .
其中 sin x ≠ 0 , \sin x \ne 0\mathclose{\text{,}} sin x = 0 ,
d d x cos x sin x = ( − sin x ) sin x − cos x cos x sin 2 x = − sin 2 x + cos 2 x sin 2 x = − 1 sin 2 x = − csc 2 x , d d x 1 sin x = 0 ⋅ sin x − 1 ⋅ cos x sin 2 x = − 1 sin x ⋅ cos x sin x = − csc x cot x . \begin{aligned} &\frac{d}{dx}\frac{\cos x}{\sin x} \\ &\quad= \frac{(-\sin x)\sin x - \cos x\cos x}{\sin^2 x} \\ &\quad= -\frac{\sin^2 x + \cos^2 x}{\sin^2 x} \\ &\quad= -\frac{1}{\sin^2 x} = -\csc^2 x, \\[6pt] &\frac{d}{dx}\frac{1}{\sin x} \\ &\quad= \frac{0\cdot\sin x - 1\cdot\cos x}{\sin^2 x} \\ &\quad= -\frac{1}{\sin x}\cdot\frac{\cos x}{\sin x} = -\csc x\cot x. \end{aligned} d x d sin x cos x = sin 2 x ( − sin x ) sin x − cos x cos x = − sin 2 x sin 2 x + cos 2 x = − sin 2 x 1 = − csc 2 x , d x d sin x 1 = sin 2 x 0 ⋅ sin x − 1 ⋅ cos x = − sin x 1 ⋅ sin x cos x = − csc x cot x .
∎
一个记忆模式:三个“余”函数——余弦、余切和余割——带有负号。
例 5.5与正弦和余弦的乘积和商 ✓ 已检验
对 (a) x 2 sin x 、 x^2\sin x\mathclose{\text{、}} x 2 sin x 、 (b) sin x cos x \sin x\cos x sin x cos x 和 (c) sin x x \dfrac{\sin x}{x} x sin x 在 x ≠ 0 x \ne 0 x = 0 下求导。
(a) 乘积法则: d d x ( x 2 sin x ) = 2 x sin x + x 2 cos x 。 \dfrac{d}{dx}\big(x^2\sin x\big) = 2x\sin x + x^2\cos x\mathclose{\text{。}} d x d ( x 2 sin x ) = 2 x sin x + x 2 cos x 。
(b) 乘积法则再次应用:
d d x ( sin x cos x ) = cos x cos x + sin x ( − sin x ) = cos 2 x − sin 2 x . \begin{aligned} &\frac{d}{dx}(\sin x\cos x) \\ &\quad= \cos x\cos x + \sin x(-\sin x) \\ &\quad= \cos^2 x - \sin^2 x. \end{aligned} d x d ( sin x cos x ) = cos x cos x + sin x ( − sin x ) = cos 2 x − sin 2 x .
(c) 商法则: d d x sin x x = cos x ⋅ x − sin x ⋅ 1 x 2 = x cos x − sin x x 2 . \dfrac{d}{dx}\dfrac{\sin x}{x} = \dfrac{\cos x\cdot x - \sin x\cdot 1}{x^2} = \dfrac{x\cos x - \sin x}{x^2}\mathclose{\text{.}} d x d x sin x = x 2 cos x ⋅ x − sin x ⋅ 1 = x 2 x cos x − sin x .
例 5.6一个弹簧上的质量 ✓ 已检验
一个质量在弹簧上上下弹跳。假设它在 t t t 秒后相对于平衡点的高度为 s ( t ) = 4 sin t + 3 cos t s(t) = 4\sin t + 3\cos t s ( t ) = 4 sin t + 3 cos t 厘米。求它的速度 v = s ′ v = s' v = s ′ 和加速度 a = v ′ , a = v'\mathclose{\text{,}} a = v ′ , 并比较 a a a 与 s 。 s\mathclose{\text{。}} s 。
v ( t ) = 4 cos t − 3 sin t cm/s , a ( t ) = − 4 sin t − 3 cos t cm/s 2 . \begin{aligned} v(t) &= 4\cos t - 3\sin t \ \text{cm/s}, \\ a(t) &= -4\sin t - 3\cos t \ \text{cm/s}^2. \end{aligned} v ( t ) a ( t ) = 4 cos t − 3 sin t cm/s , = − 4 sin t − 3 cos t cm/s 2 .
所以 a ( t ) = − s ( t ) a(t) = -s(t) a ( t ) = − s ( t ) 在每一瞬间:加速度始终指向平衡点,并且与距离成正比。这就是弹簧的拉力(胡克定律),并且模块 13 表明,具有这种性质的任何运动都是正弦和余弦的组合。在 t = 0 t = 0 t = 0 时,质量位于 3 厘米上方,并以 4 厘米/秒的速度向上运动。
注意
两个标牌: ( cos x ) ′ = − sin x , (\cos x)' = -\sin x\mathclose{\text{,}} ( cos x ) ′ = − sin x , 不是 sin x ; \sin x\mathclose{\text{;}} sin x ; 以及 cot x \cot x cot x 和 csc x \csc x csc x 的导数也带有负号。所有六个公式都假设使用弧度:用计算器的度数模式验证它们会失败。
合成函数无处不在:sin ( 2 x ) , \sin(2x)\mathclose{\text{,}} sin ( 2 x ) , ( x 2 + 1 ) 10 , (x^2 + 1)^{10}\mathclose{\text{,}} ( x 2 + 1 ) 10 , 1 + x 2 。 \sqrt{1 + x^2}\mathclose{\text{。}} 1 + x 2 。 从数字开始。在 x = 0 x = 0 x = 0 处 y = sin ( 2 x ) y = \sin(2x) y = sin ( 2 x ) 的斜率是多少?那里的差商是 sin ( 2 h ) − sin 0 h = sin ( 2 h ) h : \dfrac{\sin(2h) - \sin 0}{h} = \dfrac{\sin(2h)}{h}\mathclose{\text{:}} h sin ( 2 h ) − sin 0 = h sin ( 2 h ) :
h h h sin ( 2 h ) h \dfrac{\sin(2h)}{h} h sin ( 2 h ) 0.1 0.1 0.1 1.986693 1.986693 1.986693 0.01 0.01 0.01 1.999867 1.999867 1.999867 0.001 0.001 0.001 1.999999 1.999999 1.999999
它们趋近于 2,而不是 cos ( 2 ⋅ 0 ) = 1 。 \cos(2 \cdot 0) = 1\mathclose{\text{。}} cos ( 2 ⋅ 0 ) = 1 。 第 1.5 节解释了原因:函数 sin ( 2 x ) \sin(2x) sin ( 2 x ) 的图像实际上是函数 sin x \sin x sin x 水平方向被压缩了 2 倍,因此它上升得更陡峭,每个斜率都加倍。函数 sin ( 2 x ) \sin(2x) sin ( 2 x ) 的导数是 2 cos ( 2 x ) : 2\cos(2x)\mathclose{\text{:}} 2 cos ( 2 x ) : 外层函数(正弦函数)在内层函数 2 x 2x 2 x 处的导数乘以内层函数变化的速率 2。
速率相乘
在图 5.3 中,齿轮 A 有 36 齿,齿轮 B 有 18 齿,齿轮 C 有 6 齿。当 A 转动一圈时,36 齿经过与 B 相啮合的点,因此 B 转动 36 / 18 = 2 36/18 = 2 36/18 = 2 圈。对于每转一圈 B,18 齿经过 C,因此 C 转动 18 / 6 = 3 18/6 = 3 18/6 = 3 圈。因此,C 比 A 快 3 ⋅ 2 = 6 3 \cdot 2 = 6 3 ⋅ 2 = 6 倍。如果 θ A 、 \theta_A\mathclose{\text{、}} θ A 、 θ B \theta_B θ B 和 θ C \theta_C θ C 分别表示各齿轮转动的角度,每个角度按各自转动方向测量,
d θ C d θ A = d θ C d θ B ⋅ d θ B d θ A = 3 ⋅ 2 = 6. \frac{d\theta_C}{d\theta_A} = \frac{d\theta_C}{d\theta_B}\cdot\frac{d\theta_B}{d\theta_A} = 3 \cdot 2 = 6. d θ A d θ C = d θ B d θ C ⋅ d θ A d θ B = 3 ⋅ 2 = 6.
图 5.3 速率相乘。齿轮 B 每转一圈,齿轮 A 转两圈;齿轮 C 每转一圈,齿轮 B 转三圈,因此 C 每转一圈,A 转 3 ⋅ 2 = 6 3 \cdot 2 = 6 3 ⋅ 2 = 6 圈。相啮合的齿轮转动方向相反(箭头所示)。
单位换算同样适用。假设一辆汽车每公里耗油 0.06 升,以 90 公里/小时速度行驶。则它每小时耗油 0.06 ⋅ 90 = 5.4 0.06 \cdot 90 = 5.4 0.06 ⋅ 90 = 5.4 升,单位相乘如分数相乘:(升/公里)乘以(公里/小时)等于升/小时。
对于齿轮和燃料,速率是恒定的。对于曲线,速率在各点之间变化,但在每个点附近,可导函数接近于其切线,而切线具有恒定的速率,即斜率。因此,逐点地,速率相乘。
定理 5.6链式法则
如果 g g g 在 x x x 处可导,且 f f f 在 g ( x ) g(x) g ( x ) 处可导,则复合函数 F = f ∘ g , F = f \circ g\mathclose{\text{,}} F = f ∘ g , F ( x ) = f ( g ( x ) ) , F(x) = f\big(g(x)\big)\mathclose{\text{,}} F ( x ) = f ( g ( x ) ) , 在 x x x 处可导,并且
F ′ ( x ) = f ′ ( g ( x ) ) g ′ ( x ) . F'(x) = f'\big(g(x)\big)\,g'(x). F ′ ( x ) = f ′ ( g ( x ) ) g ′ ( x ) .
在莱布尼茨记号中,对于 y = f ( u ) y = f(u) y = f ( u ) 和 u = g ( x ) , u = g(x)\mathclose{\text{,}} u = g ( x ) ,
d y d x = d y d u ⋅ d u d x , \frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}, d x d y = d u d y ⋅ d x d u ,
其中 d y / d u dy/du d y / d u 在 u = g ( x ) u = g(x) u = g ( x ) 处求值。
用文字表述:对外层函数求导,保持内层函数不变,再乘以内层函数的导数。符号 f ′ ( g ( x ) ) f'\big(g(x)\big) f ′ ( g ( x ) ) 读作“g of x 的 f 的导数”:即 f f f 在数值 g ( x ) g(x) g ( x ) 处的导数。莱布尼茨形式看起来像是在消去 d u : du\mathclose{\text{:}} d u : 这里 d y / d x dy/dx d y / d x 表现得像分数,这使得该规则易于记忆。但这并非证明,因为 d y / d u dy/du d y / d u 是一个表示极限的单一符号(模块 4),而非分数。
f f f 必须在某点可导:在 g ( x ) g(x) g ( x ) 这个使用该点,而不是在 x 。 x\mathclose{\text{。}} x 。 没有这个假设,规则可能失效:对于 f ( u ) = ∣ u ∣ f(u) = \abs{u} f ( u ) = ∣ u ∣ 和 g ( x ) = x 2 − 1 , g(x) = x^2 - 1\mathclose{\text{,}} g ( x ) = x 2 − 1 , 虽然 f f f 在 1 处可导,但在 g ( 1 ) = 0 g(1) = 0 g ( 1 ) = 0 处不可导,且 f ( g ( x ) ) = ∣ x 2 − 1 ∣ f\big(g(x)\big) = \abs{x^2 - 1} f ( g ( x ) ) = x 2 − 1 在 x = 1 x = 1 x = 1 处有拐点。
证明思想。 设 u = g ( x ) , u = g(x)\mathclose{\text{,}} u = g ( x ) , 当 x x x 改变 h h h 时,设 Δ u = g ( x + h ) − g ( x ) \Delta u = g(x + h) - g(x) Δ u = g ( x + h ) − g ( x ) 和 Δ y = f ( u + Δ u ) − f ( u ) \Delta y = f(u + \Delta u) - f(u) Δ y = f ( u + Δ u ) − f ( u ) 分别为 u u u 和 y y y 的变化量。如果 Δ u ≠ 0 , \Delta u \ne 0\mathclose{\text{,}} Δ u = 0 ,
Δ y h = Δ y Δ u ⋅ Δ u h . \frac{\Delta y}{h} = \frac{\Delta y}{\Delta u}\cdot\frac{\Delta u}{h}. h Δ y = Δ u Δ y ⋅ h Δ u .
与 h → 0 h \to 0 h → 0 类似, Δ u → 0 \Delta u \to 0 Δ u → 0 (因为 g g g 在 x x x 处连续),所以 Δ y / Δ u → f ′ ( u ) , \Delta y/\Delta u \to f'(u)\mathclose{\text{,}} Δ y /Δ u → f ′ ( u ) , 而 Δ u / h → g ′ ( x ) ; \Delta u/h \to g'(x)\mathclose{\text{;}} Δ u / h → g ′ ( x ) ; 乘积趋于 f ′ ( u ) g ′ ( x ) 。 f'(u)\,g'(x)\mathclose{\text{。}} f ′ ( u ) g ′ ( x ) 。 这是极限的齿轮论证,几乎是一个证明。缺口:对于 h ≠ 0 h \ne 0 h = 0 接近 0 的值, Δ u \Delta u Δ u 可以是 0(对于常数 g , g\mathclose{\text{,}} g , 它对所有 h h h 都是 0;练习 5.11 给出一个不太明显的例子),然后 Δ y / Δ u \Delta y/\Delta u Δ y /Δ u 是 0 / 0 。 0/0\mathclose{\text{。}} 0/0 。 下一个框用完整的证明填补了这个缺口;初次阅读可跳过。
深入一步链式法则的证明
关于除以 Δ u \Delta u Δ u 的处理方式是描述 f f f 的可导性而不进行除法。令 u = g ( x ) 。 u = g(x)\mathclose{\text{。}} u = g ( x ) 。 由于 f f f 在 u u u 处可导,它定义在 u u u 附近的一个开区间内;对于 k ≠ 0 k \ne 0 k = 0 使得 u + k u + k u + k 在该区间内,令
E ( k ) = f ( u + k ) − f ( u ) k − f ′ ( u ) , E(k) = \frac{f(u + k) - f(u)}{k} - f'(u), E ( k ) = k f ( u + k ) − f ( u ) − f ′ ( u ) ,
差商超过 f ′ ( u ) f'(u) f ′ ( u ) 的量,令 E ( 0 ) = 0 。 E(0) = 0\mathclose{\text{。}} E ( 0 ) = 0 。 f f f 在 u u u 处可导的条件恰好说明 E ( k ) → 0 E(k) \to 0 E ( k ) → 0 当 k → 0 ; k \to 0\mathclose{\text{;}} k → 0 ; 由于 E ( 0 ) = 0 , E(0) = 0\mathclose{\text{,}} E ( 0 ) = 0 , E E E 在 0 处连续。乘以 k , k\mathclose{\text{,}} k ,
f ( u + k ) − f ( u ) = ( f ′ ( u ) + E ( k ) ) k , f(u + k) - f(u) = \big(f'(u) + E(k)\big)\,k, f ( u + k ) − f ( u ) = ( f ′ ( u ) + E ( k ) ) k ,
对于 k ≠ 0 , k \ne 0\mathclose{\text{,}} k = 0 , 以及对于 k = 0 , k = 0\mathclose{\text{,}} k = 0 , 当两边都为 0 时。
现在令 h ≠ 0 h \ne 0 h = 0 足够小,使得 g ( x + h ) g(x + h) g ( x + h ) 位于区间 (可能因为 g g g 在 x x x 处连续),并令 k = Δ u = g ( x + h ) − g ( x ) , k = \Delta u = g(x + h) - g(x)\mathclose{\text{,}} k = Δ u = g ( x + h ) − g ( x ) , 无论 Δ u \Delta u Δ u 是否为 0 都允许。除以 h , h\mathclose{\text{,}} h ,
f ( g ( x + h ) ) − f ( g ( x ) ) h = ( f ′ ( u ) + E ( Δ u ) ) Δ u h . \begin{aligned} &\frac{f\big(g(x + h)\big) - f\big(g(x)\big)}{h} \\ &\quad= \big(f'(u) + E(\Delta u)\big)\,\frac{\Delta u}{h}. \end{aligned} h f ( g ( x + h ) ) − f ( g ( x ) ) = ( f ′ ( u ) + E ( Δ u ) ) h Δ u .
设 h → 0 . h \to 0\mathclose{\text{.}} h → 0 . 那么 Δ u / h → g ′ ( x ) , \Delta u/h \to g'(x)\mathclose{\text{,}} Δ u / h → g ′ ( x ) , 因为 g g g 在 x x x 处可导。同时 Δ u → 0 , \Delta u \to 0\mathclose{\text{,}} Δ u → 0 , 因为 g g g 在 x x x 处连续,因此 E ( Δ u ) → E ( 0 ) = 0 , E(\Delta u) \to E(0) = 0\mathclose{\text{,}} E ( Δ u ) → E ( 0 ) = 0 , 因为 E E E 在 0 处连续(复合函数的极限,定理 3.4 )。所以右边趋近于 f ′ ( u ) g ′ ( x ) , f'(u)\,g'(x)\mathclose{\text{,}} f ′ ( u ) g ′ ( x ) , 这证明了链式法则。
每个假设都被使用了:g g g 在 x x x 处的可导性,用于 Δ u / h → g ′ ( x ) , \Delta u/h \to g'(x)\mathclose{\text{,}} Δ u / h → g ′ ( x ) , 并通过连续性用于 Δ u → 0 ; \Delta u \to 0\mathclose{\text{;}} Δ u → 0 ; 以及 f f f 在 u = g ( x ) u = g(x) u = g ( x ) 处的可导性,而非在 x x x 处,用于 E ( k ) → 0 。 E(k) \to 0\mathclose{\text{。}} E ( k ) → 0 。
使用链式法则
要使用链式法则,需命名内部函数,对外部函数进行求导并将内部函数保留其中,再乘以内层函数的导数。
例 5.7三个复合函数 ✓ 已检验
求导 (a) ( 2 x + 1 ) 5 , (2x + 1)^5\mathclose{\text{,}} ( 2 x + 1 ) 5 , (b) sin ( x 2 ) \sin(x^2) sin ( x 2 ) 和 (c) sin 2 x 。 \sin^2 x\mathclose{\text{。}} sin 2 x 。
(a) 内函数是 u = 2 x + 1 , u = 2x + 1\mathclose{\text{,}} u = 2 x + 1 , 其中 d u / d x = 2 , du/dx = 2\mathclose{\text{,}} d u / d x = 2 , 外函数是 u 5 : u^5\mathclose{\text{:}} u 5 :
d d x ( 2 x + 1 ) 5 = 5 ( 2 x + 1 ) 4 ⋅ 2 = 10 ( 2 x + 1 ) 4 . \begin{aligned} \frac{d}{dx}(2x + 1)^5 &= 5(2x + 1)^4 \cdot 2 \\ &= 10(2x + 1)^4. \end{aligned} d x d ( 2 x + 1 ) 5 = 5 ( 2 x + 1 ) 4 ⋅ 2 = 10 ( 2 x + 1 ) 4 .
展开 ( 2 x + 1 ) 5 (2x + 1)^5 ( 2 x + 1 ) 5 也可以,但需要更多步骤。
(b) 内 u = x 2 , u = x^2\mathclose{\text{,}} u = x 2 , 外 sin u : \sin u\mathclose{\text{:}} sin u : d d x sin ( x 2 ) = cos ( x 2 ) ⋅ 2 x = 2 x cos ( x 2 ) . \dfrac{d}{dx}\sin(x^2) = \cos(x^2)\cdot 2x = 2x\cos(x^2)\mathclose{\text{.}} d x d sin ( x 2 ) = cos ( x 2 ) ⋅ 2 x = 2 x cos ( x 2 ) .
(c) sin 2 x \sin^2 x sin 2 x 表示 ( sin x ) 2 : (\sin x)^2\mathclose{\text{:}} ( sin x ) 2 : 内 u = sin x , u = \sin x\mathclose{\text{,}} u = sin x , 外 u 2 . u^2\mathclose{\text{.}} u 2 . 所以 d d x sin 2 x = 2 sin x ⋅ cos x . \dfrac{d}{dx}\sin^2 x = 2\sin x\cdot\cos x\mathclose{\text{.}} d x d sin 2 x = 2 sin x ⋅ cos x .
在 (b) 中正弦函数在外层,而在 (c) 中在内层:这两个函数以不同的顺序复合,其导数不同。
例 5.8正弦函数以度数为单位 ✓ 已检验
在度数模式下,计算器的正弦键计算 S ( x ) = sin ( x ∘ ) = sin ( π x 180 ) 。 S(x) = \sin(x^\circ) = \sin\Big(\dfrac{\pi x}{180}\Big)\mathclose{\text{。}} S ( x ) = sin ( x ∘ ) = sin ( 180 π x ) 。 找出 S ′ ( x ) 。 S'(x)\mathclose{\text{。}} S ′ ( x ) 。
内层函数是 u = π x 180 , u = \dfrac{\pi x}{180}\mathclose{\text{,}} u = 180 π x , 其导数为 d u / d x = π 180 , du/dx = \dfrac{\pi}{180}\mathclose{\text{,}} d u / d x = 180 π , 外层函数是 sin u : \sin u\mathclose{\text{:}} sin u :
S ′ ( x ) = cos ( π x 180 ) ⋅ π 180 = π 180 cos ( x ∘ ) . \begin{aligned} S'(x) &= \cos\Big(\frac{\pi x}{180}\Big)\cdot\frac{\pi}{180} \\ &= \frac{\pi}{180}\cos(x^\circ). \end{aligned} S ′ ( x ) = cos ( 180 π x ) ⋅ 180 π = 180 π cos ( x ∘ ) .
在 x = 0 x = 0 x = 0 处,斜率是每度 π / 180 ≈ 0.017453 。 \pi/180 \approx 0.017453\mathclose{\text{。}} π /180 ≈ 0.017453 。 如果角度以度数为单位,所有三角函数的导数都会带有这个因子。
链式法则适用于更长的链式复合:从外层开始,逐个对每个部分应用链式法则。
例 5.9三节链条 ✓ 已检验
对 y = sin 3 ( 4 x ) y = \sin^3(4x) y = sin 3 ( 4 x ) 求导,意味着 ( sin ( 4 x ) ) 3 。 \big(\sin(4x)\big)^3\mathclose{\text{。}} ( sin ( 4 x ) ) 3 。
三个函数依次作用:v = 4 x , v = 4x\mathclose{\text{,}} v = 4 x , 然后 u = sin v , u = \sin v\mathclose{\text{,}} u = sin v , 然后 y = u 3 。 y = u^3\mathclose{\text{。}} y = u 3 。 链式法则使用两次,将三个变化率相乘:
d y d x = d y d u ⋅ d u d v ⋅ d v d x = 3 u 2 ⋅ cos v ⋅ 4 = 12 sin 2 ( 4 x ) cos ( 4 x ) . \begin{aligned} \frac{dy}{dx} &= \frac{dy}{du}\cdot\frac{du}{dv}\cdot\frac{dv}{dx} = 3u^2\cdot\cos v\cdot 4 \\ &= 12\sin^2(4x)\cos(4x). \end{aligned} d x d y = d u d y ⋅ d v d u ⋅ d x d v = 3 u 2 ⋅ cos v ⋅ 4 = 12 sin 2 ( 4 x ) cos ( 4 x ) .
一行说明:先立方,将 3 带下来,留下 sin ( 4 x ) \sin(4x) sin ( 4 x ) 在内;然后是正弦函数,留下 4 x 4x 4 x 在内;最后是 4 x 4x 4 x 本身。
函数的幂与根
以整数幂法则(定理 5.3)作为外层导数,链式法则给出,只要 g g g 可导,对于每个整数 n n n (若 n ≤ 0 n \le 0 n ≤ 0 则为 g ( x ) ≠ 0 ), g(x) \ne 0\mathclose{\text{),}} g ( x ) = 0 ),
d d x ( g ( x ) ) n = n ( g ( x ) ) n − 1 g ′ ( x ) . \frac{d}{dx}\big(g(x)\big)^n = n\big(g(x)\big)^{n-1}g'(x). d x d ( g ( x ) ) n = n ( g ( x ) ) n − 1 g ′ ( x ) .
例 5.10函数的负幂 ✓ 已检验
对 y = 1 ( x 2 + 1 ) 3 y = \dfrac{1}{(x^2 + 1)^3} y = ( x 2 + 1 ) 3 1 求导。
写出 y = ( x 2 + 1 ) − 3 。 y = (x^2 + 1)^{-3}\mathclose{\text{。}} y = ( x 2 + 1 ) − 3 。 对于 n = − 3 n = -3 n = − 3 和 g ( x ) = x 2 + 1 , g(x) = x^2 + 1\mathclose{\text{,}} g ( x ) = x 2 + 1 ,
y ′ = − 3 ( x 2 + 1 ) − 4 ⋅ 2 x = − 6 x ( x 2 + 1 ) 4 . y' = -3(x^2 + 1)^{-4}\cdot 2x = -\frac{6x}{(x^2 + 1)^4}. y ′ = − 3 ( x 2 + 1 ) − 4 ⋅ 2 x = − ( x 2 + 1 ) 4 6 x .
商法则在约去一个因子 ( x 2 + 1 ) 2 (x^2 + 1)^2 ( x 2 + 1 ) 2 后给出相同结果,但需要更多步骤。
分数指数的幂法则在模块 6 中被证明,适用于每个实数指数。已知的一个分数幂是:例 4.5 由定义得出]
d d x x = 1 2 x ( x > 0 ) , \frac{d}{dx}\sqrt x = \frac{1}{2\sqrt x} \qquad (x > 0), d x d x = 2 x 1 ( x > 0 ) ,
哪个是 1 2 x − 1 / 2 , \tfrac12 x^{-1/2}\mathclose{\text{,}} 2 1 x − 1/2 , 幂法则与 n = 1 2 。 n = \tfrac12\mathclose{\text{。}} n = 2 1 。 (将差商的分子和分母同时乘以 x + h + x , \sqrt{x + h} + \sqrt x\mathclose{\text{,}} x + h + x , 将其转化为 1 x + h + x , \dfrac{1}{\sqrt{x + h} + \sqrt x}\mathclose{\text{,}} x + h + x 1 , 它趋近于 1 2 x 。) \dfrac{1}{2\sqrt x}\mathclose{\text{。)}} 2 x 1 。) 在 x = 0 x = 0 x = 0 处没有导数: x \sqrt x x 在 0 的左侧未定义,从右侧的差商 h − 0 h = 1 h \dfrac{\sqrt h - 0}{h} = \dfrac{1}{\sqrt h} h h − 0 = h 1 随着 h → 0 + h \to 0^+ h → 0 + 趋向于无穷大,因此图像在原点处垂直离开。
使用链式法则,只要 g ( x ) > 0 g(x) > 0 g ( x ) > 0 和 g g g 可导,
d d x g ( x ) = g ′ ( x ) 2 g ( x ) . \frac{d}{dx}\sqrt{g(x)} = \frac{g'(x)}{2\sqrt{g(x)}}. d x d g ( x ) = 2 g ( x ) g ′ ( x ) .
例 5.11多项式的平方根 ✓ 已检验
对 (a) 1 + x 2 \sqrt{1 + x^2} 1 + x 2 和 (b) ( x 2 + 1 ) 3 / 2 (x^2 + 1)^{3/2} ( x 2 + 1 ) 3/2 求导。
(a) 1 + x 2 > 0 1 + x^2 > 0 1 + x 2 > 0 对于每一个 x , x\mathclose{\text{,}} x , 因此对于每一个 x x x
d d x 1 + x 2 = 2 x 2 1 + x 2 = x 1 + x 2 . \frac{d}{dx}\sqrt{1 + x^2} = \frac{2x}{2\sqrt{1 + x^2}} = \frac{x}{\sqrt{1 + x^2}}. d x d 1 + x 2 = 2 1 + x 2 2 x = 1 + x 2 x .
(b) 幂 3 2 \tfrac32 2 3 尚未覆盖,但 ( x 2 + 1 ) 3 / 2 = ( x 2 + 1 ) x 2 + 1 (x^2 + 1)^{3/2} = (x^2 + 1)\sqrt{x^2 + 1} ( x 2 + 1 ) 3/2 = ( x 2 + 1 ) x 2 + 1 是一个乘积。 通过乘积法则和 (a),
d d x ( x 2 + 1 ) 3 / 2 = 2 x x 2 + 1 + ( x 2 + 1 ) x x 2 + 1 = 2 x x 2 + 1 + x x 2 + 1 = 3 x x 2 + 1 . \begin{aligned} &\frac{d}{dx}(x^2 + 1)^{3/2} \\ &\quad= 2x\sqrt{x^2 + 1} + (x^2 + 1)\frac{x}{\sqrt{x^2 + 1}} \\ &\quad= 2x\sqrt{x^2 + 1} + x\sqrt{x^2 + 1} \\ &\quad= 3x\sqrt{x^2 + 1}. \end{aligned} d x d ( x 2 + 1 ) 3/2 = 2 x x 2 + 1 + ( x 2 + 1 ) x 2 + 1 x = 2 x x 2 + 1 + x x 2 + 1 = 3 x x 2 + 1 .
与 n = 3 2 n = \tfrac32 n = 2 3 相关的幂法则,由模块 6 证明,结果一致: 3 2 ( x 2 + 1 ) 1 / 2 ⋅ 2 x = 3 x x 2 + 1 。 \tfrac32(x^2 + 1)^{1/2}\cdot 2x = 3x\sqrt{x^2 + 1}\mathclose{\text{。}} 2 3 ( x 2 + 1 ) 1/2 ⋅ 2 x = 3 x x 2 + 1 。
注意
三个链式法则错误。忘记内层导数:d d x sin ( 2 x ) \dfrac{d}{dx}\sin(2x) d x d sin ( 2 x ) 是 2 cos ( 2 x ) , 2\cos(2x)\mathclose{\text{,}} 2 cos ( 2 x ) , 而不是 cos ( 2 x ) 。 \cos(2x)\mathclose{\text{。}} cos ( 2 x ) 。 改变内部函数:外层导数是在内部函数不变的情况下计算的,因此 d d x sin ( x 2 ) = cos ( x 2 ) ⋅ 2 x , \dfrac{d}{dx}\sin(x^2) = \cos(x^2)\cdot 2x\mathclose{\text{,}} d x d sin ( x 2 ) = cos ( x 2 ) ⋅ 2 x , 而不是 cos x ⋅ 2 x \cos x\cdot 2x cos x ⋅ 2 x 和 cos ( 2 x ) 。 \cos(2x)\mathclose{\text{。}} cos ( 2 x ) 。 混淆复合函数与乘积:sin ( x 2 ) \sin(x^2) sin ( x 2 ) 需要链式法则,x sin x x\sin x x sin x 需要乘积法则。
真实的公式结合了多个规则。系统化的顺序有助于控制计算过程。
要点
对一个公式求导:
如果有助于理解,可以重写它。 使用负幂表示倒数(3 x 4 = 3 x − 4 ); \dfrac{3}{x^4} = 3x^{-4}\mathclose{\text{);}} x 4 3 = 3 x − 4 ); 约去公共因子,注意省略的点;展开一个简短的多项式乘积。
找出最后的操作 :当你计算公式在某个数的值时,最后进行的操作。它决定了规则:加法,使用加法法则;乘法,使用乘积法则;除法,使用商法则;对某个非 x x x 自身的函数应用,使用链式法则。
应用该规则 ,并将它留下的每个部分以相同方式求导,直到只剩下基本导数。
简化 : 提取公因式,合并分数,使用诸如 sin 2 x + cos 2 x = 1 \sin^2 x + \cos^2 x = 1 sin 2 x + cos 2 x = 1 等恒等式,并说明结果成立的条件。
检查 : 在有差商的点上,图上(下方图示),或用 SymPy(第 5.7 节)。
公式
最后一步
第一条规则
x 2 sin x x^2\sin x x 2 sin x
将 x 2 x^2 x 2 乘以 sin x \sin x sin x
积
sin ( x 2 ) \sin(x^2) sin ( x 2 )
对 x 2 x^2 x 2 取正弦
链式法则
sin 2 x \sin^2 x sin 2 x
将 sin x \sin x sin x 平方
链式法则
x sin x \dfrac{x}{\sin x} sin x x
将 x x x 除以 sin x \sin x sin x
商
sin x cos ( 3 x ) \sin x\cos(3x) sin x cos ( 3 x )
相乘
先相乘,再对 cos ( 3 x ) \cos(3x) cos ( 3 x ) 使用链式法则
例 5.12幂的乘积 ✓ 已检验
对 y = x 3 ( 2 x − 1 ) 4 y = x^3(2x - 1)^4 y = x 3 ( 2 x − 1 ) 4 求导,化简,并找出切线水平的点。
最后一步是 x 3 x^3 x 3 和 ( 2 x − 1 ) 4 (2x - 1)^4 ( 2 x − 1 ) 4 的乘积。第二个因子需要使用链式法则:其导数是 4 ( 2 x − 1 ) 3 ⋅ 2 = 8 ( 2 x − 1 ) 3 。 4(2x - 1)^3 \cdot 2 = 8(2x - 1)^3\mathclose{\text{。}} 4 ( 2 x − 1 ) 3 ⋅ 2 = 8 ( 2 x − 1 ) 3 。 因此
y ′ = 3 x 2 ( 2 x − 1 ) 4 + x 3 ⋅ 8 ( 2 x − 1 ) 3 . y' = 3x^2(2x - 1)^4 + x^3 \cdot 8(2x - 1)^3. y ′ = 3 x 2 ( 2 x − 1 ) 4 + x 3 ⋅ 8 ( 2 x − 1 ) 3 .
两个项都包含 x 2 ( 2 x − 1 ) 3 , x^2(2x - 1)^3\mathclose{\text{,}} x 2 ( 2 x − 1 ) 3 , 将其提出:
y ′ = x 2 ( 2 x − 1 ) 3 [ 3 ( 2 x − 1 ) + 8 x ] = x 2 ( 2 x − 1 ) 3 ( 14 x − 3 ) . \begin{aligned} y' &= x^2(2x - 1)^3\big[3(2x - 1) + 8x\big] \\ &= x^2(2x - 1)^3(14x - 3). \end{aligned} y ′ = x 2 ( 2 x − 1 ) 3 [ 3 ( 2 x − 1 ) + 8 x ] = x 2 ( 2 x − 1 ) 3 ( 14 x − 3 ) .
因式分解的形式立刻显示出 y ′ = 0 y' = 0 y ′ = 0 的位置:在 x = 0 、 x = 0\mathclose{\text{、}} x = 0 、 x = 1 2 x = \tfrac12 x = 2 1 和 x = 3 14 x = \tfrac{3}{14} x = 14 3 处。这三个点的切线是水平的。展开形式 112 x 6 − 192 x 5 + 120 x 4 − 32 x 3 + 3 x 2 112x^6 - 192x^5 + 120x^4 - 32x^3 + 3x^2 112 x 6 − 192 x 5 + 120 x 4 − 32 x 3 + 3 x 2 则隐藏了这一点。
例 5.13可以化简的分数 ✓ 已检验
对 y = sin x 1 + cos x y = \dfrac{\sin x}{1 + \cos x} y = 1 + cos x sin x 求导,其中 cos x ≠ − 1 。 \cos x \ne -1\mathclose{\text{。}} cos x = − 1 。
使用商数法则,然后在分子中使用毕达哥拉斯恒等式:
y ′ = cos x ( 1 + cos x ) − sin x ( − sin x ) ( 1 + cos x ) 2 = cos x + cos 2 x + sin 2 x ( 1 + cos x ) 2 = 1 + cos x ( 1 + cos x ) 2 = 1 1 + cos x . \begin{aligned} y' &= \frac{\cos x\,(1 + \cos x) - \sin x\,(-\sin x)}{(1 + \cos x)^2} \\ &= \frac{\cos x + \cos^2 x + \sin^2 x}{(1 + \cos x)^2} \\ &= \frac{1 + \cos x}{(1 + \cos x)^2} = \frac{1}{1 + \cos x}. \end{aligned} y ′ = ( 1 + cos x ) 2 cos x ( 1 + cos x ) − sin x ( − sin x ) = ( 1 + cos x ) 2 cos x + cos 2 x + sin 2 x = ( 1 + cos x ) 2 1 + cos x = 1 + cos x 1 .
例 5.14一个链式结构围绕一个商数 ✓ 已检验
对 y = ( x − 1 x + 1 ) 4 y = \Big(\dfrac{x - 1}{x + 1}\Big)^4 y = ( x + 1 x − 1 ) 4 求导,其中 x ≠ − 1 。 x \ne -1\mathclose{\text{。}} x = − 1 。
最后一步是四次方,因此首先使用链式法则,商数作为内函数。其导数,通过商数法则,是
d d x x − 1 x + 1 = 1 ⋅ ( x + 1 ) − ( x − 1 ) ⋅ 1 ( x + 1 ) 2 = 2 ( x + 1 ) 2 , \begin{aligned} \frac{d}{dx}\frac{x - 1}{x + 1} &= \frac{1\cdot(x + 1) - (x - 1)\cdot 1}{(x + 1)^2} \\ &= \frac{2}{(x + 1)^2}, \end{aligned} d x d x + 1 x − 1 = ( x + 1 ) 2 1 ⋅ ( x + 1 ) − ( x − 1 ) ⋅ 1 = ( x + 1 ) 2 2 ,
因此
y ′ = 4 ( x − 1 x + 1 ) 3 ⋅ 2 ( x + 1 ) 2 = 8 ( x − 1 ) 3 ( x + 1 ) 5 . \begin{aligned} y' &= 4\Big(\frac{x - 1}{x + 1}\Big)^3\cdot\frac{2}{(x + 1)^2} \\ &= \frac{8(x - 1)^3}{(x + 1)^5}. \end{aligned} y ′ = 4 ( x + 1 x − 1 ) 3 ⋅ ( x + 1 ) 2 2 = ( x + 1 ) 5 8 ( x − 1 ) 3 .
图形计算器同时绘制函数及其导数。它使用中心差分法(模块 4)计算 f ′ f' f ′ 的数值,因此可以验证你手动推导的公式。
注意
在求导前简化函数,当这样做成本较低时,但要注意简化所依赖的假设。对于 x ≠ 1 , x \ne 1\mathclose{\text{,}} x = 1 , x 2 − 1 x − 1 = x + 1 , \dfrac{x^2 - 1}{x - 1} = x + 1\mathclose{\text{,}} x − 1 x 2 − 1 = x + 1 , 因此其导数在每个 x ≠ 1 x \ne 1 x = 1 处为 1;在 x = 1 x = 1 x = 1 处函数未定义,因此那里没有导数。未简化的答案并不错误,只是更难使用:例 5.12 需要因式分解形式来找出切线水平的位置。
SymPy 的 diff (模块 4) 知道本模块中的所有规则。sp.diff(expr, x) 对 expr 关于 x 求导;sp.factor 和 sp.simplify (模块 1) 整理结果。
动手计算用 SymPy 求导
Python 复制
import sympy as sp
x = sp.symbols ('x' )
y = x**3 *(2 *x - 1 )**4 # Example 5.12
dy = sp.diff (y, x)
print (dy)
print (sp.factor (dy))
print (sp.expand (dy))
输出
8*x**3*(2*x - 1)**3 + 3*x**2*(2*x - 1)**4
x**2*(2*x - 1)**3*(14*x - 3)
112*x**6 - 192*x**5 + 120*x**4 - 32*x**3 + 3*x**2
第一行是乘积法则应用后的结果,尚未进行任何化简,各项按照 SymPy 的顺序排列;factor 给出例 5.12 的形式,expand 是展开形式,虽然正确但无助于找出 y ′ = 0 。 y' = 0\mathclose{\text{。}} y ′ = 0 。 SymPy 也会对它不认识的函数应用求导法则:
Python 复制
f, g = sp.Function ('f' ), sp.Function ('g' )
print (sp.diff (f (x)*g (x), x))
print (sp.diff (f (g (x)), x))
print (sp.diff (sp.tan (x), x))
输出
f(x)*Derivative(g(x), x) + g(x)*Derivative(f(x), x)
Derivative(f(g(x)), g(x))*Derivative(g(x), x)
tan(x)**2 + 1
第一行是乘积法则,第二行是链式法则:Derivative(f(g(x)), g(x)) 表示 f ′ f' f ′ 在 g ( x ) g(x) g ( x ) 处的值。第三行是 sec 2 x \sec^2 x sec 2 x 的变形:将 sin 2 x + cos 2 x = 1 \sin^2 x + \cos^2 x = 1 sin 2 x + cos 2 x = 1 除以 cos 2 x \cos^2 x cos 2 x 得到 tan 2 x + 1 = sec 2 x 。 \tan^2 x + 1 = \sec^2 x\mathclose{\text{。}} tan 2 x + 1 = sec 2 x 。
SymPy 只能对 SymPy 表达式求导。Python 的 math.sin 接受数值,所以传入符号时会报错:
Python 故意出错的例子
import math
print (sp.diff (math.sin (x), x))
错误
TypeError: Cannot convert expression to float
在你希望求导的公式中使用 sp.sin、sp.cos、sp.sqrt 和其他 SymPy 函数。
为什么答案看起来不同
SymPy 机械地应用规则,仅进行少量整理。其答案与你的答案可能在项的顺序、分组方式、所用恒等式(tan 2 x + 1 \tan^2 x + 1 tan 2 x + 1 对应 sec 2 x , \sec^2 x\mathclose{\text{,}} sec 2 x , 或 cos 2 x − sin 2 x \cos^2 x - \sin^2 x cos 2 x − sin 2 x 对应 cos 2 x , \cos 2x\mathclose{\text{,}} cos 2 x , 即带有 y = x y = x y = x 的加法公式)上存在差异,也可能源于一方进行了简化而另一方未进行。两个表达式 A A A 和 B B B 相等当且仅当 A − B = 0 , A - B = 0\mathclose{\text{,}} A − B = 0 , 因此要比较两个答案,需简化它们的差。
动手计算我的答案对吗?
Python 复制
import sympy as sp
x = sp.symbols ('x' )
theirs = sp.diff (sp.sin (x)/(1 + sp.cos (x)), x) # Example 5.13
mine = 1 /(1 + sp.cos (x))
print (theirs)
print (sp.simplify (theirs - mine))
输出
cos(x)/(cos(x) + 1) + sin(x)**2/(cos(x) + 1)**2
0
两式之差化简为 0,所以答案一致。如果写错了,差就可能非零。假设求 sin ( x 2 ) \sin(x^2) sin ( x 2 ) 的导数时忘了乘内层导数,写成 cos ( x 2 ) : \cos(x^2)\mathclose{\text{:}} cos ( x 2 ) :
Python 复制
wrong = sp.cos (x**2 )
gap = sp.simplify (sp.diff (sp.sin (x**2 ), x) - wrong)
print (gap)
print ([round (float (gap.subs (x, v)), 4 ) for v in (0.5 , 1 , 2 )])
输出
(2*x - 1)*cos(x**2)
[0.0, 0.5403, -1.9609]
最后一行在三个数处计算差值。在 x = 0.5 x = 0.5 x = 0.5 处,错误的答案恰好正确,因为在 2 x − 1 = 0 2x - 1 = 0 2 x − 1 = 0 处;在 1 和 2 处则不正确,只要有一个非零值就足以证明两个表达式不同。
要点
为检查两个答案 A A A 和 B B B 是否相等,化简 A − B 。 A - B\mathclose{\text{。}} A − B 。 如果得到 0,则它们在定义域内处处相等。如果不为 0,则在几个数值上评估 A − B : A - B\mathclose{\text{:}} A − B : 一个非零值可证明它们不同。 simplify 并不找到所有化简方式,因此一个不化简为 0 的差异本身并不能证明答案不同;一个非零值则可以证明。
注意
一个差值在一点或两点为 0 并不能证明什么: ( 2 x − 1 ) cos ( x 2 ) (2x - 1)\cos(x^2) ( 2 x − 1 ) cos ( x 2 ) 在 x = 0.5 x = 0.5 x = 0.5 处为 0。应测试多个点,而不仅仅是整数,或进行化简。
训练神经网络、将模型拟合到数据、控制机械臂:每种情况都需要函数的导数,而这些函数往往只以程序形式存在,通常包含循环和分支的较长程序。如何让一个程序对另一个程序求导?有三种方法。
有限差分 (模块 4): 在 a a a 和 a + h a + h a + h 处运行程序,并计算 f ( a + h ) − f ( a ) h 。 \dfrac{f(a + h) - f(a)}{h}\mathclose{\text{。}} h f ( a + h ) − f ( a ) 。 这只需要程序本身,但这是一个近似:一个较大的 h h h 会产生截断误差,一个较小的则会产生舍入误差,最佳折中方案只保留浮点数大约一半的有效数字,即 16 位中的约 8 位。
符号微分 ,如在 SymPy 中:将程序转换为公式,并应用本模块的规则。结果是精确的,但公式可能会变得非常庞大,且循环和分支必须首先转换为公式。
自动微分 :在携带导数值的数值上运行程序,每一步都根据本模块的规则更新导数。不存在步 h , h\mathclose{\text{,}} h , 因此没有截断误差:结果仅受浮点数舍入误差影响,这种误差也会影响 f f f 本身的值,且每一步需要额外几次运算。
最简单的方式是使用双数来携带导数。
定义 5.1双数
双数 是一个表达式 a + b ε , a + b\varepsilon\mathclose{\text{,}} a + b ε , 其中 a a a 和 b b b 是实数,而 ε \varepsilon ε (希腊字母 epsilon)是一个新符号,具有 ε 2 = 0 。 \varepsilon^2 = 0\mathclose{\text{。}} ε 2 = 0 。 双数像 ε \varepsilon ε 的多项式一样进行加法和乘法运算,其中 ε 2 \varepsilon^2 ε 2 被替换为 0:
( a + b ε ) + ( c + d ε ) = ( a + c ) + ( b + d ) ε , ( a + b ε ) ( c + d ε ) = a c + ( a d + b c ) ε . \begin{aligned} &(a + b\varepsilon) + (c + d\varepsilon) \\ &\quad= (a + c) + (b + d)\varepsilon, \\ &(a + b\varepsilon)(c + d\varepsilon) \\ &\quad= ac + (ad + bc)\varepsilon. \end{aligned} ( a + b ε ) + ( c + d ε ) = ( a + c ) + ( b + d ) ε , ( a + b ε ) ( c + d ε ) = a c + ( a d + b c ) ε .
一个实数 c c c 是双数 c + 0 ε ; c + 0\varepsilon\mathclose{\text{;}} c + 0 ε ; b b b 是 **ε \varepsilon ε -部分 ** 的 a + b ε 。 a + b\varepsilon\mathclose{\text{。}} a + b ε 。
除了 0 以外,没有实数的平方为 0,因此 ε \varepsilon ε 不是一个实数:它是一个具有一个规则的符号。(关于自动微分的书籍使用字母 ε \varepsilon ε 表示它;它与 模块 2 的极限中的 ε \varepsilon ε 或 模块 4 的机器 epsilon 无关。)看一下乘积。它的 ε \varepsilon ε 部分 a d + b c ad + bc a d + b c 是乘积法则:如果 a a a 和 c c c 是两个函数的值,而 b b b 和 d d d 是它们的导数,则乘积的值为 a c , ac\mathclose{\text{,}} a c , 导数为 a d + b c 。 ad + bc\mathclose{\text{。}} a d + b c 。 这就是整个技巧。
定理 5.7双数携带导数
若 p p p 是一个多项式,则对于所有实数 a a a 和 b , b\mathclose{\text{,}} b ,
p ( a + b ε ) = p ( a ) + p ′ ( a ) b ε . p(a + b\varepsilon) = p(a) + p'(a)\,b\,\varepsilon. p ( a + b ε ) = p ( a ) + p ′ ( a ) b ε .
特别地,函数 p ( a + ε ) p(a + \varepsilon) p ( a + ε ) 的 ε \varepsilon ε 部分是导数 p ′ ( a ) 。 p'(a)\mathclose{\text{。}} p ′ ( a ) 。
证明
多项式是由常数和 x x x 通过加法和乘法构造而成的。称一个函数 q q q 为“好函数”,如果 q ( a + b ε ) = q ( a ) + q ′ ( a ) b ε q(a + b\varepsilon) = q(a) + q'(a)\,b\,\varepsilon q ( a + b ε ) = q ( a ) + q ′ ( a ) b ε 对所有 a a a 和 b b b 成立。一个常数 c c c 是好函数,因为 c = c + 0 ε c = c + 0\varepsilon c = c + 0 ε 和 c ′ = 0 ; c' = 0\mathclose{\text{;}} c ′ = 0 ; 所以 x x x 也是好函数,因为 x ′ = 1 。 x' = 1\mathclose{\text{。}} x ′ = 1 。 若 q q q 和 r r r 是好函数,则 q + r q + r q + r 也是好函数,根据和法则;同样, q r qr q r 也是好函数:
q ( a + b ε ) r ( a + b ε ) = ( q ( a ) + q ′ ( a ) b ε ) ⋅ ( r ( a ) + r ′ ( a ) b ε ) = q ( a ) r ( a ) + ( q ′ ( a ) r ( a ) + q ( a ) r ′ ( a ) ) b ε , \begin{aligned} &q(a + b\varepsilon)\,r(a + b\varepsilon) \\ &\quad= \big(q(a) + q'(a)b\varepsilon\big) \\ &\qquad \cdot \big(r(a) + r'(a)b\varepsilon\big) \\ &\quad= q(a)r(a) \\ &\qquad + \big(q'(a)r(a) + q(a)r'(a)\big)b\varepsilon, \end{aligned} q ( a + b ε ) r ( a + b ε ) = ( q ( a ) + q ′ ( a ) b ε ) ⋅ ( r ( a ) + r ′ ( a ) b ε ) = q ( a ) r ( a ) + ( q ′ ( a ) r ( a ) + q ( a ) r ′ ( a ) ) b ε ,
由乘积法则,这正好是 ( q r ) ( a ) + ( q r ) ′ ( a ) b ε 。 (qr)(a) + (qr)'(a)\,b\,\varepsilon\mathclose{\text{。}} ( q r ) ( a ) + ( q r ) ′ ( a ) b ε 。 构造 p p p 的每一步都保持这个性质,所以 p p p 也具有这个性质。
∎
例如, ( 3 + ε ) 2 = 9 + 6 ε + ε 2 = 9 + 6 ε , (3 + \varepsilon)^2 = 9 + 6\varepsilon + \varepsilon^2 = 9 + 6\varepsilon\mathclose{\text{,}} ( 3 + ε ) 2 = 9 + 6 ε + ε 2 = 9 + 6 ε , 且 x 2 x^2 x 2 在 x = 3 x = 3 x = 3 处的值为 9,导数为 6。
其他函数通过声明自己的导数来参与。对于正弦函数,定义 sin ( a + b ε ) = sin a + ( cos a ) b ε 。 \sin(a + b\varepsilon) = \sin a + (\cos a)\,b\,\varepsilon\mathclose{\text{。}} sin ( a + b ε ) = sin a + ( cos a ) b ε 。 然后对于一个好函数 g , g\mathclose{\text{,}} g ,
sin ( g ( a + b ε ) ) = sin ( g ( a ) + g ′ ( a ) b ε ) = sin g ( a ) + cos g ( a ) g ′ ( a ) b ε , \begin{aligned} &\sin\big(g(a + b\varepsilon)\big) \\ &\quad= \sin\big(g(a) + g'(a)\,b\,\varepsilon\big) \\ &\quad= \sin g(a) + \cos g(a)\,g'(a)\,b\,\varepsilon, \end{aligned} sin ( g ( a + b ε ) ) = sin ( g ( a ) + g ′ ( a ) b ε ) = sin g ( a ) + cos g ( a ) g ′ ( a ) b ε ,
其 ε \varepsilon ε 部分是链式法则的 ( sin g ) ′ ( a ) (\sin g)'(a) ( sin g ) ′ ( a ) 乘以 b 。 b\mathclose{\text{。}} b 。 程序中的每个操作只知道自己的导数;链式法则在程序运行过程中逐步应用,其余工作由其完成。
动手计算Python 中的双数
一个包含两个数的类,分别是值 a 和 ε \varepsilon ε -部分 b,并遵循定义 5.1 中的 + 和 * 的规则:
Python 复制
class Dual :
"""A dual number a + b·ε, where ε² = 0."""
def __init__ (self, a, b=0.0 ):
self.a, self.b = a, b # the value and the ε-part
def __add__ (self, other):
other = other if isinstance (other, Dual) else Dual (other)
return Dual (self.a + other.a, self.b + other.b)
def __mul__ (self, other):
other = other if isinstance (other, Dual) else Dual (other)
return Dual (self.a*other.a, self.a*other.b + self.b*other.a)
__radd__ = __add__ # 1 + d and 3*d: number first
__rmul__ = __mul__
Python 将 __add__ 称为 +,将 __mul__ 称为 *,因此任何使用 + 和 * 编写的函数现在都可以在双数上运行。取 f ( x ) = x 3 − 2 x + 1 f(x) = x^3 - 2x + 1 f ( x ) = x 3 − 2 x + 1 在 x = 1.5 x = 1.5 x = 1.5 处,并在 1.5 + 1 ε 1.5 + 1\varepsilon 1.5 + 1 ε 上运行:
Python 复制
def f (x):
return x*x*x + (-2 )*x + 1 # x³ − 2x + 1, with + and * only
y = f (Dual (1.5 , 1.0 ))
print (y.a, y.b) # f(1.5) and f'(1.5)
这些就是 f ( 1.5 ) = 1.375 f(1.5) = 1.375 f ( 1.5 ) = 1.375 和 f ′ ( 1.5 ) = 3 ( 1.5 ) 2 − 2 = 4.75 , f'(1.5) = 3(1.5)^2 - 2 = 4.75\mathclose{\text{,}} f ′ ( 1.5 ) = 3 ( 1.5 ) 2 − 2 = 4.75 , 完全相同。同样的函数在普通数上运行时给出前向差分:
Python 复制
for h in [1e-1 , 1e-4 , 1e-8 , 1e-12 ]:
print (f"h = {h:g}: {(f(1.5 + h) - f(1.5))/h}" )
输出
h = 0.1: 5.210000000000008
h = 0.0001: 4.750450010000407
h = 1e-08: 4.749999993336473
h = 1e-12: 4.75042227776612
使用 h = 0.1 h = 0.1 h = 0.1 时,截断误差约为 0.46。使用 h = 10 − 8 , h = 10^{-8}\mathclose{\text{,}} h = 1 0 − 8 , 即最佳步长时,误差约为 7 × 10 − 9 ; 7 \times 10^{-9}\mathclose{\text{;}} 7 × 1 0 − 9 ; 在 h = 10 − 12 h = 10^{-12} h = 1 0 − 12 处舍入误差占据主导,误差再次增长,约为 4 × 10 − 4 。 4 \times 10^{-4}\mathclose{\text{。}} 4 × 1 0 − 4 。 SymPy,给定公式,可以精确求导:
Python 复制
import sympy as sp
x = sp.symbols ('x' )
fp = sp.diff (x**3 - 2 *x + 1 , x)
print (fp, '|' , fp.subs (x, 1.5 ))
输出
3*x**2 - 2 | 4.75000000000000
给正弦函数加上它的导数规则;然后链式法则就自动适用。这是 sin ( x 2 ) \sin(x^2) sin ( x 2 ) 在 1 处的导数,即 2 cos 1 : 2\cos 1\mathclose{\text{:}} 2 cos 1 :
Python 复制
import math
def sin (d): # sin(a + bε) = sin a + (cos a)·b ε
return Dual (math.sin (d.a), math.cos (d.a)*d.b)
t = Dual (1.0 , 1.0 )
print (sin (t*t).b, 2 *math.cos (1.0 ))
输出
1.0806046117362795 1.0806046117362795
自动微分同样适用于循环结构,而公式本身并不包含循环。这个函数三次平方并相加:
Python 复制
def g (x):
y = x
for _ in range (3 ): # three times: y becomes y² + x
y = y*y + x
return y
print (g (Dual (0.5 , 1.0 )).b)
print (sp.diff (g (x), x).subs (x, sp.Rational (1 , 2 )))
程序 g 计算出一个次数为 8 的多项式 ( ( x 2 + x ) 2 + x ) 2 + x , \big((x^2 + x)^2 + x\big)^2 + x\mathclose{\text{,}} ( ( x 2 + x ) 2 + x ) 2 + x , 并利用双数在 0.5 处找到了导数,而无需任何人写出那个公式。SymPy 也同意:运行在符号 x 上的同一程序构建了公式,然后 sp.diff 对其进行微分。
图 5.4 比较了这些方法在整个步长范围 h h h 上的表现。
图 5.4 每种方法在 f ( x ) = x 3 − 2 x + 1 f(x) = x^3 - 2x + 1 f ( x ) = x 3 − 2 x + 1 处能正确计算出 f ′ ( 1.5 ) = 4.75 f'(1.5) = 4.75 f ′ ( 1.5 ) = 4.75 的多少位有效数字。前向差分(蓝色)最多只有约 9 位,中心差分(绿色)约 11 位:缩小 h h h 有助于提升精度,直到舍入误差占据主导。双数(橙色)则精确地给出 4.75。
前向与后向
双数将导数向前传递,从输入经过程序的每一步直到输出:这就是 前向模式 自动微分。一次运行可以得到一个输入的导数。然而,一个神经网络有数百万个参数,需要使训练数据上的误差变得很小,训练过程需要该误差对每个参数的导数。对每个参数进行一次前向运行将会非常缓慢。反向传播 应用了同样的链式法则,但方向相反:它记录一次运行的步骤,然后从输出向输入回溯,乘以各步骤的导数,并在一次反向传递中找到所有导数。反向传播是为多个输入组织的链式法则;模块 17 展示了它是如何工作的。
注意
自动微分对程序执行的步骤进行微分,而不是程序员心中所想的函数。一个在 x = 1 x = 1 x = 1 时返回 1,否则返回 x ⋅ x x \cdot x x ⋅ x 的程序,对每个 x 2 x^2 x 2 计算 x , x\mathclose{\text{,}} x , 但在 x = 1 x = 1 x = 1 处取常数分支,因此它在该点报告导数为 0 而不是 2。
乘积法则 ( f g ) ′ = f ′ g + f g ′ (fg)' = f'g + fg' ( f g ) ′ = f ′ g + f g ′ 以及 商的法则 ( f g ) ′ = f ′ g − f g ′ g 2 \Big(\dfrac{f}{g}\Big)' = \dfrac{f'g - fg'}{g^2} ( g f ) ′ = g 2 f ′ g − f g ′ (其中 g ≠ 0 ); g \ne 0\mathclose{\text{);}} g = 0 ); 一个增长的矩形解释了第一个。乘积的导数不是导数的乘积。
幂法则 d d x x n = n x n − 1 \dfrac{d}{dx}x^n = nx^{n-1} d x d x n = n x n − 1 对于每一个整数 n n n (x ≠ 0 x \ne 0 x = 0 当 n ≤ 0 n \le 0 n ≤ 0 时),以及 d d x x = 1 2 x \dfrac{d}{dx}\sqrt x = \dfrac{1}{2\sqrt x} d x d x = 2 x 1 对于 x > 0 。 x > 0\mathclose{\text{。}} x > 0 。
以弧度为单位, ( sin x ) ′ = cos x (\sin x)' = \cos x ( sin x ) ′ = cos x 和 ( cos x ) ′ = − sin x , (\cos x)' = -\sin x\mathclose{\text{,}} ( cos x ) ′ = − sin x , 来自加法公式和模块 2 的极限;然后 ( tan x ) ′ = sec 2 x , (\tan x)' = \sec^2 x\mathclose{\text{,}} ( tan x ) ′ = sec 2 x , ( sec x ) ′ = sec x tan x , (\sec x)' = \sec x\tan x\mathclose{\text{,}} ( sec x ) ′ = sec x tan x , ( cot x ) ′ = − csc 2 x (\cot x)' = -\csc^2 x ( cot x ) ′ = − csc 2 x 和 ( csc x ) ′ = − csc x cot x 。 (\csc x)' = -\csc x\cot x\mathclose{\text{。}} ( csc x ) ′ = − csc x cot x 。
链式法则 ** ** ( f ( g ( x ) ) ) ′ = f ′ ( g ( x ) ) g ′ ( x ) , \big(f(g(x))\big)' = f'\big(g(x)\big)\,g'(x)\mathclose{\text{,}} ( f ( g ( x )) ) ′ = f ′ ( g ( x ) ) g ′ ( x ) , 或 d y d x = d y d u ⋅ d u d x : \dfrac{dy}{dx} = \dfrac{dy}{du}\cdot\dfrac{du}{dx}\mathclose{\text{:}} d x d y = d u d y ⋅ d x d u : 速率相乘,如同齿轮比和单位换算。更长的链式相乘更多速率,从外向内。
为结合规则,找到最后的操作,应用其规则,对各个部分重复此过程,然后简化(因式分解)并检查。
sp.diff 求导;SymPy 的答案可能与你的不同,因此通过简化它们的差值进行比较,并在多个点上评估,如果差值不简化为 0。
程序通过 自动微分 区分程序:带有 a + b ε a + b\varepsilon a + b ε 的双精度数 ε 2 = 0 \varepsilon^2 = 0 ε 2 = 0 能够精确地(除舍入误差外)跟踪每个值的导数,这不同于有限差分。反向传播是链式法则的逆向应用(模块 17)。
练习 5.1 ★ 乘积、商和幂
求导:
(a) y = ( 3 x 2 − 1 ) ( x 3 + 2 x ) , y = (3x^2 - 1)(x^3 + 2x)\mathclose{\text{,}} y = ( 3 x 2 − 1 ) ( x 3 + 2 x ) , 使用乘积法则;然后通过展开来验证。
(b) y = 2 x + 1 x − 3 , y = \dfrac{2x + 1}{x - 3}\mathclose{\text{,}} y = x − 3 2 x + 1 , 用于 x ≠ 3 。 x \ne 3\mathclose{\text{。}} x = 3 。
(c) y = 5 x 3 − 1 x , y = \dfrac{5}{x^3} - \dfrac{1}{x}\mathclose{\text{,}} y = x 3 5 − x 1 , 用于 x ≠ 0 。 x \ne 0\mathclose{\text{。}} x = 0 。
(d) y = x 2 x 2 + 4 . y = \dfrac{x^2}{x^2 + 4}\mathclose{\text{.}} y = x 2 + 4 x 2 .
查看解答✓ 已检验
(a) 使用 f = 3 x 2 − 1 f = 3x^2 - 1 f = 3 x 2 − 1 和 g = x 3 + 2 x , g = x^3 + 2x\mathclose{\text{,}} g = x 3 + 2 x , 以及 f ′ = 6 x f' = 6x f ′ = 6 x 和 g ′ = 3 x 2 + 2 : g' = 3x^2 + 2\mathclose{\text{:}} g ′ = 3 x 2 + 2 :
y ′ = 6 x ( x 3 + 2 x ) + ( 3 x 2 − 1 ) ( 3 x 2 + 2 ) = ( 6 x 4 + 12 x 2 ) + ( 9 x 4 + 3 x 2 − 2 ) = 15 x 4 + 15 x 2 − 2. \begin{aligned} y' &= 6x(x^3 + 2x) \\ &\quad + (3x^2 - 1)(3x^2 + 2) \\ &= (6x^4 + 12x^2) \\ &\quad + (9x^4 + 3x^2 - 2) \\ &= 15x^4 + 15x^2 - 2. \end{aligned} y ′ = 6 x ( x 3 + 2 x ) + ( 3 x 2 − 1 ) ( 3 x 2 + 2 ) = ( 6 x 4 + 12 x 2 ) + ( 9 x 4 + 3 x 2 − 2 ) = 15 x 4 + 15 x 2 − 2.
展开后:y = 3 x 5 + 6 x 3 − x 3 − 2 x = 3 x 5 + 5 x 3 − 2 x , y = 3x^5 + 6x^3 - x^3 - 2x = 3x^5 + 5x^3 - 2x\mathclose{\text{,}} y = 3 x 5 + 6 x 3 − x 3 − 2 x = 3 x 5 + 5 x 3 − 2 x , 以及 y ′ = 15 x 4 + 15 x 2 − 2 y' = 15x^4 + 15x^2 - 2 y ′ = 15 x 4 + 15 x 2 − 2 再次。
(b) 使用商法则,以及 ( 2 x + 1 ) ′ = 2 (2x + 1)' = 2 ( 2 x + 1 ) ′ = 2 和 ( x − 3 ) ′ = 1 : (x - 3)' = 1\mathclose{\text{:}} ( x − 3 ) ′ = 1 :
y ′ = 2 ( x − 3 ) − ( 2 x + 1 ) ⋅ 1 ( x − 3 ) 2 = 2 x − 6 − 2 x − 1 ( x − 3 ) 2 = − 7 ( x − 3 ) 2 . \begin{aligned} y' &= \frac{2(x - 3) - (2x + 1)\cdot 1}{(x - 3)^2} \\ &= \frac{2x - 6 - 2x - 1}{(x - 3)^2} \\ &= -\frac{7}{(x - 3)^2}. \end{aligned} y ′ = ( x − 3 ) 2 2 ( x − 3 ) − ( 2 x + 1 ) ⋅ 1 = ( x − 3 ) 2 2 x − 6 − 2 x − 1 = − ( x − 3 ) 2 7 .
对于每一个 x ≠ 3 , x \ne 3\mathclose{\text{,}} x = 3 , 它都是负数:每一条切线都是向下倾斜的,且图像在 x = 3 x = 3 x = 3 的两侧下降(模块 8 证明了在一个区间内导数为负意味着图像下降)。
(c) 用负幂重写并使用幂法则:y = 5 x − 3 − x − 1 , y = 5x^{-3} - x^{-1}\mathclose{\text{,}} y = 5 x − 3 − x − 1 , 因此
y ′ = − 15 x − 4 + x − 2 = − 15 x 4 + 1 x 2 . \begin{aligned} y' &= -15x^{-4} + x^{-2} \\ &= -\frac{15}{x^4} + \frac{1}{x^2}. \end{aligned} y ′ = − 15 x − 4 + x − 2 = − x 4 15 + x 2 1 .
(d) 商的法则: y ′ = 2 x ( x 2 + 4 ) − x 2 ⋅ 2 x ( x 2 + 4 ) 2 = 8 x ( x 2 + 4 ) 2 . y' = \dfrac{2x(x^2 + 4) - x^2\cdot 2x}{(x^2 + 4)^2} = \dfrac{8x}{(x^2 + 4)^2}\mathclose{\text{.}} y ′ = ( x 2 + 4 ) 2 2 x ( x 2 + 4 ) − x 2 ⋅ 2 x = ( x 2 + 4 ) 2 8 x .
练习 5.2 ★ 三角函数的导数
求导:
(a) x 3 cos x x^3\cos x x 3 cos x
(b) tan x − x , \tan x - x\mathclose{\text{,}} tan x − x , 其中 cos x ≠ 0 \cos x \ne 0 cos x = 0
(c) sin x 1 − sin x , \dfrac{\sin x}{1 - \sin x}\mathclose{\text{,}} 1 − sin x sin x , 其中 sin x ≠ 1 \sin x \ne 1 sin x = 1
并且 (d) 求 y = sec x y = \sec x y = sec x 在 x = π / 4 x = \pi/4 x = π /4 处的斜率。
查看解答✓ 已检验
(a) 乘积法则: 3 x 2 cos x + x 3 ( − sin x ) = 3 x 2 cos x − x 3 sin x 。 3x^2\cos x + x^3(-\sin x) = 3x^2\cos x - x^3\sin x\mathclose{\text{。}} 3 x 2 cos x + x 3 ( − sin x ) = 3 x 2 cos x − x 3 sin x 。
(b) sec 2 x − 1 . \sec^2 x - 1\mathclose{\text{.}} sec 2 x − 1 . 将 sin 2 x + cos 2 x = 1 \sin^2 x + \cos^2 x = 1 sin 2 x + cos 2 x = 1 除以 cos 2 x \cos^2 x cos 2 x 得到 tan 2 x + 1 = sec 2 x , \tan^2 x + 1 = \sec^2 x\mathclose{\text{,}} tan 2 x + 1 = sec 2 x , 因此这是 tan 2 x 。 \tan^2 x\mathclose{\text{。}} tan 2 x 。
(c) 商的法则,其中 ( 1 − sin x ) ′ = − cos x 。 (1 - \sin x)' = -\cos x\mathclose{\text{。}} ( 1 − sin x ) ′ = − cos x 。 其分子是上函数的导数乘以下函数减去上函数乘以下函数的导数,即
cos x ( 1 − sin x ) − sin x ( − cos x ) = cos x − sin x cos x + sin x cos x = cos x , \begin{aligned} &\cos x\,(1 - \sin x) \\ &\qquad - \sin x\,(-\cos x) \\ &\quad= \cos x - \sin x\cos x \\ &\qquad + \sin x\cos x \\ &\quad= \cos x, \end{aligned} cos x ( 1 − sin x ) − sin x ( − cos x ) = cos x − sin x cos x + sin x cos x = cos x ,
因此
d d x sin x 1 − sin x = cos x ( 1 − sin x ) 2 . \frac{d}{dx}\frac{\sin x}{1 - \sin x} = \frac{\cos x}{(1 - \sin x)^2}. d x d 1 − sin x sin x = ( 1 − sin x ) 2 cos x .
(d) d d x sec x = sec x tan x , \dfrac{d}{dx}\sec x = \sec x\tan x\mathclose{\text{,}} d x d sec x = sec x tan x , 并且在 π / 4 \pi/4 π /4 处, sec π 4 = 1 cos ( π / 4 ) = 2 \sec\dfrac{\pi}{4} = \dfrac{1}{\cos(\pi/4)} = \sqrt2 sec 4 π = cos ( π /4 ) 1 = 2 和 tan π 4 = 1 。 \tan\dfrac{\pi}{4} = 1\mathclose{\text{。}} tan 4 π = 1 。 斜率是 2 ≈ 1.414 。 \sqrt2 \approx 1.414\mathclose{\text{。}} 2 ≈ 1.414 。
练习 5.3 ★ 链式法则
求导:
(a) ( 1 − 4 x ) 6 (1 - 4x)^6 ( 1 − 4 x ) 6
(b) cos ( x 3 ) \cos(x^3) cos ( x 3 )
(c) cos 3 x \cos^3 x cos 3 x
(d) 1 ( x 2 + 9 ) 2 \dfrac{1}{(x^2 + 9)^2} ( x 2 + 9 ) 2 1
(e) 4 − x 2 , \sqrt{4 - x^2}\mathclose{\text{,}} 4 − x 2 , 对于 − 2 < x < 2 -2 < x < 2 − 2 < x < 2
查看解答✓ 已检验
在每一部分中,命名内函数 u , u\mathclose{\text{,}} u , 并将外函数的导数乘以 d u / d x 。 du/dx\mathclose{\text{。}} d u / d x 。
(a) u = 1 − 4 x , u = 1 - 4x\mathclose{\text{,}} u = 1 − 4 x , 外函数 u 6 : u^6\mathclose{\text{:}} u 6 : 6 ( 1 − 4 x ) 5 ⋅ ( − 4 ) = − 24 ( 1 − 4 x ) 5 . 6(1 - 4x)^5\cdot(-4) = -24(1 - 4x)^5\mathclose{\text{.}} 6 ( 1 − 4 x ) 5 ⋅ ( − 4 ) = − 24 ( 1 − 4 x ) 5 .
(b) u = x 3 , u = x^3\mathclose{\text{,}} u = x 3 , 外函数 cos u : \cos u\mathclose{\text{:}} cos u : − sin ( x 3 ) ⋅ 3 x 2 = − 3 x 2 sin ( x 3 ) . -\sin(x^3)\cdot 3x^2 = -3x^2\sin(x^3)\mathclose{\text{.}} − sin ( x 3 ) ⋅ 3 x 2 = − 3 x 2 sin ( x 3 ) .
(c) 内层为 u = cos x , u = \cos x\mathclose{\text{,}} u = cos x , 外层为 u 3 , u^3\mathclose{\text{,}} u 3 , 结果为 3 cos 2 x ⋅ ( − sin x ) = − 3 cos 2 x sin x 。 3\cos^2 x\cdot(-\sin x) = -3\cos^2 x\sin x\mathclose{\text{。}} 3 cos 2 x ⋅ ( − sin x ) = − 3 cos 2 x sin x 。
(d) 内层为 u = x 2 + 9 , u = x^2 + 9\mathclose{\text{,}} u = x 2 + 9 , 外层为 u − 2 , u^{-2}\mathclose{\text{,}} u − 2 , 结果为 − 2 ( x 2 + 9 ) − 3 ⋅ 2 x = − 4 x ( x 2 + 9 ) 3 。 -2(x^2 + 9)^{-3}\cdot 2x = -\dfrac{4x}{(x^2 + 9)^3}\mathclose{\text{。}} − 2 ( x 2 + 9 ) − 3 ⋅ 2 x = − ( x 2 + 9 ) 3 4 x 。
(e) u = 4 − x 2 , u = 4 - x^2\mathclose{\text{,}} u = 4 − x 2 , 哪个在 − 2 < x < 2 -2 < x < 2 − 2 < x < 2 上为正;外 u : \sqrt u\mathclose{\text{:}} u : − 2 x 2 4 − x 2 = − x 4 − x 2 。 \dfrac{-2x}{2\sqrt{4 - x^2}} = -\dfrac{x}{\sqrt{4 - x^2}}\mathclose{\text{。}} 2 4 − x 2 − 2 x = − 4 − x 2 x 。 这是 例 1.2 : 顶部为 0,x = 0 , x = 0\mathclose{\text{,}} x = 0 , 向右为负,且当 x x x 趋近于 ± 2 \pm 2 ± 2 时,大小趋于无限,此时半圆垂直地与 x x x 轴相交。
练习 5.4 ★ 速率相乘
(a) 一辆自行车的踏板转动前链轮,该链轮有 44 个齿;链条驱动后链轮,该链轮有 11 个齿,固定在后轮上,其周长为 2.1 米。你以每秒一圈的速度踩踏。自行车的速度是多少?以米每秒和公里每小时表示。
(b) 假设 g ( 2 ) = 5 , g(2) = 5\mathclose{\text{,}} g ( 2 ) = 5 , g ′ ( 2 ) = 3 , g'(2) = 3\mathclose{\text{,}} g ′ ( 2 ) = 3 , f ′ ( 2 ) = 7 f'(2) = 7 f ′ ( 2 ) = 7 和 f ′ ( 5 ) = − 2 。 f'(5) = -2\mathclose{\text{。}} f ′ ( 5 ) = − 2 。 求 f ( g ( x ) ) f\big(g(x)\big) f ( g ( x ) ) 在 x = 2 x = 2 x = 2 处的导数。
查看解答✓ 已检验
(a) 三个速率相乘。设 p p p 和 w w w 分别为踏板和车轮转动的圈数,s s s 为行驶的距离,单位为米。每转一圈踏板,带动 44 链节,使后飞轮转动,进而使车轮转动 44 / 11 = 4 44/11 = 4 44/11 = 4 次:d w / d p = 4 。 dw/dp = 4\mathclose{\text{。}} d w / d p = 4 。 每转一圈车轮,自行车前进 2.1 米:d s / d w = 2.1 。 ds/dw = 2.1\mathclose{\text{。}} d s / d w = 2.1 。 并且 d p / d t = 1 dp/dt = 1 d p / d t = 1 转每秒。所以
d s d t = d s d w ⋅ d w d p ⋅ d p d t = 2.1 ⋅ 4 ⋅ 1 = 8.4 m/s . \begin{aligned} \frac{ds}{dt} &= \frac{ds}{dw}\cdot\frac{dw}{dp}\cdot\frac{dp}{dt} \\ &= 2.1 \cdot 4 \cdot 1 = 8.4 \text{ m/s}. \end{aligned} d t d s = d w d s ⋅ d p d w ⋅ d t d p = 2.1 ⋅ 4 ⋅ 1 = 8.4 m/s .
换算为公里每小时, 8.4 ⋅ 3600 / 1000 = 30.24 : 8.4 \cdot 3600/1000 = 30.24\mathclose{\text{:}} 8.4 ⋅ 3600/1000 = 30.24 : 约 30 公里/小时。
(b) 根据链式法则, ( f ∘ g ) ′ ( 2 ) = f ′ ( g ( 2 ) ) g ′ ( 2 ) = f ′ ( 5 ) ⋅ 3 = − 2 ⋅ 3 = − 6 。 (f \circ g)'(2) = f'\big(g(2)\big)\,g'(2) = f'(5)\cdot 3 = -2\cdot 3 = -6\mathclose{\text{。}} ( f ∘ g ) ′ ( 2 ) = f ′ ( g ( 2 ) ) g ′ ( 2 ) = f ′ ( 5 ) ⋅ 3 = − 2 ⋅ 3 = − 6 。 值 f ′ ( 2 ) = 7 f'(2) = 7 f ′ ( 2 ) = 7 是一个陷阱:外层导数是在 g ( 2 ) = 5 g(2) = 5 g ( 2 ) = 5 处计算,而不是在 2 处计算。错误答案 f ′ ( 2 ) g ′ ( 2 ) = 21 f'(2)\,g'(2) = 21 f ′ ( 2 ) g ′ ( 2 ) = 21 是掉入这个陷阱得到的。
练习 5.5 ★★ 水平切线和一条切线
设 y = sin x + cos x 。 y = \sin x + \cos x\mathclose{\text{。}} y = sin x + cos x 。
(a) 找出图中 0 ≤ x ≤ 2 π 0 \le x \le 2\pi 0 ≤ x ≤ 2 π 处的切线为水平的点。
(b) 求 x = π / 2 x = \pi/2 x = π /2 处的切线方程。
查看解答✓ 已检验
(a) y ′ = cos x − sin x . y' = \cos x - \sin x\mathclose{\text{.}} y ′ = cos x − sin x . 切线水平出现在 cos x = sin x 。 \cos x = \sin x\mathclose{\text{。}} cos x = sin x 。 在这样的 x x x 点, cos x ≠ 0 \cos x \ne 0 cos x = 0 (如果 cos x = 0 , \cos x = 0\mathclose{\text{,}} cos x = 0 , 则 sin x = ± 1 , \sin x = \pm 1\mathclose{\text{,}} sin x = ± 1 , 它不等于它),因此你可以除以 cos x : \cos x\mathclose{\text{:}} cos x : tan x = 1 。 \tan x = 1\mathclose{\text{。}} tan x = 1 。 在 [ 0 , 2 π ] [0, 2\pi] [ 0 , 2 π ] 中,这种情况发生在 x = π / 4 x = \pi/4 x = π /4 和 x = 5 π / 4 x = 5\pi/4 x = 5 π /4 处。
y ( π 4 ) = 2 2 + 2 2 = 2 , y ( 5 π 4 ) = − 2 2 − 2 2 = − 2 . \begin{aligned} y\Big(\frac{\pi}{4}\Big) &= \frac{\sqrt2}{2} + \frac{\sqrt2}{2} = \sqrt2, \\ y\Big(\frac{5\pi}{4}\Big) &= -\frac{\sqrt2}{2} - \frac{\sqrt2}{2} = -\sqrt2. \end{aligned} y ( 4 π ) y ( 4 5 π ) = 2 2 + 2 2 = 2 , = − 2 2 − 2 2 = − 2 .
这些点是 ( π / 4 , 2 ) \big(\pi/4, \sqrt2\big) ( π /4 , 2 ) 和 ( 5 π / 4 , − 2 ) 。 \big(5\pi/4, -\sqrt2\big)\mathclose{\text{。}} ( 5 π /4 , − 2 ) 。 它们是图像的最高点和最低点。平方后, y 2 = sin 2 x + 2 sin x cos x + cos 2 x = 1 + 2 sin x cos x , y^2 = \sin^2 x + 2\sin x\cos x + \cos^2 x = 1 + 2\sin x\cos x\mathclose{\text{,}} y 2 = sin 2 x + 2 sin x cos x + cos 2 x = 1 + 2 sin x cos x , 和 2 sin x cos x ≤ sin 2 x + cos 2 x = 1 2\sin x\cos x \le \sin^2 x + \cos^2 x = 1 2 sin x cos x ≤ sin 2 x + cos 2 x = 1 因为 ( sin x − cos x ) 2 ≥ 0 。 (\sin x - \cos x)^2 \ge 0\mathclose{\text{。}} ( sin x − cos x ) 2 ≥ 0 。 因此 y 2 ≤ 2 , y^2 \le 2\mathclose{\text{,}} y 2 ≤ 2 , 即 − 2 ≤ y ≤ 2 , -\sqrt2 \le y \le \sqrt2\mathclose{\text{,}} − 2 ≤ y ≤ 2 , 这两个点达到这些极值。
(b) 在 x = π / 2 , x = \pi/2\mathclose{\text{,}} x = π /2 , y = 1 + 0 = 1 y = 1 + 0 = 1 y = 1 + 0 = 1 和 y ′ = 0 − 1 = − 1 。 y' = 0 - 1 = -1\mathclose{\text{。}} y ′ = 0 − 1 = − 1 。 通过 ( π / 2 , 1 ) (\pi/2, 1) ( π /2 , 1 ) 点,斜率为 − 1 -1 − 1 的切线是 y − 1 = − ( x − π / 2 ) , y - 1 = -(x - \pi/2)\mathclose{\text{,}} y − 1 = − ( x − π /2 ) , 即,
y = − x + 1 + π 2 . y = -x + 1 + \frac{\pi}{2}. y = − x + 1 + 2 π .
练习 5.6 ★★ 组合规则
求导并化简:
(a) x 2 ( 1 − 3 x ) 5 x^2(1 - 3x)^5 x 2 ( 1 − 3 x ) 5
(b) x 2 + 4 x , \sqrt{x^2 + 4x}\mathclose{\text{,}} x 2 + 4 x , 对于 x > 0 x > 0 x > 0
(c) sec ( x 2 ) , \sec(x^2)\mathclose{\text{,}} sec ( x 2 ) , 其中 cos ( x 2 ) ≠ 0 \cos(x^2) \ne 0 cos ( x 2 ) = 0
(d) x x 2 + 1 \dfrac{x}{\sqrt{x^2 + 1}} x 2 + 1 x
查看解答✓ 已检验
(a) 应用乘积法则,其中第二个因子用链式法则求导,导数为 5 ( 1 − 3 x ) 4 ( − 3 ) = − 15 ( 1 − 3 x ) 4 。 5(1 - 3x)^4(-3) = -15(1 - 3x)^4\mathclose{\text{。}} 5 ( 1 − 3 x ) 4 ( − 3 ) = − 15 ( 1 − 3 x ) 4 。 结果的两项都含有 x ( 1 − 3 x ) 4 , x(1 - 3x)^4\mathclose{\text{,}} x ( 1 − 3 x ) 4 , 提取这个因子后剩下 2 ( 1 − 3 x ) − 15 x = 2 − 21 x , 2(1 - 3x) - 15x = 2 - 21x\mathclose{\text{,}} 2 ( 1 − 3 x ) − 15 x = 2 − 21 x , 所以
y ′ = 2 x ( 1 − 3 x ) 5 − 15 x 2 ( 1 − 3 x ) 4 = x ( 1 − 3 x ) 4 ( 2 − 21 x ) . \begin{aligned} y' &= 2x(1 - 3x)^5 \\ &\quad - 15x^2(1 - 3x)^4 \\ &= x(1 - 3x)^4(2 - 21x). \end{aligned} y ′ = 2 x ( 1 − 3 x ) 5 − 15 x 2 ( 1 − 3 x ) 4 = x ( 1 − 3 x ) 4 ( 2 − 21 x ) .
(b) 对于 x > 0 , x > 0\mathclose{\text{,}} x > 0 , x 2 + 4 x > 0 , x^2 + 4x > 0\mathclose{\text{,}} x 2 + 4 x > 0 , 以及平方根的链式法则给出
2 x + 4 2 x 2 + 4 x = x + 2 x 2 + 4 x . \frac{2x + 4}{2\sqrt{x^2 + 4x}} = \frac{x + 2}{\sqrt{x^2 + 4x}}. 2 x 2 + 4 x 2 x + 4 = x 2 + 4 x x + 2 .
(c) 外层 sec u , \sec u\mathclose{\text{,}} sec u , 内层 u = x 2 : u = x^2\mathclose{\text{:}} u = x 2 : sec ( x 2 ) tan ( x 2 ) ⋅ 2 x = 2 x sec ( x 2 ) tan ( x 2 ) . \sec(x^2)\tan(x^2)\cdot 2x = 2x\sec(x^2)\tan(x^2)\mathclose{\text{.}} sec ( x 2 ) tan ( x 2 ) ⋅ 2 x = 2 x sec ( x 2 ) tan ( x 2 ) .
(d) 商的法则,其中 ( x 2 + 1 ) ′ = x x 2 + 1 \big(\sqrt{x^2 + 1}\big)' = \dfrac{x}{\sqrt{x^2 + 1}} ( x 2 + 1 ) ′ = x 2 + 1 x (例 5.11)。然后将分子和分母都乘以 x 2 + 1 : \sqrt{x^2 + 1}\mathclose{\text{:}} x 2 + 1 :
y ′ = x 2 + 1 − x ⋅ x x 2 + 1 x 2 + 1 = ( x 2 + 1 ) − x 2 ( x 2 + 1 ) x 2 + 1 = 1 ( x 2 + 1 ) 3 / 2 . \begin{aligned} y' &= \frac{\sqrt{x^2 + 1} - x\cdot\dfrac{x}{\sqrt{x^2 + 1}}}{x^2 + 1} \\ &= \frac{(x^2 + 1) - x^2}{(x^2 + 1)\sqrt{x^2 + 1}} \\ &= \frac{1}{(x^2 + 1)^{3/2}}. \end{aligned} y ′ = x 2 + 1 x 2 + 1 − x ⋅ x 2 + 1 x = ( x 2 + 1 ) x 2 + 1 ( x 2 + 1 ) − x 2 = ( x 2 + 1 ) 3/2 1 .
练习 5.7 ★★ 一个弹簧在两倍频率下振动
一个质量在更硬的弹簧上振动,经过 t t t 秒后高度为 s ( t ) = 3 cos ( 2 t ) + 4 sin ( 2 t ) s(t) = 3\cos(2t) + 4\sin(2t) s ( t ) = 3 cos ( 2 t ) + 4 sin ( 2 t ) 厘米。
(a) 求其速度 v ( t ) v(t) v ( t ) 和加速度 a ( t ) 。 a(t)\mathclose{\text{。}} a ( t ) 。
(b) 证明 a = − 4 s a = -4s a = − 4 s 在每一时刻成立,并解释 4 的来源。
(c) 求 t = 0 t = 0 t = 0 和 t = π / 4 t = \pi/4 t = π /4 时的位置和速度。
查看解答✓ 已检验
(a) 每一项都需要使用内函数 2 t 2t 2 t 的链式法则,其导数为 2。以厘米/秒和厘米/秒²为单位,
v ( t ) = − 6 sin ( 2 t ) + 8 cos ( 2 t ) , a ( t ) = − 12 cos ( 2 t ) − 16 sin ( 2 t ) . \begin{aligned} v(t) &= -6\sin(2t) + 8\cos(2t), \\ a(t) &= -12\cos(2t) - 16\sin(2t). \end{aligned} v ( t ) a ( t ) = − 6 sin ( 2 t ) + 8 cos ( 2 t ) , = − 12 cos ( 2 t ) − 16 sin ( 2 t ) .
(b) a ( t ) = − 4 ( 3 cos ( 2 t ) + 4 sin ( 2 t ) ) = − 4 s ( t ) . a(t) = -4\big(3\cos(2t) + 4\sin(2t)\big) = -4s(t)\mathclose{\text{.}} a ( t ) = − 4 ( 3 cos ( 2 t ) + 4 sin ( 2 t ) ) = − 4 s ( t ) . 每次求导都会从内部函数 2 t 2t 2 t 中提取一个因子 2,两次求导则提取 2 ⋅ 2 = 4 。 2 \cdot 2 = 4\mathclose{\text{。}} 2 ⋅ 2 = 4 。 (在例 5.6 中,对于 sin t \sin t sin t 和 cos t , \cos t\mathclose{\text{,}} cos t , 因子为 1 ⋅ 1 = 1 。) 1 \cdot 1 = 1\mathclose{\text{。)}} 1 ⋅ 1 = 1 。 )
(c) 在 t = 0 : t = 0\mathclose{\text{:}} t = 0 : s = 3 s = 3 s = 3 厘米, v = 8 v = 8 v = 8 厘米/秒,向上。在 t = π / 4 , t = \pi/4\mathclose{\text{,}} t = π /4 , 2 t = π / 2 , 2t = \pi/2\mathclose{\text{,}} 2 t = π /2 , 因此 s = 3 ⋅ 0 + 4 ⋅ 1 = 4 s = 3 \cdot 0 + 4 \cdot 1 = 4 s = 3 ⋅ 0 + 4 ⋅ 1 = 4 厘米, v = − 6 ⋅ 1 + 8 ⋅ 0 = − 6 v = -6 \cdot 1 + 8 \cdot 0 = -6 v = − 6 ⋅ 1 + 8 ⋅ 0 = − 6 厘米/秒:质量为 4 厘米向上运动,速度为 6 厘米/秒向下。
练习 5.8 ★★ 相同导数,不同形式
(a) 对 tan 2 x \tan^2 x tan 2 x 和 sec 2 x \sec^2 x sec 2 x (在 cos x ≠ 0 \cos x \ne 0 cos x = 0 处) 求导,并证明两个导数相等。
(b) 不通过求导解释为何它们必须相等。
(c) 对于第一个,SymPy 输出 (2*tan(x)**2 + 2)*tan(x)。通过手动计算和 SymPy 验证,证明它与你的答案一致。
查看解答✓ 已检验
(a) 通过外函数 u 2 u^2 u 2 的链式法则: d d x tan 2 x = 2 tan x sec 2 x , \dfrac{d}{dx}\tan^2 x = 2\tan x\sec^2 x\mathclose{\text{,}} d x d tan 2 x = 2 tan x sec 2 x , 和 d d x sec 2 x = 2 sec x ⋅ sec x tan x = 2 sec 2 x tan x 。 \dfrac{d}{dx}\sec^2 x = 2\sec x\cdot\sec x\tan x = 2\sec^2 x\tan x\mathclose{\text{。}} d x d sec 2 x = 2 sec x ⋅ sec x tan x = 2 sec 2 x tan x 。 它们相等。
(b) tan 2 x + 1 = sec 2 x \tan^2 x + 1 = \sec^2 x tan 2 x + 1 = sec 2 x (用 cos 2 x \cos^2 x cos 2 x 除以 sin 2 x + cos 2 x = 1 ). \sin^2 x + \cos^2 x = 1\mathclose{\text{).}} sin 2 x + cos 2 x = 1 ). 所以这两个函数相差一个常数 1,而常数的导数是 0。
(c) ( 2 tan 2 x + 2 ) tan x = 2 ( tan 2 x + 1 ) tan x = 2 sec 2 x tan x . (2\tan^2 x + 2)\tan x = 2(\tan^2 x + 1)\tan x = 2\sec^2 x\tan x\mathclose{\text{.}} ( 2 tan 2 x + 2 ) tan x = 2 ( tan 2 x + 1 ) tan x = 2 sec 2 x tan x . 使用 SymPy 简化它们的差:
Python 复制
import sympy as sp
x = sp.symbols ('x' )
a = sp.diff (sp.tan (x)**2 , x)
b = sp.diff (sp.sec (x)**2 , x)
print (a, '|' , b)
print (sp.simplify (a - b))
输出
(2*tan(x)**2 + 2)*tan(x) | 2*tan(x)*sec(x)**2
0
差为 0:这两个答案是同一个函数,只是写法不同。
练习 5.9 ★★ 手动计算双数
使用双数的运算规则,结合 ε 2 = 0 。 \varepsilon^2 = 0\mathclose{\text{。}} ε 2 = 0 。
(a) 计算 ( 2 + ε ) 2 (2 + \varepsilon)^2 ( 2 + ε ) 2 和 ( 2 + ε ) 3 。 (2 + \varepsilon)^3\mathclose{\text{。}} ( 2 + ε ) 3 。
(b) 设 f ( x ) = x 3 − 4 x 。 f(x) = x^3 - 4x\mathclose{\text{。}} f ( x ) = x 3 − 4 x 。 计算 f ( 2 + ε ) , f(2 + \varepsilon)\mathclose{\text{,}} f ( 2 + ε ) , 读出 f ( 2 ) f(2) f ( 2 ) 和 f ′ ( 2 ) , f'(2)\mathclose{\text{,}} f ′ ( 2 ) , 并用幂法则验证 f ′ ( 2 ) 。 f'(2)\mathclose{\text{。}} f ′ ( 2 ) 。
(c) 计算 f ( 3 + 2 ε ) , f(3 + 2\varepsilon)\mathclose{\text{,}} f ( 3 + 2 ε ) , 并用定理 5.7 解释其 ε \varepsilon ε 部分。
查看解答✓ 已检验
(a) ( 2 + ε ) 2 = 4 + 4 ε + ε 2 = 4 + 4 ε , (2 + \varepsilon)^2 = 4 + 4\varepsilon + \varepsilon^2 = 4 + 4\varepsilon\mathclose{\text{,}} ( 2 + ε ) 2 = 4 + 4 ε + ε 2 = 4 + 4 ε , 并
( 2 + ε ) 3 = ( 4 + 4 ε ) ( 2 + ε ) = 8 + 4 ε + 8 ε + 4 ε 2 = 8 + 12 ε . \begin{aligned} (2 + \varepsilon)^3 &= (4 + 4\varepsilon)(2 + \varepsilon) \\ &= 8 + 4\varepsilon + 8\varepsilon + 4\varepsilon^2 \\ &= 8 + 12\varepsilon. \end{aligned} ( 2 + ε ) 3 = ( 4 + 4 ε ) ( 2 + ε ) = 8 + 4 ε + 8 ε + 4 ε 2 = 8 + 12 ε .
(b) f ( 2 + ε ) = ( 8 + 12 ε ) − 4 ( 2 + ε ) = 8 + 12 ε − 8 − 4 ε = 0 + 8 ε . f(2 + \varepsilon) = (8 + 12\varepsilon) - 4(2 + \varepsilon) = 8 + 12\varepsilon - 8 - 4\varepsilon = 0 + 8\varepsilon\mathclose{\text{.}} f ( 2 + ε ) = ( 8 + 12 ε ) − 4 ( 2 + ε ) = 8 + 12 ε − 8 − 4 ε = 0 + 8 ε . 所以 f ( 2 ) = 0 f(2) = 0 f ( 2 ) = 0 和 f ′ ( 2 ) = 8 . f'(2) = 8\mathclose{\text{.}} f ′ ( 2 ) = 8 . 检查: f ′ ( x ) = 3 x 2 − 4 , f'(x) = 3x^2 - 4\mathclose{\text{,}} f ′ ( x ) = 3 x 2 − 4 , 和 f ′ ( 2 ) = 12 − 4 = 8 。 f'(2) = 12 - 4 = 8\mathclose{\text{。}} f ′ ( 2 ) = 12 − 4 = 8 。
(c) ( 3 + 2 ε ) 2 = 9 + 12 ε (3 + 2\varepsilon)^2 = 9 + 12\varepsilon ( 3 + 2 ε ) 2 = 9 + 12 ε 和 ( 3 + 2 ε ) 3 = ( 9 + 12 ε ) ( 3 + 2 ε ) = 27 + 54 ε , (3 + 2\varepsilon)^3 = (9 + 12\varepsilon)(3 + 2\varepsilon) = 27 + 54\varepsilon\mathclose{\text{,}} ( 3 + 2 ε ) 3 = ( 9 + 12 ε ) ( 3 + 2 ε ) = 27 + 54 ε , 所以
f ( 3 + 2 ε ) = 27 + 54 ε − 12 − 8 ε = 15 + 46 ε . \begin{aligned} f(3 + 2\varepsilon) &= 27 + 54\varepsilon - 12 - 8\varepsilon \\ &= 15 + 46\varepsilon. \end{aligned} f ( 3 + 2 ε ) = 27 + 54 ε − 12 − 8 ε = 15 + 46 ε .
根据定理 5.7 以及 a = 3 a = 3 a = 3 和 b = 2 , b = 2\mathclose{\text{,}} b = 2 , ε \varepsilon ε 部分是 f ′ ( 3 ) ⋅ 2 , f'(3)\cdot 2\mathclose{\text{,}} f ′ ( 3 ) ⋅ 2 , 并且确实 f ′ ( 3 ) = 27 − 4 = 23 f'(3) = 27 - 4 = 23 f ′ ( 3 ) = 27 − 4 = 23 和 23 ⋅ 2 = 46 。 23 \cdot 2 = 46\mathclose{\text{。}} 23 ⋅ 2 = 46 。 将输入视为一个随时间变化的量 x , x\mathclose{\text{,}} x , 其值为 3,变化率是 d x / d t = 2 : dx/dt = 2\mathclose{\text{:}} d x / d t = 2 : 那么输出的 ε \varepsilon ε 部分是 d f d x ⋅ d x d t , \dfrac{df}{dx}\cdot\dfrac{dx}{dt}\mathclose{\text{,}} d x df ⋅ d t d x , 再次应用链式法则。
练习 5.10 ★★★ 幂法则的归纳证明
数学归纳法 的证明表明,一个命题对每个正整数n n n 的成立需要两个步骤。基础情况 展示了它在n = 1 n = 1 n = 1 时的成立。归纳步骤 展示了每当它对某个n n n 成立时,它对n + 1 n + 1 n + 1 也成立。那么它对1成立,因此对2成立,对3成立,并对每个n n n 如此,就像一排倒下的多米诺骨牌。(模块9再次使用了该方法。)
仅使用乘积法则和 x x x 的导数(不使用模块 4 其他部分的幂法则)。
(a) 用归纳法证明 d d x x n = n x n − 1 \dfrac{d}{dx}x^n = nx^{n-1} d x d x n = n x n − 1 对于每一个正整数 n n n 成立。
(b) 用相同的方法证明,如果 f f f 在 x x x 处可导,则对于每个正整数 n , n\mathclose{\text{,}} n , 都有 d d x f ( x ) n = n f ( x ) n − 1 f ′ ( x ) : \dfrac{d}{dx}f(x)^n = nf(x)^{n-1}f'(x)\mathclose{\text{:}} d x d f ( x ) n = n f ( x ) n − 1 f ′ ( x ) : 幂函数的链式法则,不使用链式法则。
查看解答✓ 已检验
(a) 基础情形。 对于 n = 1 : n = 1\mathclose{\text{:}} n = 1 : 函数 x x x 在每个 h ≠ 0 h \ne 0 h = 0 处的差商为 ( x + h ) − x h = 1 , \dfrac{(x + h) - x}{h} = 1\mathclose{\text{,}} h ( x + h ) − x = 1 , 因此 d d x x = 1 = 1 ⋅ x 0 。 \dfrac{d}{dx}x = 1 = 1\cdot x^0\mathclose{\text{。}} d x d x = 1 = 1 ⋅ x 0 。
归纳步骤。 假设 d d x x n = n x n − 1 \dfrac{d}{dx}x^n = nx^{n-1} d x d x n = n x n − 1 在某个 n ≥ 1 n \ge 1 n ≥ 1 处成立。则 x n + 1 = x ⋅ x n , x^{n+1} = x \cdot x^n\mathclose{\text{,}} x n + 1 = x ⋅ x n , 并由乘积法则
d d x x n + 1 = 1 ⋅ x n + x ⋅ n x n − 1 = x n + n x n = ( n + 1 ) x n , \begin{aligned} \frac{d}{dx}x^{n+1} &= 1 \cdot x^n + x \cdot nx^{n-1} \\ &= x^n + nx^n \\ &= (n + 1)x^n, \end{aligned} d x d x n + 1 = 1 ⋅ x n + x ⋅ n x n − 1 = x n + n x n = ( n + 1 ) x n ,
得到 n + 1 n + 1 n + 1 的陈述。通过归纳,对于每个正整数 n n n 都成立。
(b) 基础情形。 对于 n = 1 , n = 1\mathclose{\text{,}} n = 1 , 陈述为 ( f 1 ) ′ = 1 ⋅ f ′ , (f^1)' = 1\cdot f'\mathclose{\text{,}} ( f 1 ) ′ = 1 ⋅ f ′ , 这是正确的。
归纳步骤。 假设 ( f n ) ′ = n f n − 1 f ′ (f^n)' = nf^{n-1}f' ( f n ) ′ = n f n − 1 f ′ 在 x x x 处成立。则 f n + 1 = f ⋅ f n , f^{n+1} = f\cdot f^n\mathclose{\text{,}} f n + 1 = f ⋅ f n , 并由乘积法则
( f n + 1 ) ′ = f ′ ⋅ f n + f ⋅ n f n − 1 f ′ = ( 1 + n ) f n f ′ , \begin{aligned} (f^{n+1})' &= f'\cdot f^n + f\cdot nf^{n-1}f' \\ &= (1 + n)f^n f', \end{aligned} ( f n + 1 ) ′ = f ′ ⋅ f n + f ⋅ n f n − 1 f ′ = ( 1 + n ) f n f ′ ,
得到 n + 1 n + 1 n + 1 的陈述。这是乘积法则的模式,每个项对一个因子求导: f n f^n f n 有 n n n 个因子 f , f\mathclose{\text{,}} f , 因此其导数有 n n n 个相等的项 f n − 1 f ′ 。 f^{n-1}f'\mathclose{\text{。}} f n − 1 f ′ 。
练习 5.11 ★★★ 当内部变化为零时
设 g ( x ) = x 2 sin ( 1 / x ) g(x) = x^2\sin(1/x) g ( x ) = x 2 sin ( 1/ x ) 对于 x ≠ 0 , x \ne 0\mathclose{\text{,}} x = 0 , 且 g ( 0 ) = 0 . g(0) = 0\mathclose{\text{.}} g ( 0 ) = 0 .
(a) 用定义和夹逼定理证明 g ′ ( 0 ) = 0 。 g'(0) = 0\mathclose{\text{。}} g ′ ( 0 ) = 0 。
(b) 证明 g ( h ) = 0 g(h) = 0 g ( h ) = 0 对于 h = 1 k π , h = \dfrac{1}{k\pi}\mathclose{\text{,}} h = k π 1 , k = 1 , 2 , 3 , … 。 k = 1, 2, 3, \dots\mathclose{\text{。}} k = 1 , 2 , 3 , … 。 为什么这会破坏链式法则证明在 x = 0 x = 0 x = 0 处的思路?
(c) 设 f ( u ) = u 2 + u f(u) = u^2 + u f ( u ) = u 2 + u 和 F ( x ) = f ( g ( x ) ) 。 F(x) = f\big(g(x)\big)\mathclose{\text{。}} F ( x ) = f ( g ( x ) ) 。 用链式法则求 F ′ ( 0 ) , F'(0)\mathclose{\text{,}} F ′ ( 0 ) , 并从定义进行验证。
查看解答✓ 已检验
(a) 这是 练习 4.11 (b) 再次出现。对于 h ≠ 0 , h \ne 0\mathclose{\text{,}} h = 0 , 差商是 g ( h ) − g ( 0 ) h = h 2 sin ( 1 / h ) h = h sin ( 1 / h ) 。 \dfrac{g(h) - g(0)}{h} = \dfrac{h^2\sin(1/h)}{h} = h\sin(1/h)\mathclose{\text{。}} h g ( h ) − g ( 0 ) = h h 2 sin ( 1/ h ) = h sin ( 1/ h ) 。 由于 − 1 ≤ sin ( 1 / h ) ≤ 1 , -1 \le \sin(1/h) \le 1\mathclose{\text{,}} − 1 ≤ sin ( 1/ h ) ≤ 1 , 它介于 − ∣ h ∣ -\abs{h} − ∣ h ∣ 和 ∣ h ∣ \abs{h} ∣ h ∣ 之间,而这两个都趋于 0。根据夹逼定理,h sin ( 1 / h ) → 0 : h\sin(1/h) \to 0\mathclose{\text{:}} h sin ( 1/ h ) → 0 : g ′ ( 0 ) = 0 . g'(0) = 0\mathclose{\text{.}} g ′ ( 0 ) = 0 .
(b) g ( 1 k π ) = 1 k 2 π 2 sin ( k π ) = 0 , g\Big(\dfrac{1}{k\pi}\Big) = \dfrac{1}{k^2\pi^2}\sin(k\pi) = 0\mathclose{\text{,}} g ( k π 1 ) = k 2 π 2 1 sin ( k π ) = 0 , 因为sin ( k π ) = 0 。 \sin(k\pi) = 0\mathclose{\text{。}} sin ( k π ) = 0 。 因此,对于可以任意接近0的h = 1 / π , 1 / ( 2 π ) , 1 / ( 3 π ) , … h = 1/\pi, 1/(2\pi), 1/(3\pi), \dots h = 1/ π , 1/ ( 2 π ) , 1/ ( 3 π ) , … 数,Δ u = g ( 0 + h ) − g ( 0 ) \Delta u = g(0 + h) - g(0) Δ u = g ( 0 + h ) − g ( 0 ) 为0。对于这些h , h\mathclose{\text{,}} h , 证明思路中的商Δ y / Δ u \Delta y/\Delta u Δ y /Δ u 为0 / 0 , 0/0\mathclose{\text{,}} 0/0 , 因此该论证在x = 0 x = 0 x = 0 处无法完成。5.5节“深入一步”框中的证明从未除以Δ u , \Delta u\mathclose{\text{,}} Δ u , 因此它涵盖了这种情况。
(c) f ′ ( u ) = 2 u + 1 , f'(u) = 2u + 1\mathclose{\text{,}} f ′ ( u ) = 2 u + 1 , 所以根据链式法则 F ′ ( 0 ) = f ′ ( g ( 0 ) ) g ′ ( 0 ) = ( 2 ⋅ 0 + 1 ) ⋅ 0 = 0 . F'(0) = f'\big(g(0)\big)\,g'(0) = (2\cdot 0 + 1)\cdot 0 = 0\mathclose{\text{.}} F ′ ( 0 ) = f ′ ( g ( 0 ) ) g ′ ( 0 ) = ( 2 ⋅ 0 + 1 ) ⋅ 0 = 0 . 根据定义: F ( 0 ) = f ( 0 ) = 0 , F(0) = f(0) = 0\mathclose{\text{,}} F ( 0 ) = f ( 0 ) = 0 , 并且对于 h ≠ 0 h \ne 0 h = 0
F ( h ) − F ( 0 ) h = g ( h ) 2 + g ( h ) h = g ( h ) ⋅ g ( h ) h + g ( h ) h . \begin{aligned} &\frac{F(h) - F(0)}{h} \\ &\quad= \frac{g(h)^2 + g(h)}{h} \\ &\quad= g(h)\cdot\frac{g(h)}{h} + \frac{g(h)}{h}. \end{aligned} h F ( h ) − F ( 0 ) = h g ( h ) 2 + g ( h ) = g ( h ) ⋅ h g ( h ) + h g ( h ) .
由 (a), g ( h ) / h → 0 , g(h)/h \to 0\mathclose{\text{,}} g ( h ) / h → 0 , 和 g ( h ) → 0 g(h) \to 0 g ( h ) → 0 因为 ∣ g ( h ) ∣ ≤ h 2 . \abs{g(h)} \le h^2\mathclose{\text{.}} ∣ g ( h ) ∣ ≤ h 2 . 所以商趋于 0 ⋅ 0 + 0 = 0 , 0 \cdot 0 + 0 = 0\mathclose{\text{,}} 0 ⋅ 0 + 0 = 0 , 正如链式法则所说。
练习 5.12 ★★★ 双数的除法
(a) 设 c ≠ 0 . c \ne 0\mathclose{\text{.}} c = 0 . 求具有 ( c + d ε ) ( p + q ε ) = a + b ε (c + d\varepsilon)(p + q\varepsilon) = a + b\varepsilon ( c + d ε ) ( p + q ε ) = a + b ε 的双数 p + q ε , p + q\varepsilon\mathclose{\text{,}} p + q ε , 即商 a + b ε c + d ε 。 \dfrac{a + b\varepsilon}{c + d\varepsilon}\mathclose{\text{。}} c + d ε a + b ε 。
(b) 解释为什么结果是商的法则。
(c) 将除法添加到第 5.8 节的 Dual 类中,并计算 f ( x ) = 1 1 + x 2 f(x) = \dfrac{1}{1 + x^2} f ( x ) = 1 + x 2 1 在 x = 2 x = 2 x = 2 处的导数。与商的法则进行比较。
查看解答✓ 已检验
(a) 展开: ( c + d ε ) ( p + q ε ) = c p + ( c q + d p ) ε . (c + d\varepsilon)(p + q\varepsilon) = cp + (cq + dp)\varepsilon\mathclose{\text{.}} ( c + d ε ) ( p + q ε ) = c p + ( c q + d p ) ε . 这等于 a + b ε a + b\varepsilon a + b ε 当 c p = a cp = a c p = a 和 c q + d p = b . cq + dp = b\mathclose{\text{.}} c q + d p = b . 由于 c ≠ 0 , c \ne 0\mathclose{\text{,}} c = 0 , p = a c , p = \dfrac{a}{c}\mathclose{\text{,}} p = c a , 然后 q = b − d p c = b − a d / c c = b c − a d c 2 . q = \dfrac{b - dp}{c} = \dfrac{b - ad/c}{c} = \dfrac{bc - ad}{c^2}\mathclose{\text{.}} q = c b − d p = c b − a d / c = c 2 b c − a d . 所以
a + b ε c + d ε = a c + b c − a d c 2 ε . \frac{a + b\varepsilon}{c + d\varepsilon} = \frac{a}{c} + \frac{bc - ad}{c^2}\,\varepsilon. c + d ε a + b ε = c a + c 2 b c − a d ε .
(b) 代入两个函数的值和导数: a = f ( x ) , a = f(x)\mathclose{\text{,}} a = f ( x ) , b = f ′ ( x ) , b = f'(x)\mathclose{\text{,}} b = f ′ ( x ) , c = g ( x ) , c = g(x)\mathclose{\text{,}} c = g ( x ) , d = g ′ ( x ) . d = g'(x)\mathclose{\text{.}} d = g ′ ( x ) . 的 ε \varepsilon ε 部分变为 f ′ ( x ) g ( x ) − f ( x ) g ′ ( x ) g ( x ) 2 , \dfrac{f'(x)g(x) - f(x)g'(x)}{g(x)^2}\mathclose{\text{,}} g ( x ) 2 f ′ ( x ) g ( x ) − f ( x ) g ′ ( x ) , 商的法则. (条件 c ≠ 0 c \ne 0 c = 0 是商的法则的 g ( x ) ≠ 0 .) g(x) \ne 0\mathclose{\text{.)}} g ( x ) = 0 .)
(c) 两种方法: __truediv__ 对于 d / e, __rtruediv__ 对于一个普通数除以一个双变量,如 1/(1 + x*x):
Python 复制
class Dual :
def __init__ (self, a, b=0.0 ):
self.a, self.b = a, b
def __add__ (self, other):
other = other if isinstance (other, Dual) else Dual (other)
return Dual (self.a + other.a, self.b + other.b)
def __mul__ (self, other):
other = other if isinstance (other, Dual) else Dual (other)
return Dual (self.a*other.a, self.a*other.b + self.b*other.a)
def __truediv__ (self, other): # (a + bε)/(c + dε), with c ≠ 0
other = other if isinstance (other, Dual) else Dual (other)
a, b, c, d = self.a, self.b, other.a, other.b
return Dual (a/c, (b*c - a*d)/c**2 )
def __rtruediv__ (self, other): # number / dual
return Dual (other)/self
__radd__, __rmul__ = __add__, __mul__
Python 复制
def f (x):
return 1 /(1 + x*x)
y = f (Dual (2.0 , 1.0 ))
print (y.a, y.b)
商的法则给出 f ′ ( x ) = 0 ⋅ ( 1 + x 2 ) − 1 ⋅ 2 x ( 1 + x 2 ) 2 = − 2 x ( 1 + x 2 ) 2 , f'(x) = \dfrac{0\cdot(1 + x^2) - 1\cdot 2x}{(1 + x^2)^2} = -\dfrac{2x}{(1 + x^2)^2}\mathclose{\text{,}} f ′ ( x ) = ( 1 + x 2 ) 2 0 ⋅ ( 1 + x 2 ) − 1 ⋅ 2 x = − ( 1 + x 2 ) 2 2 x , 所以 f ( 2 ) = 1 5 = 0.2 f(2) = \dfrac15 = 0.2 f ( 2 ) = 5 1 = 0.2 和 f ′ ( 2 ) = − 4 25 = − 0.16 : f'(2) = -\dfrac{4}{25} = -0.16\mathclose{\text{:}} f ′ ( 2 ) = − 25 4 = − 0.16 : 相同的数值.
1 d d x ( x 3 sin x ) \dfrac{d}{dx}\big(x^3\sin x\big) d x d ( x 3 sin x ) 等于
3 x 2 cos x 3x^2\cos x 3 x 2 cos x 3 x 2 sin x + x 3 cos x 3x^2\sin x + x^3\cos x 3 x 2 sin x + x 3 cos x 3 x 2 sin x − x 3 cos x 3x^2\sin x - x^3\cos x 3 x 2 sin x − x 3 cos x x 3 cos x x^3\cos x x 3 cos x 根据乘积法则,第一个因子的导数乘以第二个因子,加上第一个因子乘以第二个因子的导数:
3 x 2 sin x + x 3 cos x . 3x^2\sin x + x^3\cos x\mathclose{\text{.}} 3 x 2 sin x + x 3 cos x . 3 x 2 cos x 3x^2\cos x 3 x 2 cos x 乘以两个导数,这不是规则;
x 3 cos x x^3\cos x x 3 cos x 仅对第二个因子求导;而负号属于商的法则.
2 d d x x x + 1 \dfrac{d}{dx}\dfrac{x}{x + 1} d x d x + 1 x 对于
x ≠ − 1 , x \ne -1\mathclose{\text{,}} x = − 1 , 等于
1 1 1 − 1 ( x + 1 ) 2 -\dfrac{1}{(x + 1)^2} − ( x + 1 ) 2 1 2 x + 1 ( x + 1 ) 2 \dfrac{2x + 1}{(x + 1)^2} ( x + 1 ) 2 2 x + 1 1 ( x + 1 ) 2 \dfrac{1}{(x + 1)^2} ( x + 1 ) 2 1 商的法则:
1 ⋅ ( x + 1 ) − x ⋅ 1 ( x + 1 ) 2 = 1 ( x + 1 ) 2 . \dfrac{1\cdot(x + 1) - x\cdot 1}{(x + 1)^2} = \dfrac{1}{(x + 1)^2}\mathclose{\text{.}} ( x + 1 ) 2 1 ⋅ ( x + 1 ) − x ⋅ 1 = ( x + 1 ) 2 1 . 答案 1 将导数相除,
1 / 1 ; 1/1\mathclose{\text{;}} 1/1 ; − 1 ( x + 1 ) 2 -\dfrac{1}{(x + 1)^2} − ( x + 1 ) 2 1 的分子顺序颠倒;
2 x + 1 ( x + 1 ) 2 \dfrac{2x + 1}{(x + 1)^2} ( x + 1 ) 2 2 x + 1 用加号代替减号。
3 y = cos x y = \cos x y = cos x 在
x = π / 2 x = \pi/2 x = π /2 处的斜率是
− 1 -1 − 1 0 0 0 1 1 1 π / 2 \pi/2 π /2 ( cos x ) ′ = − sin x , (\cos x)' = -\sin x\mathclose{\text{,}} ( cos x ) ′ = − sin x , 和
− sin ( π / 2 ) = − 1 : -\sin(\pi/2) = -1\mathclose{\text{:}} − sin ( π /2 ) = − 1 : 余弦在穿过轴时递减。 0 是值
cos ( π / 2 ) , \cos(\pi/2)\mathclose{\text{,}} cos ( π /2 ) , 不是斜率; 1 忘记了负号。
4 d d x sin ( 3 x ) \dfrac{d}{dx}\sin(3x) d x d sin ( 3 x ) 等于
cos ( 3 x ) \cos(3x) cos ( 3 x ) 3 cos x 3\cos x 3 cos x 3 cos ( 3 x ) 3\cos(3x) 3 cos ( 3 x ) − 3 cos ( 3 x ) -3\cos(3x) − 3 cos ( 3 x ) 链式法则,内函数为
3 x : 3x\mathclose{\text{:}} 3 x : cos ( 3 x ) ⋅ 3 。 \cos(3x)\cdot 3\mathclose{\text{。}} cos ( 3 x ) ⋅ 3 。 cos ( 3 x ) \cos(3x) cos ( 3 x ) 忘记了内函数的导数;
3 cos x 3\cos x 3 cos x 改变了余弦的内部; 负号属于余弦导数,而不是正弦导数。
5 d d x ( x 2 + 1 ) 10 \dfrac{d}{dx}(x^2 + 1)^{10} d x d ( x 2 + 1 ) 10 等于
10 ( x 2 + 1 ) 9 10(x^2 + 1)^9 10 ( x 2 + 1 ) 9 20 x ( x 2 + 1 ) 9 20x(x^2 + 1)^9 20 x ( x 2 + 1 ) 9 10 ( 2 x ) 9 10(2x)^9 10 ( 2 x ) 9 20 x ( x 2 + 1 ) 10 20x(x^2 + 1)^{10} 20 x ( x 2 + 1 ) 10 链式法则:
10 ( x 2 + 1 ) 9 ⋅ 2 x 。 10(x^2 + 1)^9\cdot 2x\mathclose{\text{。}} 10 ( x 2 + 1 ) 9 ⋅ 2 x 。 10 ( x 2 + 1 ) 9 10(x^2 + 1)^9 10 ( x 2 + 1 ) 9 忘记了内函数导数
2 x ; 2x\mathclose{\text{;}} 2 x ; 10 ( 2 x ) 9 10(2x)^9 10 ( 2 x ) 9 在幂内求导; 指数必须降到 9。
6 假设
g ( 1 ) = 2 , g(1) = 2\mathclose{\text{,}} g ( 1 ) = 2 , g ′ ( 1 ) = 3 , g'(1) = 3\mathclose{\text{,}} g ′ ( 1 ) = 3 , f ′ ( 1 ) = 7 f'(1) = 7 f ′ ( 1 ) = 7 和
f ′ ( 2 ) = 5 。 f'(2) = 5\mathclose{\text{。}} f ′ ( 2 ) = 5 。 f ( g ( x ) ) f\big(g(x)\big) f ( g ( x ) ) 在
x = 1 x = 1 x = 1 处的导数是
15 15 15 21 21 21 10 10 10 5 5 5 f ′ ( g ( 1 ) ) g ′ ( 1 ) = f ′ ( 2 ) ⋅ 3 = 15 . f'\big(g(1)\big)\,g'(1) = f'(2)\cdot 3 = 15\mathclose{\text{.}} f ′ ( g ( 1 ) ) g ′ ( 1 ) = f ′ ( 2 ) ⋅ 3 = 15 . 21 在 1 处计算
f ′ f' f ′ 而不是在
g ( 1 ) = 2 ; g(1) = 2\mathclose{\text{;}} g ( 1 ) = 2 ; 10 乘以
g ( 1 ) g(1) g ( 1 ) 而不是
g ′ ( 1 ) ; g'(1)\mathclose{\text{;}} g ′ ( 1 ) ; 5 忘记了内层导数。
7 SymPy 打印 tan(x)**2 + 1 对应 sp.diff(sp.tan(x), x)。哪一个是正确的?
SymPy 错误:导数是 sec 2 x \sec^2 x sec 2 x 它仅在 x = 0 x = 0 x = 0 处等于 sec 2 x \sec^2 x sec 2 x 它仅在小的 x x x 时等于 sec 2 x \sec^2 x sec 2 x 它在 cos x ≠ 0 \cos x \ne 0 cos x = 0 处等于 sec 2 x \sec^2 x sec 2 x 将
sin 2 x + cos 2 x = 1 \sin^2 x + \cos^2 x = 1 sin 2 x + cos 2 x = 1 除以
cos 2 x \cos^2 x cos 2 x 得到
tan 2 x + 1 = sec 2 x , \tan^2 x + 1 = \sec^2 x\mathclose{\text{,}} tan 2 x + 1 = sec 2 x , 对于每个
x x x 满足
cos x ≠ 0 : \cos x \ne 0\mathclose{\text{:}} cos x = 0 : 两种写法表示同一个函数。简化两种形式的差值得到 0。
8 用
ε 2 = 0 , \varepsilon^2 = 0\mathclose{\text{,}} ε 2 = 0 , 将
f ( x ) = x 2 + 3 x f(x) = x^2 + 3x f ( x ) = x 2 + 3 x 在
2 + ε 2 + \varepsilon 2 + ε 处计算得到
10 + 4 ε 10 + 4\varepsilon 10 + 4 ε 10 + ε 10 + \varepsilon 10 + ε 10 + 7 ε 10 + 7\varepsilon 10 + 7 ε 10 + 7 ε + ε 2 10 + 7\varepsilon + \varepsilon^2 10 + 7 ε + ε 2 ( 2 + ε ) 2 + 3 ( 2 + ε ) = 4 + 4 ε + 6 + 3 ε = 10 + 7 ε : (2 + \varepsilon)^2 + 3(2 + \varepsilon) = 4 + 4\varepsilon + 6 + 3\varepsilon = 10 + 7\varepsilon\mathclose{\text{:}} ( 2 + ε ) 2 + 3 ( 2 + ε ) = 4 + 4 ε + 6 + 3 ε = 10 + 7 ε : 值为
f ( 2 ) = 10 , f(2) = 10\mathclose{\text{,}} f ( 2 ) = 10 , 导数为
f ′ ( 2 ) = 2 ⋅ 2 + 3 = 7 。 f'(2) = 2\cdot 2 + 3 = 7\mathclose{\text{。}} f ′ ( 2 ) = 2 ⋅ 2 + 3 = 7 。 10 + 4 ε 10 + 4\varepsilon 10 + 4 ε 忘记了
ε \varepsilon ε 来自
3 x ; 3x\mathclose{\text{;}} 3 x ; 10 + ε 10 + \varepsilon 10 + ε 是
f ( 2 ) + ε , f(2) + \varepsilon\mathclose{\text{,}} f ( 2 ) + ε , 如同输入的变化未改变地传递到输出;
ε 2 \varepsilon^2 ε 2 由定义为 0。
重新作答