| 1 | initial version |
Update:
I defined the expressions I was looking for by using the lambda function:
var('q,n,k,m')
qfac= lambda n : prod([(1-q^(k))/(1-q) for k in (1..n)]) #q-factorial
qbin = lambda n,m : qfac(n)/(qfac(m)*qfac(n-m)) #q-binomial
S= lambda n : sum([qbin(n,k) for k in (1..n)])
I also stopped using the iput sum(funcion,variable,lower limit,upper limit), and I am using sum([list]), where the list is defined by [expression(k) for k in (1..n)]. Although the first one works for simple stuff, It is not so good for symbolic.
Now I can call, as an example, S(4).
S(4)
A second way I defined the sum above is by defining a list in a specific range,
S = [sum([qbin(n,k) for k in (1..n)]) for n in (1..5)]
And I can call S(4) by calling the S[3] (lists start in 0, and use square brackets )
S[3]
I can also call all elements in a range of the list by
S[0:4]
This calls all elements up to S[3], which I find a bit confusing...
I'm still new to all of this... perhaps I can use "def" to do the same, maybe it is better, but I'm satisfied for now. Any comments are welcome.
| 2 | No.2 Revision |
Update:
I defined the expressions I was looking for by using the lambda function:
var('q,n,k,m')
qfac= lambda n : prod([(1-q^(k))/(1-q) for k in (1..n)]) #q-factorial
qbin = lambda n,m : qfac(n)/(qfac(m)*qfac(n-m)) #q-binomial
S= lambda n : sum([qbin(n,k) for k in (1..n)])
enter code here
I also stopped using the iput sum(funcion,variable,lower limit,upper limit), and I am using sum([list]), where the list is defined by [expression(k) for k in (1..n)]. Although the first one works for simple stuff, It is not so good for symbolic.
Now I can call, as an example, S(4).
S(4)
A second way I defined the sum above is by defining a list in a specific range,
S = [sum([qbin(n,k) for k in (1..n)]) for n in (1..5)]
And I can call S(4) by calling the S[3] (lists start in 0, and use square brackets )
S[3]
I can also call all elements in a range of the list by
S[0:4]
This calls all elements up to S[3], which I find a bit confusing...
I'm still new to all of this... perhaps I can use "def" to do the same, maybe it is better, but I'm satisfied for now. Any comments are welcome.
| 3 | No.3 Revision |
Update:
I defined the expressions I was looking for by using the lambda function:
var('q,n,k,m')
qfac= lambda n : prod([(1-q^(k))/(1-q) for k in (1..n)]) #q-factorial
qbin = lambda n,m : qfac(n)/(qfac(m)*qfac(n-m)) #q-binomial
S= lambda n : sum([qbin(n,k) for k in (1..n)])
enter code here
I also stopped using the iput sum(funcion,variable,lower limit,upper limit), and I am using sum([list]), where the list is defined by [expression(k) for k in (1..n)]. Although the first one works for simple stuff, It is not so good for symbolic.
Now I can call, as an example, S(4).
S(4)
A second way I defined the sum above is by defining a list in a specific range,
S = [sum([qbin(n,k) for k in (1..n)]) for n in (1..5)]
And I can call S(4) by calling the S[3] (lists start in 0, and use square brackets )
S[3]
I can also call all elements in a range of the list by
S[0:4]
This calls all elements up to S[3], which I find a bit confusing...
I'm still new to all of this... perhaps I can use "def" to do the same, maybe it is better, but I'm satisfied for now. Any comments are welcome.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.