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 is not adding polynomials, it is adding the empty list, 
there is no way that the sum known that you are expecting a polynomial.

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]
sage: sum([])
0

sage: *def* *ib*(m, n): *return* sum(binomial(m*n-*1*, m*k) *for* k in (*0.*
.n-*1*))

This function should return integers, no polynomials.

If you want to return a flint polynomial, you could instruct to make the 
sum over the polynomial zero using an additional argument. 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'>


-- 
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/3c6eb571-cbcf-455f-9ac2-ff2737f6b411%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to