Skip to content

Commit

Permalink
Fix bug in logarithm return
Browse files Browse the repository at this point in the history
  • Loading branch information
wellington36 committed Nov 14, 2023
1 parent a87f08f commit df877e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions extrapolation/esum.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,25 @@ def esum(series, transform, error=1e-5, logarithm=False, precision=53) -> tuple:
"""
n0 = 10
n = n0
acel = acelsum(series, transform, n0, True, precision)
acel = acelsum(series, transform, n0, logarithm=True, precision=precision)
i = -1 # trash

while fabs(exp(acel[-1].value()[1]) - exp(acel[-2].value()[1])) > error:
i = i + 1
n = n0 + 2**i
acel = acelsum(series, transform, n)
acel = acelsum(series, transform, n, logarithm=True, precision=precision)

n0 = n0 + 2**(i-1)

while (n > n0):
acel = acelsum(series, transform, int((n+n0)/2))
acel = acelsum(series, transform, int((n+n0)/2), logarithm=True, precision=precision)

if fabs(exp(acel[-1].value()[1]) - exp(acel[-2].value()[1])) > error:
n0 = int((n+n0)/2 + 1)
else:
n = int((n+n0)/2)

acel = acelsum(series, transform, n)
acel = acelsum(series, transform, n, logarithm=True, precision=precision)

if logarithm:
return n, acel
Expand Down

0 comments on commit df877e3

Please sign in to comment.