# [Numpy-discussion] Polynomial evaluation inconsistencies

Maxwell Aifer maifer at haverford.edu
Mon Jul 2 03:31:46 EDT 2018

```Ok I see what you mean. If people really want math-like symbolic
representations for everything it’s probably better to use sympy or
something
On Mon, Jul 2, 2018 at 2:59 AM Eric Wieser <wieser.eric+numpy at gmail.com>
wrote:

> I think the `x` is just noise there, especially if it's ignored (that is,
> `T[0](x*2)` doesn't do anything reasonable).
>
>     Chebyshev.literal(lambda T: 1*T[0] + 2*T[1] + 3*T[2])
>
> Would work, but honestly I don't think that provides much clarity. I think
> the value here is mainly for "simple" polynomials.
>
> On Sun, 1 Jul 2018 at 23:42 Maxwell Aifer <maifer at haverford.edu> wrote:
>
>> Say we add a constructor to the polynomial base class that looks
>> something like this:
>>
>>
>> -------------------------------------------------------------------------------------------
>>    @classmethod
>>     def literal(cls, f):
>>         def basis_function_getter(self, deg):
>>             coefs = [0]*deg + [1]
>>             return lambda _: cls(coefs)
>>         basis = type('',(object,),{'__getitem__':
>> basis_function_getter})()
>>         return f(basis, None)
>>
>> -------------------------------------------------------------------------------------------
>>
>>
>> Then the repr for, say, a Chebyshev polynomial could look like this:
>>
>> >>> Chebyshev.literal(lambda T,x: 1*T[0](x) + 2*T[1](x) + 3*T[2](x))
>>
>> Does this sound like a good idea to anyone?
>>
>> Max
>>
>>
>> On Sat, Jun 30, 2018 at 6:47 PM, Charles R Harris <
>> charlesr.harris at gmail.com> wrote:
>>
>>>
>>>
>>> On Sat, Jun 30, 2018 at 4:42 PM, Charles R Harris <
>>> charlesr.harris at gmail.com> wrote:
>>>
>>>>
>>>>
>>>> On Sat, Jun 30, 2018 at 3: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
>>>>>
>>>>
>>>> IIRC there was a proposal for that. There is the possibility of adding
>>>> renderers for latex and html that could be used by Jupyter, and I think the
>>>> ordering was an option.
>>>>
>>>
>>> See https://github.com/numpy/numpy/issues/8893 for the proposal. BTW,
>>> if someone would like to work on this, go for it.
>>>
>>> Chuck
>>>
>>>> ​
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...