Calculate area under curve
Project description
area\_under\_curve
==================
- Python 2.7/3.5+ module to calculate riemann sum area under a curve
- Supports
- simpson, trapezoid, and midpoint algorithms,
- n-degree single variable polynomials, including fractional exponents,
- variable step size
- https://github.com/smycynek/area-under-curve/
``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``.
==================
- Python 2.7/3.5+ module to calculate riemann sum area under a curve
- Supports
- simpson, trapezoid, and midpoint algorithms,
- n-degree single variable polynomials, including fractional exponents,
- variable step size
- https://github.com/smycynek/area-under-curve/
``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
area_under_curve-0.9.9.zip
(12.5 kB
view hashes)
Built Distribution
Close
Hashes for area_under_curve-0.9.9-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db1f73d9a3bea29a080164c10e5f6ba9ab379891d1321844983c58d7a39b4e84 |
|
MD5 | 2a76558069e0591d18b1784b0b5ac6c4 |
|
BLAKE2b-256 | 7a99de02f2e306f0ee1a18d664c74f01f5036bcd761894e6a7ae66041bfd8861 |