Skip to content

Instantly share code, notes, and snippets.

@nobonobo
Last active November 28, 2015 06:05
Show Gist options
  • Select an option

  • Save nobonobo/c2b1b415f7585f0f93dd to your computer and use it in GitHub Desktop.

Select an option

Save nobonobo/c2b1b415f7585f0f93dd to your computer and use it in GitHub Desktop.
sympyで矩形波関数をフーリエ級数展開
from sympy import *
# fourier 5回級数展開
l = [-mpmath.pi, mpmath.pi]
f0 = lambda x:sign(sin(x))
cs = mpmath.fourier(f0, l, 5)
f1 = lambda x: mpmath.fourierval(cs, l, x)
mpmath.plot([f0, f1], xlim=l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment