Tue 2019-06-25 10:49:44 UTC+2, luisfe:
>
>
> On Tuesday, June 25, 2019 at 10:03:03 AM UTC+2, Peter Luschny wrote:
>>
>> How that? Look at the output above. Sage *knows* that the terms of the 
>> sum 
>> are polynomials. So it should return the zero of that ring, which is the 
>> null polynomial.
>>
>
> Not in the first case, look at what are you passing to sum as argument
>
> sage: sage: R=ZZ['x']
> sage: R=ZZ['x']
> sage: def ib(m, n): return [binomial(m*n-1, 
> m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1)]
> sage: for n in (0..6):
> ....:     print(ib(2,n))
> ....:     
> []
> [x + 1]
> [x + 1, 3*x^2 + 3]
> [x + 1, 10*x^2 + 10, 5*x^2 - 5*x + 5]
> [x + 1, 21*x^2 + 21, 35*x^2 - 35*x + 35, 7*x^4 + 7]
> [x + 1, 36*x^2 + 36, 126*x^2 - 126*x + 126, 84*x^4 + 84, 9*x^4 - 9*x^3 + 
> 9*x^2 - 9*x + 9]
> [x + 1, 55*x^2 + 55, 330*x^2 - 330*x + 330, 462*x^4 + 462, 165*x^4 - 
> 165*x^3 + 165*x^2 - 165*x + 165, 11*x^4 - 11*x^2 + 11]
>  
> When n =0, k ranges from 0 to -1 so there is no k and the list constructed 
> in ib(n,m) is just the empty list. Not an empty list of polynomials, just 
> an empty list.
>

This is what makes it necessary to define what the sum starts from;
here, the zero in the polynomial ring (instead of the default which is
the integer zero).

So, replace

    sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k in (0..n-1))

by

    sum((binomial(m*n-1, m*k)*OmegaPolynomial(m, k) for k in (0 .. n-1)), 
RR['x'].zero()) 

-- 
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/cbf6fbbe-fe57-446d-ad88-8a5eca23bcfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to