Skip to content

Instantly share code, notes, and snippets.

@d-demirci
Created May 14, 2019 20:06
Show Gist options
  • Save d-demirci/375da08c82e2ea1abf34f1da2641c8c4 to your computer and use it in GitHub Desktop.
Save d-demirci/375da08c82e2ea1abf34f1da2641c8c4 to your computer and use it in GitHub Desktop.
fourrier series sine waves to make square wave
from sys import platform as sys_pf
if sys_pf == 'darwin':
import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import numpy as np
x = np.arange(-np.pi,np.pi,0.01)
sin_cumulative = 0
for i in range(1,400,2):
sin_cumulative += np.sin(i*x) / (i)
plt.plot(x,sin_cumulative)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment