Skip to content

Commit

Permalink
Merge pull request #44 from wellington36/dev
Browse files Browse the repository at this point in the history
v2.1.1
  • Loading branch information
wellington36 authored Nov 14, 2023
2 parents c7bcd81 + 41a9963 commit 991d38e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ print(f"With acceleration: {accelerated[-1]}, with {n1} iterations")
Out:
```
True value: 1.6449340668482264
Without acceleration: 1.6449330668607708753650232828, with 1000012 iterations
With acceleration: 1.6449340611256049164589309217, with 22896 iterations
Without acceleration: 1.6449330668487264267523920296, with 1000000 iterations
With acceleration: 1.6449340611255960068665838135, with 22896 iterations
```

### acelsum
Expand Down
10 changes: 5 additions & 5 deletions extrapolation/esum.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def Levin_v_transform(items: list, lib='mpmath'):


###### summation with extrapolation ######
def acelsum(series, transform: str, n: int, logarithm=True, precision=53):
def acelsum(series, transform: str, n: int, logarithm=False, precision=53):
"""Evaluates partial sums up to n terms using a given transformation.
Args:
Expand Down 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, 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 991d38e

Please sign in to comment.