Created
June 29, 2020 20:50
-
-
Save TakaoNarikawa/20bd8f8c26075ede6029cb07624a79b1 to your computer and use it in GitHub Desktop.
200630_report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def x(n): | |
return (1 - np.cos(n * np.pi)) / ((np.pi * n)** 2) if n != 0 else 0.5 | |
def y(n): | |
return x(n // 2) if n % 2 == 0 else 0 | |
def Xd(w, N=1000): | |
return sum([np.exp(-w * n * 1j) * x(n) for n in range(-N, N)]) | |
def Yd(w, N=1000): | |
return sum([np.exp(-w / 2 * n * 1j) * y(n) for n in range(-N, N)]) | |
W = np.linspace(-np.pi, np.pi, 10000) | |
xd = Xd(W) | |
yd = Yd(W) | |
fig, ax = plt.subplots(2, 2, figsize=(10, 6)) | |
ax[0, 0].plot(W, xd.real) | |
ax[0, 0].set_title("Xd re") | |
ax[0, 1].plot(W, yd.real) | |
ax[0, 1].set_title("Yd re") | |
ax[1, 0].plot(W, xd.imag) | |
ax[1, 0].set_title("Xd im") | |
ax[1, 1].plot(W, yd.imag) | |
ax[1, 1].set_title("Yd im") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment