Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kohei-Toyoda/7715461e141d9f9a0a1d8e06f2501959 to your computer and use it in GitHub Desktop.
Save Kohei-Toyoda/7715461e141d9f9a0a1d8e06f2501959 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import math
time_max=8
timestep=0.005
count=240
n_max=30
result=[]
for t_ in range(time_max):
result = []
t = t_ * timestep
for x in range(count):
y=0
for n in range(1,n_max):
a = 8 * math.sin(math.pi * n / 2) / ((math.pi ** 2) * (n ** 2))
y += a*math.sin(math.pi*n*1.0/count*x)*math.exp(-1*(n*math.pi)**2*t)
result.append(y)
plt.plot(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment