# pynumint: A Numerical Integration Library
![ml drop (11)](https://github.com/ArjunJagdale/pynumint/assets/142811259/c7a8c892-5553-4059-9ad9-dd8e38c5fda6)
pynumint is a Python library for numerical integration methods.
pynumint offers a wide range of numerical integration methods, including trapezoidal rule, Simpson's rule, midpoint rule, Boole's rule, Romberg integration, Gauss-Legendre quadrature, Gauss-Chebyshev quadrature, Gauss-Laguerre quadrature, Gauss-Hermite quadrature, adaptive Simpson's rule, Monte Carlo integration, and double integrals. Users can choose the most suitable method based on the characteristics of the function and the desired level of accuracy.
[Link to PyPi](https://pypi.org/project/pynumint/)
## Installation
```bash
pip install pynumint
```
## Usage
```bash
from pynumint import trapezoidal_rule, simpsons_rule, midpoint_rule, booles_rule, romberg_integration, gauss_legendre_quadrature, gauss_chebyshev_quadrature, gauss_laguerre_quadrature, gauss_hermite_quadrature, adaptive_simpsons_rule, monte_carlo_integration, double_integral, simpsons_rule_with_error
import numpy as np
# Define your functions to be integrated
def f1(x):
return x**2
def f2(x):
return np.sin(x)
def f3(x):
return np.exp(-x**2)
def f4(x, y):
return x * y
# Define integration limits and number of intervals
a = 0
b = 10
n = 1000
```
### [Trapezoidal Rule](https://en.wikipedia.org/wiki/Trapezoidal_rule)
```bash
result_trapezoidal = trapezoidal_rule(f1, a, b, n)
```
### [Simpson's Rule](https://en.wikipedia.org/wiki/Simpson%27s_rule)
```bash
result_simpsons = simpsons_rule(f2, a, b, n)
```
### [Midpoint Rule](https://en.wikipedia.org/wiki/Riemann_sum)
```bash
result_midpoint = midpoint_rule(f3, a, b, n)
```
### [Boole's Rule](https://en.wikipedia.org/wiki/Boole%27s_rule)
```bash
result_booles = booles_rule(f1, a, b, n)
```
### [Romberg Integration](https://en.wikipedia.org/wiki/Romberg%27s_method)
```bash
result_romberg = romberg_integration(f2, a, b)
```
### [Gauss-Legendre Quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_quadrature)
```bash
result_gauss_legendre = gauss_legendre_quadrature(f3, a, b, 5)
```
### [Gauss-Chebyshev Quadrature](https://en.wikipedia.org/wiki/Chebyshev%E2%80%93Gauss_quadrature)
```bash
result_gauss_chebyshev = gauss_chebyshev_quadrature(f3, 5)
```
### [Gauss-Laguerre Quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature)
```bash
result_gauss_laguerre = gauss_laguerre_quadrature(f3, 5)
```
### [Gauss-Hermite Quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Hermite_quadrature)
```bash
result_gauss_hermite = gauss_hermite_quadrature(f3, 5)
```
### [Adaptive Simpson's Rule](https://en.wikipedia.org/wiki/Adaptive_Simpson%27s_method)
```bash
result_adaptive_simpsons = adaptive_simpsons_rule(f3, a, b, 1e-6)
```
### [Monte Carlo Integration](https://en.wikipedia.org/wiki/Monte_Carlo_integration)
```bash
result_monte_carlo = monte_carlo_integration(f3, a, b)
```
### [Double Integrals](https://en.wikipedia.org/wiki/Multiple_integral)
```bash
result_double_integral = double_integral(f4, 0, 1, 0, 1)
```
### [Simpson's rule with error](https://en.wikipedia.org/wiki/Simpson%27s_rule)
```bash
result_simpsons_error, error_estimate = simpsons_rule_with_error(f2, a, b, n)
```
## Print results
```bash
print("Results:")
print(f"Trapezoidal Rule: {result_trapezoidal}")
print(f"Simpson's Rule: {result_simpsons}")
print(f"Midpoint Rule: {result_midpoint}")
print(f"Boole's Rule: {result_booles}")
print(f"Romberg Integration: {result_romberg}")
print(f"Gauss-Legendre Quadrature: {result_gauss_legendre}")
print(f"Gauss-Chebyshev Quadrature: {result_gauss_chebyshev}")
print(f"Gauss-Laguerre Quadrature: {result_gauss_laguerre}")
print(f"Gauss-Hermite Quadrature: {result_gauss_hermite}")
print(f"Adaptive Simpson's Rule: {result_adaptive_simpsons}")
print(f"Monte Carlo Integration: {result_monte_carlo}")
print(f"Double Integral: {result_double_integral}")
print(f"Double Integral: {result_double_integral}")
print(f"Simpson's Rule with Error Estimation: {result_simpsons_error} with an error estimate of {error_estimate}")
```
## Output
```bash
Results:
Trapezoidal Rule: 333.33350000000013
Simpson's Rule: 1.8390715291786217
Midpoint Rule: 0.8862269254527569
Boole's Rule: 333.3333333333334
Romberg Integration: 1.839071529076259
Gauss-Legendre Quadrature: 0.9622861833849173
Gauss-Chebyshev Quadrature: 2.026469405000093
Gauss-Laguerre Quadrature: 0.5408201719540809
Gauss-Hermite Quadrature: 1.260069748687603
Adaptive Simpson's Rule: 0.443113467730597
Monte Carlo Integration: 0.7746479690195586
Double Integral: 0.25507601265177027
Simpson's Rule with Error Estimation: 1.8390715291786217 with an error estimate of 5.555553794065748e-06
```
Raw data
{
"_id": null,
"home_page": "https://github.com/CodeSleuthX/pynumint",
"name": "pynumint",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "numerical integration mathematics science",
"author": "Arjun Jagdale",
"author_email": "arjunjagdale14@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/c5/8d/6fec3a8e3334611e8f5144e1319dd66a75adeb35664a77ffb13a9b88c87f/pynumint-0.2.3.tar.gz",
"platform": null,
"description": "# pynumint: A Numerical Integration Library\n\n![ml drop (11)](https://github.com/ArjunJagdale/pynumint/assets/142811259/c7a8c892-5553-4059-9ad9-dd8e38c5fda6)\n\npynumint is a Python library for numerical integration methods.\npynumint offers a wide range of numerical integration methods, including trapezoidal rule, Simpson's rule, midpoint rule, Boole's rule, Romberg integration, Gauss-Legendre quadrature, Gauss-Chebyshev quadrature, Gauss-Laguerre quadrature, Gauss-Hermite quadrature, adaptive Simpson's rule, Monte Carlo integration, and double integrals. Users can choose the most suitable method based on the characteristics of the function and the desired level of accuracy.\n\n[Link to PyPi](https://pypi.org/project/pynumint/)\n\n## Installation\n\n```bash\npip install pynumint\n\n```\n\n## Usage\n```bash\n\nfrom pynumint import trapezoidal_rule, simpsons_rule, midpoint_rule, booles_rule, romberg_integration, gauss_legendre_quadrature, gauss_chebyshev_quadrature, gauss_laguerre_quadrature, gauss_hermite_quadrature, adaptive_simpsons_rule, monte_carlo_integration, double_integral, simpsons_rule_with_error\nimport numpy as np\n\n# Define your functions to be integrated\ndef f1(x):\n return x**2\n\ndef f2(x):\n return np.sin(x)\n\ndef f3(x):\n return np.exp(-x**2)\n\ndef f4(x, y):\n return x * y\n\n# Define integration limits and number of intervals\na = 0\nb = 10\nn = 1000\n\n```\n### [Trapezoidal Rule](https://en.wikipedia.org/wiki/Trapezoidal_rule)\n```bash\n\nresult_trapezoidal = trapezoidal_rule(f1, a, b, n)\n\n```\n### [Simpson's Rule](https://en.wikipedia.org/wiki/Simpson%27s_rule)\n```bash\n\nresult_simpsons = simpsons_rule(f2, a, b, n)\n\n```\n### [Midpoint Rule](https://en.wikipedia.org/wiki/Riemann_sum)\n```bash\n\nresult_midpoint = midpoint_rule(f3, a, b, n)\n\n```\n### [Boole's Rule](https://en.wikipedia.org/wiki/Boole%27s_rule)\n```bash\n\nresult_booles = booles_rule(f1, a, b, n)\n\n```\n### [Romberg Integration](https://en.wikipedia.org/wiki/Romberg%27s_method)\n```bash\n\nresult_romberg = romberg_integration(f2, a, b)\n\n```\n### [Gauss-Legendre Quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_quadrature)\n```bash\n\nresult_gauss_legendre = gauss_legendre_quadrature(f3, a, b, 5)\n\n```\n### [Gauss-Chebyshev Quadrature](https://en.wikipedia.org/wiki/Chebyshev%E2%80%93Gauss_quadrature)\n```bash\n\nresult_gauss_chebyshev = gauss_chebyshev_quadrature(f3, 5)\n\n```\n### [Gauss-Laguerre Quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature)\n```bash\n\nresult_gauss_laguerre = gauss_laguerre_quadrature(f3, 5)\n\n```\n### [Gauss-Hermite Quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Hermite_quadrature)\n```bash\n\nresult_gauss_hermite = gauss_hermite_quadrature(f3, 5)\n\n```\n### [Adaptive Simpson's Rule](https://en.wikipedia.org/wiki/Adaptive_Simpson%27s_method)\n```bash\n\nresult_adaptive_simpsons = adaptive_simpsons_rule(f3, a, b, 1e-6)\n\n```\n### [Monte Carlo Integration](https://en.wikipedia.org/wiki/Monte_Carlo_integration)\n```bash\n\nresult_monte_carlo = monte_carlo_integration(f3, a, b)\n\n```\n### [Double Integrals](https://en.wikipedia.org/wiki/Multiple_integral)\n```bash\n\nresult_double_integral = double_integral(f4, 0, 1, 0, 1)\n\n```\n\n### [Simpson's rule with error](https://en.wikipedia.org/wiki/Simpson%27s_rule)\n```bash\n\nresult_simpsons_error, error_estimate = simpsons_rule_with_error(f2, a, b, n)\n\n```\n\n## Print results\n```bash\n\nprint(\"Results:\")\nprint(f\"Trapezoidal Rule: {result_trapezoidal}\")\nprint(f\"Simpson's Rule: {result_simpsons}\")\nprint(f\"Midpoint Rule: {result_midpoint}\")\nprint(f\"Boole's Rule: {result_booles}\")\nprint(f\"Romberg Integration: {result_romberg}\")\nprint(f\"Gauss-Legendre Quadrature: {result_gauss_legendre}\")\nprint(f\"Gauss-Chebyshev Quadrature: {result_gauss_chebyshev}\")\nprint(f\"Gauss-Laguerre Quadrature: {result_gauss_laguerre}\")\nprint(f\"Gauss-Hermite Quadrature: {result_gauss_hermite}\")\nprint(f\"Adaptive Simpson's Rule: {result_adaptive_simpsons}\")\nprint(f\"Monte Carlo Integration: {result_monte_carlo}\")\nprint(f\"Double Integral: {result_double_integral}\")\nprint(f\"Double Integral: {result_double_integral}\")\nprint(f\"Simpson's Rule with Error Estimation: {result_simpsons_error} with an error estimate of {error_estimate}\")\n\n```\n\n## Output\n```bash \n\nResults:\nTrapezoidal Rule: 333.33350000000013\nSimpson's Rule: 1.8390715291786217\nMidpoint Rule: 0.8862269254527569\nBoole's Rule: 333.3333333333334\nRomberg Integration: 1.839071529076259\nGauss-Legendre Quadrature: 0.9622861833849173\nGauss-Chebyshev Quadrature: 2.026469405000093\nGauss-Laguerre Quadrature: 0.5408201719540809\nGauss-Hermite Quadrature: 1.260069748687603\nAdaptive Simpson's Rule: 0.443113467730597\nMonte Carlo Integration: 0.7746479690195586\nDouble Integral: 0.25507601265177027\nSimpson's Rule with Error Estimation: 1.8390715291786217 with an error estimate of 5.555553794065748e-06\n\n```\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "pynumint is a package for Numerical Integration tasks",
"version": "0.2.3",
"project_urls": {
"Bug Reports": "https://github.com/CodeSleuthX/pynumint/issues",
"Homepage": "https://github.com/CodeSleuthX/pynumint",
"Source": "https://github.com/CodeSleuthX/pynumint"
},
"split_keywords": [
"numerical",
"integration",
"mathematics",
"science"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a80fe12c554f642d8f06b51b1975dc143bd4eda08b6fe7e937aa54e75a698232",
"md5": "3cacef496518d2343b6ace05ef95e1f1",
"sha256": "886da919bc8ffc5bd8e1c0be1f0ece8355f2da4f529a32d71f6feedd69dd5b24"
},
"downloads": -1,
"filename": "pynumint-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3cacef496518d2343b6ace05ef95e1f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5075,
"upload_time": "2024-06-13T19:33:17",
"upload_time_iso_8601": "2024-06-13T19:33:17.134999Z",
"url": "https://files.pythonhosted.org/packages/a8/0f/e12c554f642d8f06b51b1975dc143bd4eda08b6fe7e937aa54e75a698232/pynumint-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c58d6fec3a8e3334611e8f5144e1319dd66a75adeb35664a77ffb13a9b88c87f",
"md5": "e0479f08d65d6c153e131f3b85f78526",
"sha256": "36feda0160f5953b73825d3bb7c46a59e66713b2aa8b101774cef98471ed2018"
},
"downloads": -1,
"filename": "pynumint-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "e0479f08d65d6c153e131f3b85f78526",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5561,
"upload_time": "2024-06-13T19:33:19",
"upload_time_iso_8601": "2024-06-13T19:33:19.921203Z",
"url": "https://files.pythonhosted.org/packages/c5/8d/6fec3a8e3334611e8f5144e1319dd66a75adeb35664a77ffb13a9b88c87f/pynumint-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-13 19:33:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "CodeSleuthX",
"github_project": "pynumint",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pynumint"
}