On Monday, June 17, 2019 at 2:12:58 PM UTC+2, Peter Luschny wrote:
As I see it the problem is that the sum runs over (0..n-1). > Thus for n = 0 it returns by convention the integer 0 for the > empty sum (is this correct?) which of course has no list. > > But shouldn't it return the null polynomial in this case? > And isn't the null polynomial represented by the empty list? > > No, because sum has no way to know that you are expecting a polynomial. You can add a zero polynomial to make the sum over it to obtain a polynomial as a result. With David function: sage: R=ZZ['x'] sage: zero = R(0) sage: def ib(m, n): return sum([binomial(m*n-1, m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1)], zero) sage: type(ib(2,2)) <type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'> sage: ib(2,0) 0 sage: type(ib(2,0)) <type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'> sage: for n in (0..6): ....: print(ib(2, n).list()) ....: [] [1, 1] [4, 1, 3] [16, -4, 15] [64, -34, 56, 0, 7] [256, -134, 171, -9, 93] [1024, -494, 539, -165, 638] -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/c402036f-b729-494b-a1d0-0ceca9a03fa2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.