explicit_formula_demo
system:sage


{{{id=2|
import sage.libs.mpmath.all as mpmath
PREC = 53
RF = RealField(PREC)
PI = RF(pi)
///
}}}

{{{id=1|
digammaR = lambda x: (real_part(psi(x/2)/2 - log(PI)/2)).n()
///
}}}

{{{id=9|
def hh(x):
    return ((sin(x/2)/(x/2))^2).n()
///
}}}

{{{id=15|
def hh_delta(x,delta):
    return hh(x/delta)/delta
///
}}}

{{{id=10|
def gg(x):
    if abs(x) > 1:
        return 0
    else:
        return (1-abs(x)).n()
///
}}}

{{{id=16|
def gg_delta(x,delta):
    return gg(delta*x)
///
}}}

{{{id=4|
def digamterm(h, delta, mu_list, step, int_lim):
    return ((step*(sum([digammaR(1/2+x*I+mu)*h(x,delta) for mu in mu_list for x in srange(-int_lim+step/2,int_lim, step)])))/pi).n()
///
}}}

{{{id=6|
def coeffterm(gg, delta):
    return -2*sum([c[n]*gg(log(n),delta)/sqrt(n,prec=53) for n in c.keys()])
///
}}}

{{{id=17|
def rhs(hh, gg, delta, lev):
    return gg(0,delta)*log(lev).n() + digamterm(hh,delta,[.5,1.5],.1,300)+coeffterm(gg,delta)
///
}}}

{{{id=24|
c = {}
c[2] = -2*log(2).n()
///
}}}

{{{id=31|
rhs(hh_delta,gg_delta,1,5)
///
-0.167394895164802
}}}

{{{id=18|
rhs(hh_delta,gg_delta,1,6)
///
0.0149266616291525
}}}

{{{id=25|
#I've eliminated up to level 5
///
}}}

{{{id=26|
def sinc(x):
    return (sin(pi*x)/pi/x).n()

#def mestre(x,delta):
#    return (sinc(x-.5)^2/2 + sin(x+.5)^2/2+(sinc(x+.5)*sin(pi*(x+.5))-sinc(x-.5)*sin(pi*(x-.5)))/pi).n()
    
def mestre(t,delta):
    return (2*exp(-I*t)*(1+e^(I*t))^2*pi^2/(pi^2-t^2)^2).n()
    
def mestre_hat(t,delta):
    if abs(t) > 1:
        return 0
    else:
        return ((1-abs(t))*cos(pi*t)+sin(pi*abs(t))/pi).n()
///
}}}

{{{id=28|
rhs(mestre,mestre_hat,1,8)
///
-0.0751214148042171 - 1.03213436501751e-16*I
}}}

{{{id=29|
rhs(mestre,mestre_hat,1,9)
///
0.0426616208521667 - 1.03213436501751e-16*I
}}}

{{{id=30|
#I've eliminated up to 8, the imaginary part is from rounding and is really zero
///
}}}