I have a range of data that I have approximated using a polynomial of degree 2 in Python. I want to calculate the area underneath this polynomial between 0 and 1.
Is there a calculus, or similar package from numpy that I can use, or should I just make a simple function to integrate these functions?
I’m a little unclear what the best approach for defining mathematical functions is.
Thanks.
If you’re integrating only polynomials, you don’t need to represent a general mathematical function, use
numpy.poly1d, which has anintegmethod for integration.For integrating arbitrary numerical functions, you would use
scipy.integratewith normal Python functions for functions. For integrating functions analytically, you would usesympy. It doesn’t sound like you want either in this case, especially not the latter.