## "Fossies" - the Fresh Open Source Software Archive

### Source code changes of the file "mpmath/calculus/extrapolation.py" betweenmpmath-0.18.tar.gz and mpmath-0.19.tar.gz

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

extrapolation.py  (mpmath-0.18):extrapolation.py  (mpmath-0.19)
skipping to change at line 80 skipping to change at line 80
>>> v >>> v
3.14159265468624052829954206226 3.14159265468624052829954206226
>>> nprint([v-pi, c]) >>> nprint([v-pi, c])
[1.09645e-9, 20833.3] [1.09645e-9, 20833.3]
**References** **References**
1. [BenderOrszag]_ pp. 375-376 1. [BenderOrszag]_ pp. 375-376
""" """
len(seq) if len(seq) < 3:
raise ValueError("seq should be of minimum length 3")
if ctx.sign(seq[-1]-seq[-2]) != ctx.sign(seq[-2]-seq[-3]): if ctx.sign(seq[-1]-seq[-2]) != ctx.sign(seq[-2]-seq[-3]):
seq = seq[::2] seq = seq[::2]
N = len(seq)//2-1 N = len(seq)//2-1
s = ctx.zero s = ctx.zero
# The general weight is c[k] = (N+k)**N * (-1)**(k+N) / k! / (N-k)! # The general weight is c[k] = (N+k)**N * (-1)**(k+N) / k! / (N-k)!
# To avoid repeated factorials, we simplify the quotient # To avoid repeated factorials, we simplify the quotient
# of successive weights to obtain a recurrence relation # of successive weights to obtain a recurrence relation
c = (-1)**N * N**N / ctx.mpf(ctx._ifac(N)) c = (-1)**N * N**N / ctx.mpf(ctx._ifac(N))
maxc = 1 maxc = 1
for k in xrange(N+1): for k in xrange(N+1):
skipping to change at line 226 skipping to change at line 227
[4.0] [4.0]
[8.0, 1.0] [8.0, 1.0]
**References** **References**
1. [GravesMorris]_ 1. [GravesMorris]_
2. [BenderOrszag]_ pp. 368-375 2. [BenderOrszag]_ pp. 368-375
""" """
len(seq) if len(seq) < 2:
raise ValueError("seq should be of minimum length 2")
if table: if table:
START = len(table) START = len(table)
else: else:
START = 0 START = 0
table = [] table = []
STOP = len(seq) - 1 STOP = len(seq) - 1
if STOP & 1: if STOP & 1:
STOP -= 1 STOP -= 1
one = ctx.one one = ctx.one
eps = +ctx.eps eps = +ctx.eps
skipping to change at line 940 skipping to change at line 942
>>> chop(sumap(lambda k: z**k / k**n, [1,inf], integral=I)) >>> chop(sumap(lambda k: z**k / k**n, [1,inf], integral=I))
-0.6917036036904594510141448 -0.6917036036904594510141448
>>> polylog(n,z) >>> polylog(n,z)
-0.6917036036904594510141448 -0.6917036036904594510141448
""" """
prec = ctx.prec prec = ctx.prec
try: try:
ctx.prec += 10 ctx.prec += 10
a, b = interval a, b = interval
b if b != ctx.inf:
raise ValueError("b should be equal to ctx.inf")
g = lambda x: f(x+a) g = lambda x: f(x+a)
if integral is None: if integral is None:
i1, err1 = ctx.quad(g, [0,ctx.inf], error=True) i1, err1 = ctx.quad(g, [0,ctx.inf], error=True)
else: else:
i1, err1 = integral, 0 i1, err1 = integral, 0
j = ctx.j j = ctx.j
p = ctx.pi * 2 p = ctx.pi * 2
if ctx._is_real_type(i1): if ctx._is_real_type(i1):
h = lambda t: -2 * ctx.im(g(j*t)) / ctx.expm1(p*t) h = lambda t: -2 * ctx.im(g(j*t)) / ctx.expm1(p*t)
else: else:
End of changes. 3 change blocks.
3 lines changed or deleted 6 lines changed or added