[Numpy-discussion] Polynomial evaluation inconsistencies

Eric Wieser wieser.eric+numpy at gmail.com
Sat Jun 30 18:08:40 EDT 2018


Good catch, it would do that

On Sat, 30 Jun 2018 at 15:07 Maxwell Aifer <maifer at haverford.edu> wrote:

> *shouldn't the constructor call the lambda with Polynomial([0,1[)
>
> On Sat, Jun 30, 2018 at 6:05 PM, Maxwell Aifer <maifer at haverford.edu>
> wrote:
>
>> Oh, clever... yeah I think that would be very cool. But shouldn't it call
>> the constructor with Polynomial([0,1])?
>>
>> On Sat, Jun 30, 2018 at 5:41 PM, Eric Wieser <wieser.eric+numpy at gmail.com
>> > wrote:
>>
>>> 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: 2*x**3 + 3*x**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) = a_3x^3 + a_2x^2 + a_1x + a_0]
>>>>
>>>> rather than
>>>>
>>>> [image: f(x) = a_0x^3 + a_1x^2 + a_2x + a_3]
>>>>
>>>> Sure, I’d write it starting with the highest power, but I’d still
>>>> number my coefficients to match the powers.
>>>>
>>>>
>>>> Eric
>>>>>>>>
>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion at python.org
>>> https://mail.python.org/mailman/listinfo/numpy-discussion
>>>
>>>
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180630/2de48958/attachment-0001.html>


More information about the NumPy-Discussion mailing list