[Numpy-discussion] Polynomial evaluation inconsistencies (original) (raw)
Eric Wieser wieser.eric+numpy at gmail.com
Sat Jun 30 17:41:28 EDT 2018
- Previous message (by thread): [Numpy-discussion] Polynomial evaluation inconsistencies
- Next message (by thread): [Numpy-discussion] Polynomial evaluation inconsistencies
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Since the one of the arguments for the decreasing order seems to just be textual representation - do we want to tweak the repr to something like
Polynomial(lambda x: 2x**3 + 3x**2 + x + 0)
(And add a constructor that calls the lambda with Polynomial(1))
Eric
On Sat, 30 Jun 2018 at 14:30 Eric Wieser <wieser.eric+numpy at gmail.com> wrote:
“the intuitive way” is the decreasing powers.
An argument against this is that accessing the ith power of x is spelt: - x.coeffs[i] for increasing powers - x.coeffs[-i-1] for decreasing powers The former is far more natural than the latter, and avoids a potential off-by-one error If I ask someone to write down the coefficients of a polynomial I don’t think anyone would start from c[2] You wouldn’t? I’d expect to see [image: f(x) = a3x^3 + a2x^2 + a1x + a0] rather than [image: f(x) = a0x^3 + a1x^2 + a2x + a3] Sure, I’d write it starting with the highest power, but I’d still number my coefficients to match the powers.
Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180630/834762ab/attachment.html>
- Previous message (by thread): [Numpy-discussion] Polynomial evaluation inconsistencies
- Next message (by thread): [Numpy-discussion] Polynomial evaluation inconsistencies
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]