Ask Your Question

ricardokl's profile - activity

2020-05-06 16:17:44 +0200 received badge  Notable Question (source)
2019-09-21 15:55:46 +0200 received badge  Student (source)
2019-09-21 15:14:30 +0200 received badge  Popular Question (source)
2017-03-10 18:22:19 +0200 commented answer Symbolic sum with q_binomial

I had the impression the code would run and show the output...

2017-03-10 18:20:25 +0200 received badge  Editor (source)
2017-03-10 18:19:40 +0200 answered a question Symbolic sum with q_binomial

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.

2017-03-03 15:53:06 +0200 commented answer Symbolic sum with q_binomial

Thanks, good to know about these differences, I am new to all of this. But how should I proceed then? I need to use the full definition on the q_binomial explicitly? I also had some difficulty with this. I can define a sum with a arbitrary upper value 'k', but I can't do the same with a product (to use the q-factorial).

2017-03-02 19:13:26 +0200 asked a question Sum of q_binomial

Hi,

I'm new to sagemath. I'm trying to define a function that depends on a sum of a q-binomial, but I get "unable to convert n to an integer".

So, this works: sum(binomial(n,k),k,1,n)

(output gives $2^n-1$)

but this doesn't: sum(q_binomial(n,k),k,1,n)

All I did was add the "q_", which is the proper way to define a q-binomial in sage, as I already tested (try q_binomial(5,3) and the output is correct).

Anyone can help?

2017-03-02 19:13:25 +0200 asked a question Symbolic sum with q_binomial

Hi,

I'm new to sagemath. I'm trying to define a function that depends on a sum of a q-binomial, but I get "unable to convert n to an integer".

So, this works: sum(binomial(n,k),k,1,n)

(output gives $2^n-1$)

but this doesn't: sum(q_binomial(n,k),k,1,n)

All I did was add the "q_", which is the proper way to define a q-binomial in sage, as I already tested (try q_binomial(5,3) and the output is correct).

Anyone can help?