Calculate area under curve
Project description
Python 3 module to calculate area under a curve
Supports simpson, trapezoid, and midpoint algorithms, n-degree single variable polynomials, and 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.
example:
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._make([polynomial, bounds, algorithm])
AREA = auc.area_under_curve(params.polynomial, params.bounds, params.algorithm)
print(str(AREA))
Also try out unit_test.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
Hashes for area_under_curve-0.9.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3a6ef1e8b7ab6734c748e4549725a12d1d43b854acfa15b35ae260044c9d870 |
|
MD5 | 89b77b87d69e5cac69818a305c94193b |
|
BLAKE2b-256 | 1e65070b5f0baf92f1493a558d375ffd6cc72e0e4d6787c2aebddbe49e88d150 |