SM-5-Exercise6

4142 days ago by MathFest

#I'm answering this question for q-Bernoulli only. #Using the q-binomial recursion for the sequence. #Define q-binomial coefficients first. var('q,t') def QProd(t,q,N): prod=1 for j in range(N): prod=prod*(1-q^j*t) return prod def QBinom(n,k,q): return expand(factor(QProd(q,q,n))/factor(QProd(q,q,k)*QProd(q,q,n-k))) 
       
#qBernoulliList(n) outputs a list of the first n qBernoulli numbers #using the q-binomial recursion. #QBernoulli(n) is the last one in this list. def QBernoulliList(n,q): l=[1] for j in range(n): L=len(l) sum=0 for k in range(L): sum=sum-expand(factor(QBinom(L,k,q))*factor((q-1))/factor((q^(L-k+1)-1)))*l[k] l.append(sum) return l def QBernoulli(n): return QBernoulliList(n,q)[n] 
       
QBernoulli(3) 
       
-(1/(q + 1) - 1/(q^2 + q + 1))*(q^2/(q + 1) + q/(q + 1) + 1/(q + 1)) +
1/(q + 1) - 1/((q + 1)*(q^2 + 1))
-(1/(q + 1) - 1/(q^2 + q + 1))*(q^2/(q + 1) + q/(q + 1) + 1/(q + 1)) + 1/(q + 1) - 1/((q + 1)*(q^2 + 1))