美文网首页
使用matplotlib画图查看极值

使用matplotlib画图查看极值

作者: 小神david | 来源:发表于2017-08-10 11:37 被阅读0次

求函数y=x^x的极值,通过求解二阶导数为
(1)求导数f'(x);
(2)求方程f'(x)=0的根;
(3)检查f'(x)在方程的左右的值的符号,如果左正右负,那么f(x)在这个根处取得极大值;如果左负右正那么f(x)在这个根处取得极小值。

通过上述方法的到极值点是1/e。

import matplotlib.pyplot as plt
import numpy as np

ext_point = 1/np.exp(1)

x = np.linspace(0.367, 0.369, 101)
plt.plot(x, x**x,'b')
plt.plot(ext_point, ext_point**ext_point, 'ro')
plt.show()
Paste_Image.png

相关文章

网友评论

      本文标题:使用matplotlib画图查看极值

      本文链接:https://www.haomeiwen.com/subject/wcqhrxtx.html