acceleration2


Nameacceleration2 JSON
Version 2.0.0 PyPI version JSON
download
home_page
SummaryAcceleration methods to real series
upload_time2023-08-04 03:49:31
maintainer
docs_urlNone
authorWellington Silva
requires_python
licenseMIT
keywords python extrapolation numerical-analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Acceleration algorithms
==================

This repository contains implementations of the following series transformations:

* [Aitken's transformation (or delta-squared process)](https://en.wikipedia.org/wiki/Aitken%27s_delta-squared_process):
  - Transform: O($n$)
  - To find n: O($2n\log n$)

* [Richardson's transformation (modify, with given p)](https://en.wikipedia.org/wiki/Richardson_extrapolation):
  - Transform: O($\log n$)
  - To find n: O($2(\log n)^2$)

* [Epsilon transformation](https://www.sciencedirect.com/science/article/pii/S0377042700003551):
  - Transform: O($n$)
  - To find n: O($2n\log n$)

* [G transformation](https://epubs.siam.org/doi/abs/10.1137/0704032?journalCode=sjnaam):
  - Transform: O($n$)
  - To find n: O($2n\log n$)

## Installation

To install the package, run the following command:

```bash
pip install acceleration
```

## Usage

In `acceleration/esum.py` we have the transformations implemented above, and for use have the `esum` and `acelsum` function.

### esum
The `esum` receives on input:

- *A series*: In the form of a function $f: \mathbb{N} \to \mathbb{R}$ returning the terms to be summed.
- *The Transformation*: "Aitken", "Richardson", "Epsilon", "G" and "None", the latter being using the initial series without any transformation.
- *The stopping criterion*: In case the difference of the last two values of the series are smaller than a given error.
- *Return in logarithm scale*: True if you want to receive the return in logarithm scale with the sign and False if you want to receive in normal scale.
- *Precision*: If precision is 53 we use the default python precision, otherwise the given bits precision.

This function determines the minimum value of n for which, the difference between the last partial sums becomes less than the specified error when applying the transformation. And returns the series applied to the transformation. The following is an example:


```python
from acceleration.esum import *

# Test with no_transform (without transformation) and with Richardson transformation the basel problem
n0, no_accelerated = esum(lambda x: 1/x**2, 'None', error=1e-12, logarithm=False, precision=100)
n1, accelerated = esum(lambda x: 1/x**2, 'Richardson', error=1e-12, logarithm=False, precision=100)

# Comparison
print(f"True value:           {math.pi ** 2 / 6}")
print(f"Without acceleration: {no_accelerated[-1]}, with {n0} iterations")
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
```

### acelsum
We have also the `acelsum` function, that receives on input:

- *A series*: In the form of a function $f: \mathbb{N} \to \mathbb{R}$ returning the terms to be summed.
- *The Transformation*: "Aitken", "Richardson", "Epsilon", "G" and "None", the latter being using the initial series without any transformation.
- *Natural n*: Number of values to be summed.
- *Return in logarithm scale*: True if you want to receive the return in logarithm scale with the sign and False if you want to receive in normal scale.
- *Precision*: If precision is 53 we use the default python precision, otherwise the given bits precision.

This function calculates partial sums up to a given natural value, returning the result in log-scale or normal by applying a chosen transformation. The following is an example:

```python
from acceleration.esum import *

# Test with no_transform (without transformation) and with Richardson transformation the basel problem
no_accelerated = acelsum(lambda x: 1/x**2, 'None', n=1000, logarithm=False, precision=100)
accelerated = esum(lambda x: 1/x**2, 'Richardson', n=1000, logarithm=False, precision=100)

# Comparison
print(f"True value:           {math.pi ** 2 / 6}")
print(f"Without acceleration: {no_accelerated[-1]}")
print(f"With acceleration:    {accelerated[-1]}")
```

Out:
```
True value:           1.6449340668482264
Without acceleration: 1.6439345666815597935850701245
With acceleration:    1.6449310678482254269248263997
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "acceleration2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,extrapolation,numerical-analysis",
    "author": "Wellington Silva",
    "author_email": "<wellington.71319@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8e/ca/3ee7805993729ee4f730bb842531fb03fe8778c6f7615baae0589a78bfdd/acceleration2-2.0.0.tar.gz",
    "platform": null,
    "description": "Acceleration algorithms\n==================\n\nThis repository contains implementations of the following series transformations:\n\n* [Aitken's transformation (or delta-squared process)](https://en.wikipedia.org/wiki/Aitken%27s_delta-squared_process):\n  - Transform: O($n$)\n  - To find n: O($2n\\log n$)\n\n* [Richardson's transformation (modify, with given p)](https://en.wikipedia.org/wiki/Richardson_extrapolation):\n  - Transform: O($\\log n$)\n  - To find n: O($2(\\log n)^2$)\n\n* [Epsilon transformation](https://www.sciencedirect.com/science/article/pii/S0377042700003551):\n  - Transform: O($n$)\n  - To find n: O($2n\\log n$)\n\n* [G transformation](https://epubs.siam.org/doi/abs/10.1137/0704032?journalCode=sjnaam):\n  - Transform: O($n$)\n  - To find n: O($2n\\log n$)\n\n## Installation\n\nTo install the package, run the following command:\n\n```bash\npip install acceleration\n```\n\n## Usage\n\nIn `acceleration/esum.py` we have the transformations implemented above, and for use have the `esum` and `acelsum` function.\n\n### esum\nThe `esum` receives on input:\n\n- *A series*: In the form of a function $f: \\mathbb{N} \\to \\mathbb{R}$ returning the terms to be summed.\n- *The Transformation*: \"Aitken\", \"Richardson\", \"Epsilon\", \"G\" and \"None\", the latter being using the initial series without any transformation.\n- *The stopping criterion*: In case the difference of the last two values of the series are smaller than a given error.\n- *Return in logarithm scale*: True if you want to receive the return in logarithm scale with the sign and False if you want to receive in normal scale.\n- *Precision*: If precision is 53 we use the default python precision, otherwise the given bits precision.\n\nThis function determines the minimum value of n for which, the difference between the last partial sums becomes less than the specified error when applying the transformation. And returns the series applied to the transformation. The following is an example:\n\n\n```python\nfrom acceleration.esum import *\n\n# Test with no_transform (without transformation) and with Richardson transformation the basel problem\nn0, no_accelerated = esum(lambda x: 1/x**2, 'None', error=1e-12, logarithm=False, precision=100)\nn1, accelerated = esum(lambda x: 1/x**2, 'Richardson', error=1e-12, logarithm=False, precision=100)\n\n# Comparison\nprint(f\"True value:           {math.pi ** 2 / 6}\")\nprint(f\"Without acceleration: {no_accelerated[-1]}, with {n0} iterations\")\nprint(f\"With acceleration:    {accelerated[-1]}, with {n1} iterations\")\n```\n\nOut:\n```\nTrue value:           1.6449340668482264\nWithout acceleration: 1.6449330668607708753650232828, with 1000012 iterations\nWith acceleration:    1.6449340611256049164589309217, with 22896 iterations\n```\n\n### acelsum\nWe have also the `acelsum` function, that receives on input:\n\n- *A series*: In the form of a function $f: \\mathbb{N} \\to \\mathbb{R}$ returning the terms to be summed.\n- *The Transformation*: \"Aitken\", \"Richardson\", \"Epsilon\", \"G\" and \"None\", the latter being using the initial series without any transformation.\n- *Natural n*: Number of values to be summed.\n- *Return in logarithm scale*: True if you want to receive the return in logarithm scale with the sign and False if you want to receive in normal scale.\n- *Precision*: If precision is 53 we use the default python precision, otherwise the given bits precision.\n\nThis function calculates partial sums up to a given natural value, returning the result in log-scale or normal by applying a chosen transformation. The following is an example:\n\n```python\nfrom acceleration.esum import *\n\n# Test with no_transform (without transformation) and with Richardson transformation the basel problem\nno_accelerated = acelsum(lambda x: 1/x**2, 'None', n=1000, logarithm=False, precision=100)\naccelerated = esum(lambda x: 1/x**2, 'Richardson', n=1000, logarithm=False, precision=100)\n\n# Comparison\nprint(f\"True value:           {math.pi ** 2 / 6}\")\nprint(f\"Without acceleration: {no_accelerated[-1]}\")\nprint(f\"With acceleration:    {accelerated[-1]}\")\n```\n\nOut:\n```\nTrue value:           1.6449340668482264\nWithout acceleration: 1.6439345666815597935850701245\nWith acceleration:    1.6449310678482254269248263997\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Acceleration methods to real series",
    "version": "2.0.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        "extrapolation",
        "numerical-analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8eca3ee7805993729ee4f730bb842531fb03fe8778c6f7615baae0589a78bfdd",
                "md5": "a46659a2163368a49b493e9ab12d18f7",
                "sha256": "d14ba4bc5da006be849a26645350c56a918c02bb1b73abc17010dea41072efa7"
            },
            "downloads": -1,
            "filename": "acceleration2-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a46659a2163368a49b493e9ab12d18f7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4941,
            "upload_time": "2023-08-04T03:49:31",
            "upload_time_iso_8601": "2023-08-04T03:49:31.265351Z",
            "url": "https://files.pythonhosted.org/packages/8e/ca/3ee7805993729ee4f730bb842531fb03fe8778c6f7615baae0589a78bfdd/acceleration2-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-04 03:49:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "acceleration2"
}
        
Elapsed time: 0.12248s