Git Product home page Git Product logo

wynnepsilon's Introduction

Contact

Patrick Lohr: [email protected]

Implementation of Wynn's Epsilon Method For Convergence Acceleration

For most convergent series, the rate of convergence can be accelerated by applying the Shanks Transformation, which approximates the limit of a sequence in a non-linear fashion. That is, for a series of the form:

The Shanks Transformation is defined as:

Where Ap are the pth partial sums of the sequence, and ΔAp = Ap+1 - Ap. This gives a method to solve for the kth-order Shank's Transformation. Peter Wynn introduced an efficient algorithm for computing the kth Shanks Transformation of a partial sum and is given by the following:

Here, each ε2k is the equivalent of applying the kth Shanks Transformation to the nth partial sum Sn. ε0 is defined as Sn, and the primary diagonal gives the next approximation. For this example, take the Gregory-Leibniz series for calculating π:

This series will eventually converge to π, but it will take billions of terms to get even a decent a approximation! Just take a look at http://www.eveandersson.com/pi/gregory-leibniz. After 1000 terms, the series is only accurate to 2 decimal places. Even after 109 iterations, the approximation only reaches 8 decimals of precision.

wynnpi.py takes an integer argument N and implements Wynn's epsilon method to find a highly precise approximation for π after N terms of the Gregory-Leibniz series. Make sure to include NumPy.

Expected Behavior

(biosystems-analytics) Patricks-MacBook-Pro:14-open patricklohr$ ./wynnpi.py -h
usage: wynnpi.py [-h] [-n INT]

Wynn Epsilon for Gregory-Leibniz series

optional arguments:
  -h, --help            show this help message and exit
  -n INT, --numterms INT
                        Number of series terms (1<=n<=22) (default: 10)
(biosystems-analytics) Patricks-MacBook-Pro:14-open patricklohr$ 
(biosystems-analytics) dhcp-10-142-223-217:14-open patricklohr$ ./wynnpi.py -n 22

Series approximation for π (22 terms):      3.096161526463642
Wynn Epsilon accelerated result (22 terms): 3.141592653589795
Actual Value:                               3.141592653589793
Relative Error:                              7.067899292141149e-16

(biosystems-analytics) dhcp-10-142-223-217:14-open patricklohr$ 

Test Suite

(biosystems-analytics) Patricks-MacBook-Pro:14-open patricklohr$ make test
pytest -v test.py
============================ test session starts ============================
platform darwin -- Python 3.7.2, pytest-4.3.1, py-1.8.0, pluggy-0.9.0 -- /Users/patricklohr/
anaconda3/envs/biosystems-analytics/bin/python
cachedir: .pytest_cache
rootdir: /Users/patricklohr/Documents/Repo/biosys-analytics/assignments/14-open, inifile:
collected 3 items                                                           

test.py::test_usage PASSED                                            [ 33%]
test.py::test_bad_input PASSED                                        [ 66%]
test.py::test_good_input PASSED                                       [100%]

========================= 3 passed in 0.59 seconds ==========================
(biosystems-analytics) Patricks-MacBook-Pro:14-open patricklohr$ 

wynnepsilon's People

Contributors

pjlohr avatar

Stargazers

 avatar  avatar  avatar  avatar

Forkers

kigochen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.