Skip to content

Instantly share code, notes, and snippets.

@TakaoNarikawa
Created June 29, 2020 20:50
Show Gist options
  • Save TakaoNarikawa/20bd8f8c26075ede6029cb07624a79b1 to your computer and use it in GitHub Desktop.
Save TakaoNarikawa/20bd8f8c26075ede6029cb07624a79b1 to your computer and use it in GitHub Desktop.
200630_report
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