使用 sympy,我得到了一个函数的导数:
>>> import sympy as sp
>>> x = sp.Symbol('x')
>>> f = -0.01 * sp.sin(0.05 * x - 0.7) + 0.01 * sp.sin(6.2 * x + 4.5)
>>> f.diff(x)
−0.0005cos(0.05𝑥−0.7)+0.062cos(6.2𝑥+4.5)
我构建了一个函数及其导数的图表:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(100)
plt.plot(x, -0.01 * np.sin(0.05 * x - 0.7) + 0.01 * np.sin(6.2 * x + 4.5), 'b-')
plt.twinx()
plt.plot(x, -0.0005 * np.cos(0.05 * x - 0.7) + 0.062 * np.cos(6.2 * x + 4.5), 'g-')
plt.plot(plt.xlim(), [0, 0], 'k--')
plt.show()
导数为零的地方似乎不是极值。我不明白为什么。

您已经捕捉到 x 中所选点集的正弦函数的“干扰”。您的点间距为 1。函数的周期为 6.2/(2*pi) = 0.98676...
对于正确的显示点,对于函数的每个周期,x 中有几个点是必要的。例如,如果我们将点的频率增加 100 倍:
x = np.arange(100*100) *(1./100),我们得到: