Skip to content

Instantly share code, notes, and snippets.

@amarvutha
Last active December 21, 2015 15:39
Show Gist options
  • Save amarvutha/6328082 to your computer and use it in GitHub Desktop.
Save amarvutha/6328082 to your computer and use it in GitHub Desktop.
Even-valued zeta functions evaluated using Parseval's theorem
# Evaluating zeta functions using Parseval sums
# Amar
# version 1, Aug 2013
from sympy import *
from sympy import init_printing
init_printing()
n = symbols('n',integer=True)
s = symbols('s',rational=True)
t = symbols('t')
def a0(s):
# DC component of fourier series
return ((2*pi)**s)/(s+1)
def b(n,s):
return integrate(t**s * E**(I*n*t),(t,0,2*pi))/(2*pi)
def a(n,s):
# fourier components of the function t**s, defined recursively
if s!=0 and s > Rational(1,2): return (s)/(I*n) * ( a0(s-1) - a(n,s-1) )
elif s==Rational(1,2): return b(n,Rational(1,2))
else: return 0
def lhs(n,s):
# fourier side of Parseval sum. Factor of 2 is because only single-sided fourier series is considered
return apart( 2 * Abs(a(n,s))**2, n ) #,full=True )
def rhs(s):
# time side of Parseval sum
return a0(2*s) - a0(s)**2
def equation(n,s):
return lhs(n,s), rhs(s)
pprint(equation(n,1)) # gives the series sum for zeta(2)
pprint(equation(n,2)) # gives the series sum for zeta(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment