Re: [sage-support] The behavior of empty sums

2019-06-25 Thread John H Palmieri
On Tuesday, June 25, 2019 at 3:10:29 AM UTC-7, Peter Luschny wrote: > > Am Di., 25. Juni 2019 um 10:49 Uhr 'luisfe' : > > | 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 >

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread Peter Luschny
Am Di., 25. Juni 2019 um 11:29 Uhr schrieb slelievre < samuel.lelie...@gmail.com>: > 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()) > Now, this is clever!

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread Peter Luschny
Am Di., 25. Juni 2019 um 10:49 Uhr 'luisfe' : | 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. Well, then the way 'sum' is implemented is possibly improvable? The type

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread slelievre
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.

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread 'luisfe' via sage-support
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

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread slelievre
Would you share the definition of OmegaPolynomial? This would help figure out / explain what the issue is. -- 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

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread Peter Luschny
Am Montag, 17. Juni 2019 14:27:40 UTC+2 schrieb luisfe: > > On Mon, Jun 17, 2019 at 5:18 AM Peter Luschny wrote: >> >>> def ib(m, n): return sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k >>> in (0..n-1)) >>> >>> The terms "binomial(m*n-1, m*k)*OmegaPolynomial(m,k)" are of type >>> >>

Re: [sage-support] The behavior of empty sums

2019-06-23 Thread Vincent Delecroix
The SageMath function sum accepts an optional "zero" argument precisely for this purpose sage: sum([], 0) 0 sage: sum([], 11) 11 sage: sum([], []) [] Le 17/06/2019 à 11:18, Peter Luschny a écrit : Hi, I think we should be confident that the sum of integers is again an integer, the sum of

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread 'luisfe' via sage-support
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

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread 'luisfe' via sage-support
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

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread Peter Luschny
> Are you saying, the error message it spits out, >> > AttributeError: 'int' object has no attribute 'list', > is misleading? > 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

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread David Joyner
On Mon, Jun 17, 2019 at 5:38 AM Peter Luschny wrote: > I don't know what OmegaPolynomial is. However, if you replace it by >> cyclotomic_polynomial, >> it seems to work as expected, doesn't it? >> > > No, it does not. You missed the question. > > >> >> sage: *def* *ib*(m, n): *return*

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread Peter Luschny
> > I don't know what OmegaPolynomial is. However, if you replace it by > cyclotomic_polynomial, > it seems to work as expected, doesn't it? > No, it does not. You missed the question. > > sage: *def* *ib*(m, n): *return* sum(binomial(m*n-*1*, > m*k)*cyclotomic_polynomial(m*(k+*1*)) *for*

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread David Joyner
On Mon, Jun 17, 2019 at 5:18 AM Peter Luschny wrote: > Hi, > > I think we should be confident that the sum of integers is > again an integer, the sum of rational numbers a rational number > and that the sum of polynomials is a polynomial. > > With Sage this is not the case. > > def ib(m, n):

[sage-support] The behavior of empty sums

2019-06-17 Thread Peter Luschny
Hi, I think we should be confident that the sum of integers is again an integer, the sum of rational numbers a rational number and that the sum of polynomials is a polynomial. With Sage this is not the case. def ib(m, n): return sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k in