[Numpy-discussion] Polynomial evaluation inconsistencies
maifer at haverford.edu
Fri Jun 29 22:21:18 EDT 2018
I noticed some frustrating inconsistencies in the various ways to evaluate
polynomials using numpy. Numpy has three ways of evaluating polynomials
(that I know of) and each of them has a different syntax:
You define a polynomial by a list of coefficients *in order of
increasing degree*, and then use the class’s call() function.
Evaluates a polynomial at a point. *First* argument is the polynomial,
or list of coefficients *in order of decreasing degree*, and the *second*
argument is the point to evaluate at.
Also evaluates a polynomial at a point, but has more support for
vectorization. *First* argument is the point to evaluate at, and *second*
argument the list of coefficients *in order of increasing degree*.
Not only the order of arguments is changed between different methods, but
the order of the coefficients is reversed as well, leading to puzzling bugs
(in my experience). What could be the reason for this madness? As polyval
is a shameless ripoff of Matlab’s function of the same name
<https://www.mathworks.com/help/matlab/ref/polyval.html> anyway, why not
just use matlab’s syntax (polyval([c0, c1, c2...], x)) across the board?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion