"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/functions/functions.py" between
mpmath-1.0.0.tar.gz and mpmath-1.1.0.tar.gz

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

functions.py  (mpmath-1.0.0):functions.py  (mpmath-1.1.0)
skipping to change at line 182 skipping to change at line 182
def expm1(ctx, x): def expm1(ctx, x):
if not x: if not x:
return ctx.zero return ctx.zero
# exp(x) - 1 ~ x # exp(x) - 1 ~ x
if ctx.mag(x) < -ctx.prec: if ctx.mag(x) < -ctx.prec:
return x + 0.5*x**2 return x + 0.5*x**2
# TODO: accurately eval the smaller of the real/imag parts # TODO: accurately eval the smaller of the real/imag parts
return ctx.sum_accurately(lambda: iter([ctx.exp(x),-1]),1) return ctx.sum_accurately(lambda: iter([ctx.exp(x),-1]),1)
@defun_wrapped @defun_wrapped
def log1p(ctx, x):
if not x:
return ctx.zero
if ctx.mag(x) < -ctx.prec:
return x - 0.5*x**2
return ctx.log(ctx.fadd(1, x, prec=2*ctx.prec))
@defun_wrapped
def powm1(ctx, x, y): def powm1(ctx, x, y):
mag = ctx.mag mag = ctx.mag
one = ctx.one one = ctx.one
w = x**y - one w = x**y - one
M = mag(w) M = mag(w)
# Only moderate cancellation # Only moderate cancellation
if M > -8: if M > -8:
return w return w
# Check for the only possible exact cases # Check for the only possible exact cases
if not w: if not w:
 End of changes. 1 change blocks. 
0 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)