锯齿波和三角波
三角波是对锯齿波取绝对值得到的
锯齿波的无穷级数展开:
Code
import numpy as np import matplotlib.pyplot as plt t = np.linspace(-np.pi, np.pi, 201) k = np.arange(1, 99) f = np.zeros_like(t) for i in range(len(t)): f[i] = np.sum(np.sin(2 * np.pi * k * t[i])/k) f = (-2 / np.pi) * f plt.plot(t, f, lw=1.0) plt.plot(t, np.abs(f), lw=2.0) plt.show()