"Fossies" - the Fresh Open Source Software Archive

Source code changes of the file "mpmath/functions/rszeta.py" betweenmpmath-0.19.tar.gz and mpmath-1.0.0.tar.gz

About: mpmath is a Python library for arbitrary-precision floating-point arithmetic.

rszeta.py  (mpmath-0.19):rszeta.py  (mpmath-1.0.0)
skipping to change at line 54 skipping to change at line 54
The precision is limited, roughly it can compute zeta(sigma+it) The precision is limited, roughly it can compute zeta(sigma+it)
with an error less than exp(-c t) for some constant c depending with an error less than exp(-c t) for some constant c depending
on sigma. The program gives an error when the Riemann-Siegel on sigma. The program gives an error when the Riemann-Siegel
formula can not compute to the wanted precision. formula can not compute to the wanted precision.
""" """
import math import math
class RSCache(object): class RSCache(object):
def __init__(ctx): def __init__(ctx):
ctx._rs_cache = [0, 10, {}, {}] ctx._rs_cache = [0, 10, {}, {}]
from .functions import defun from .functions import defun
#------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- #
# # # #
# coef(ctx, J, eps, _cache=[0, 10, {} ] ) # # coef(ctx, J, eps, _cache=[0, 10, {} ] ) #
# # # #
#------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- #
skipping to change at line 108 skipping to change at line 108
\begin{multline} \begin{multline}
c_{2n}=-\frac{i}{\sqrt{2}}\Bigl(\frac{\pi}{2}\Bigr)^{2n} c_{2n}=-\frac{i}{\sqrt{2}}\Bigl(\frac{\pi}{2}\Bigr)^{2n}
\sum_{k=0}^n\frac{(-1)^k}{(2k)!} \sum_{k=0}^n\frac{(-1)^k}{(2k)!}
2^{2n-2k}\frac{(-1)^{n-k}E_{2n-2k}}{(2n-2k)!}+\\ 2^{2n-2k}\frac{(-1)^{n-k}E_{2n-2k}}{(2n-2k)!}+\\
+e^{3\pi i/8}\sum_{j=0}^n(-1)^j\frac{ +e^{3\pi i/8}\sum_{j=0}^n(-1)^j\frac{
E_{2j}}{(2j)!}\frac{i^{n-j}\pi^{n+j}}{(n-j)!2^{n-j+1}}. E_{2j}}{(2j)!}\frac{i^{n-j}\pi^{n+j}}{(n-j)!2^{n-j+1}}.
\end{multline} \end{multline}
""" """
newJ = J+2 # compute more coefficients that are needed newJ = J+2 # compute more coefficients that are needed
neweps6 = eps/2. # compute with a slight more precision neweps6 = eps/2. # compute with a slight more precision that are needed
that are needed
# PREPARATION FOR THE COMPUTATION OF V(N) AND W(N) # PREPARATION FOR THE COMPUTATION OF V(N) AND W(N)
# See II Section 3.16 # See II Section 3.16
# #
# Computing the exponent wpvw of the error II equation (81) # Computing the exponent wpvw of the error II equation (81)
wpvw = max(ctx.mag(10*(newJ+3)), 4*newJ+5-ctx.mag(neweps6)) wpvw = max(ctx.mag(10*(newJ+3)), 4*newJ+5-ctx.mag(neweps6))
# Preparation of Euler numbers (we need until the 2*RS_NEWJ) # Preparation of Euler numbers (we need until the 2*RS_NEWJ)
E = ctx._eulernum(2*newJ) E = ctx._eulernum(2*newJ)
skipping to change at line 415 skipping to change at line 414
# cache. The bulk of the computation is passed to # cache. The bulk of the computation is passed to
# the function coef() # the function coef()
# #
# eps6 is defined in II Section 3.13 equation (58) # eps6 is defined in II Section 3.13 equation (58)
eps6 = ctx.power(ctx.convert(2*ctx.pi), J)/(ctx.gamma(J+1)*3*J) eps6 = ctx.power(ctx.convert(2*ctx.pi), J)/(ctx.gamma(J+1)*3*J)
# Now we compute the coefficients # Now we compute the coefficients
cc = {} cc = {}
cont = {} cont = {}
cont, pipowers = coef(ctx, J, eps6) cont, pipowers = coef(ctx, J, eps6)
cc=cont.copy() # we need a copy since we have cc=cont.copy() # we need a copy since we have to change his values.
to change his values. Fp={} # this is the adequate locus of this
Fp={} # this is the adequate locus of this
for n in range(M, 3*L-2): for n in range(M, 3*L-2):
Fp[n] = 0 Fp[n] = 0
Fp={} Fp={}
ctx.prec = wpfp ctx.prec = wpfp
for m in range(0,M+1): for m in range(0,M+1):
sumP = 0 sumP = 0
for k in range(2*J-m-1,-1,-1): for k in range(2*J-m-1,-1,-1):
sumP = (sumP * p)+ cc[k] sumP = (sumP * p)+ cc[k]
Fp[m] = sumP Fp[m] = sumP
# preparation of the new coefficients # preparation of the new coefficients
skipping to change at line 563 skipping to change at line 561
for ell in range(-2,3*k//2+1): for ell in range(-2,3*k//2+1):
xfortcoef[mu,k,ell]=0 xfortcoef[mu,k,ell]=0
for mu in range(0,der+1): for mu in range(0,der+1):
for k in range(0,L): for k in range(0,L):
ctx.prec = xwptcoef[k] ctx.prec = xwptcoef[k]
for ell in range(0,3*k//2+1): for ell in range(0,3*k//2+1):
xfortcoef[mu,k,ell]=xd[mu,k,ell]*Fp[3*k-2*ell]/pipowers[2*k-ell] xfortcoef[mu,k,ell]=xd[mu,k,ell]*Fp[3*k-2*ell]/pipowers[2*k-ell]
xfortcoef[mu,k,ell]=xfortcoef[mu,k,ell]/((2*ctx.j)**ell) xfortcoef[mu,k,ell]=xfortcoef[mu,k,ell]/((2*ctx.j)**ell)
def trunc_a(t): def trunc_a(t):
wp = ctx.prec wp = ctx.prec
ctx.prec = wp + 2 ctx.prec = wp + 2
aa = ctx.sqrt(t/(2*ctx.pi)) aa = ctx.sqrt(t/(2*ctx.pi))
ctx.prec = wp ctx.prec = wp
return aa return aa
# computing the tcoef[k,ell] # computing the tcoef[k,ell]
xtcoef={} xtcoef={}
for mu in range(0,der+1): for mu in range(0,der+1):
for k in range(0,L): for k in range(0,L):
for ell in range(-2,3*k//2+1): for ell in range(-2,3*k//2+1):
xtcoef[mu,k,ell]=0 xtcoef[mu,k,ell]=0
ctx.prec = max(xwptcoef[0],ywptcoef[0])+3 ctx.prec = max(xwptcoef[0],ywptcoef[0])+3
aa= trunc_a(t) aa= trunc_a(t)
la = -ctx.ln(aa) la = -ctx.ln(aa)
skipping to change at line 1015 skipping to change at line 1013
fortcoef[mu,k,ell]=0 fortcoef[mu,k,ell]=0
for mu in derivatives: for mu in derivatives:
for k in range(0,L): for k in range(0,L):
ctx.prec = wptcoef[k] ctx.prec = wptcoef[k]
for ell in range(0,3*k//2+1): for ell in range(0,3*k//2+1):
fortcoef[mu,k,ell]=d[mu,k,ell]*Fp[3*k-2*ell]/pipowers[2*k-ell] fortcoef[mu,k,ell]=d[mu,k,ell]*Fp[3*k-2*ell]/pipowers[2*k-ell]
fortcoef[mu,k,ell]=fortcoef[mu,k,ell]/((2*ctx.j)**ell) fortcoef[mu,k,ell]=fortcoef[mu,k,ell]/((2*ctx.j)**ell)
def trunc_a(t): def trunc_a(t):
wp = ctx.prec wp = ctx.prec
ctx.prec = wp + 2 ctx.prec = wp + 2
aa = ctx.sqrt(t/(2*ctx.pi)) aa = ctx.sqrt(t/(2*ctx.pi))
ctx.prec = wp ctx.prec = wp
return aa return aa
# computing the tcoef[chi,k,ell] # computing the tcoef[chi,k,ell]
tcoef={} tcoef={}
for chi in derivatives: for chi in derivatives:
for k in range(0,L): for k in range(0,L):
for ell in range(-2,3*k//2+1): for ell in range(-2,3*k//2+1):
tcoef[chi,k,ell]=0 tcoef[chi,k,ell]=0
ctx.prec = wptcoef[0]+3 ctx.prec = wptcoef[0]+3
aa = trunc_a(t) aa = trunc_a(t)
la = -ctx.ln(aa) la = -ctx.ln(aa)
End of changes. 5 change blocks.
16 lines changed or deleted 14 lines changed or added