Skip to main content

Numerical approximators to calculate the definit integral

Project description

integrals

integrals is a Python library for using numerical methods to approximate definit integrals.

Installation

Use the package manager pip to install integrals.

pip install integrals

Usage

from integrals import Riemann, Trapezoid, Simpson
from numpy import exp

f = lambda x:exp(x**2)
riemann = Riemann(x)
print(riemann.compute_integral(-1, 3, 30, 'midpoint')) # Computing the integral of f(x) using 'Riemann midpoint sum' from -1 to 3 with 30 sub-intervals.
trapezoid = Trapezoid(f)
print(trapezoid.compute_integral(-1, 3, 30)) # Computing the integral of f(x) using 'trapezoid rule' from -1 to 3 with 30 sub-intervals.
simpson = Simpson(f)
print(simpson.compute_integral(-1, 3, 30)) # Computing the integral of f(x) using 'Simpson's rule' from -1 to 3 with 30 sub-intervals.

riemann.plot_function() # Plots the function and shows the Rieman's sum rectangles
trapezoid.plot_function() # Plots the function and shows the trapezoids
simpson.plot_function() # Plots the function and shows the sectors

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

integrals-0.2.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file integrals-0.2.tar.gz.

File metadata

  • Download URL: integrals-0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for integrals-0.2.tar.gz
Algorithm Hash digest
SHA256 78069a8b1b24fabeea8da4b660917b63f6b0b0845c502be564483dd7689d2548
MD5 d5b7be765414113f0fa94a5467573f36
BLAKE2b-256 0ee85709260cb045496258dea419385ed55bdc930d62961b1deb0a47680a4151

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page