
上QQ阅读APP看书,第一时间看更新
2-3-2 微分定理
上述程序中的fd()函数为一阶导数,它们是如何求得的?只要运用以下微分的定理,就可以轻易解出上述范例的一阶导数,相关定理整理如下。
(1)f( x)一阶导数的表示法为f′(x)或。
(2)f( x)为常数(C)→f′(x)=0。
(3)f( x)=Cg( x)→f′(x)=Cg′( x)。
(4)f( x)=g( x)+h( x)→f′(x)=g′( x)+h′( x)。
(5)次方的规则:f( x)=xn →f′(x)=nxn−1。
(6)乘积的规则:。
(7)商的规则:若r( x)=s( x)/t( x),则。
(8)链式法则(Chain Rule):

以上一节范例(2)f(x)=−10x2 +100x+5为例,针对多项式的每一项个别微分再相加,就得到f(x)的一阶导数为
f′(x)= -20 x + 100
SymPy库直接支持微积分函数的计算,可以验证定理,接下来我们就写一些程序来练习一下。
以下程序请参考02_04_微分.ipynb。
(1)f(x)为常数。程序代码如下:

执行结果:0。
(2)。程序代码如下:

执行结果均为10x。
(3)乘积的规则:。程序代码如下:

执行结果:5x4。
(4)链式法则:。程序代码如下:

执行结果:6x5。
(5)验证f(x)=−10x2 +100x+5。程序代码如下:

执行结果:100 -20x。
接着,利用一阶导数等于0,求最大值。程序代码如下:

执行结果:x=5时,最大值为255。
(6)验证f(x)= x2+2x+7。程序代码如下:

执行结果:2x + 2。
接着,利用一阶导数等于0,求最小值。程序代码如下:

执行结果:x=-1时,最小值为6。