Calculate area under curve
Project description
Version 1.0.1
Python 3.7+ module to calculate riemann sum area under a curve
Copyright 2017 Steven Mycynek
Supports
simpson, trapezoid, and midpoint algorithms,
n-degree single variable polynomials, including fractional exponents,
variable step size
USAGE = """ -p|--poly {DegreeN1:CoefficientM1, DegreeN2:CoefficientM2, ...}... -l|--lower <lower_bound> -u|--upper <upper_bound> -s|--step <step> -a|--algorithm <simpson | trapezoid | midpoint>
This was just a fun experiment I did on a couple airplane rides and might not be suitable for production use.
Try a simple function you can integrate by hand easily, like f(x) = x^3 from [0-10], and compare that to how accurate the midpoint, trapezoid, and simpson approximations are with various steps sizes.
Why not use numpy? You probably should, but I wanted to do everything from scratch for fun.
examples:
python area_under_curve.py --polynomial {3:1} --lower 0 --upper 10 --step .1 --algorithm simpson
or:
import area_under_curve as auc
algorithm = auc.get_algorithm("simpson")
bounds = auc.Bounds(0, 10, .1)
polynomial = auc.Polynomial({3:1})
params = auc.Parameters(polynomial, bounds, algorithm)
AREA = auc.area_under_curve(params.polynomial, params.bounds, params.algorithm)
print(str(AREA))
Also try out unit_test.py and demo.py.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file area_under_curve-1.0.2.tar.gz.
File metadata
- Download URL: area_under_curve-1.0.2.tar.gz
- Upload date:
- Size: 7.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.6.0 requests-toolbelt/0.8.0 tqdm/4.41.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b848396f806ab0f7568f0828ab937d8e889da3db7cfec35bb011f2b910578e3b
|
|
| MD5 |
7a5847cec5c0e97baadb1abbd4b7e9f0
|
|
| BLAKE2b-256 |
7f52d55130bd929e669877f273ef63b86b06fb9cdd22e768380153b7a666147e
|
File details
Details for the file area_under_curve-1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: area_under_curve-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.41.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43ec87dbb612b857450bf1f6d26c62a84998043a64c4674bc174c8b5b6a4fc86
|
|
| MD5 |
a0f8732302d5c675a36c4e8b2f496070
|
|
| BLAKE2b-256 |
da48884e1e2eafc52d5b34e5646f8ba53fe92c79ba05b392d923839305e4dc26
|