# How to factorise a quantity obtained after summing?

list=[]

for n in range(2,20,2):
s = sum(1/k^n,k,1,oo)/(pi)^n
print(s)
list.append(s.factor())
print(list)


My code is given above I'm not able to use the .factor() function, I understand that this is due to the type of s in the above code which is sage.symbolic.expression.Expression . My question is how to convert it into ππππ.πππππ.ππππππππ.ππππππππ or something else so that I can factorise it. In the end I want to make a list of these numbers factorized.

edit retag close merge delete

Sort by Β» oldest newest most voted

For your problem, since zeta(2n) has an explicit expression in terms of Bernoulli number I would rather go with

sage: [((-1)**(1+n//2)*2**(n-1) * bernoulli(n)/factorial(n)).factor() for n in range(2,20,2)]
[2^-1 * 3^-1,
2^-1 * 3^-2 * 5^-1,
3^-3 * 5^-1 * 7^-1,
2^-1 * 3^-3 * 5^-2 * 7^-1,
3^-5 * 5^-1 * 7^-1 * 11^-1,
3^-6 * 5^-3 * 7^-2 * 11^-1 * 13^-1 * 691,
2 * 3^-6 * 5^-2 * 7^-1 * 11^-1 * 13^-1,
2^-1 * 3^-7 * 5^-4 * 7^-2 * 11^-1 * 13^-1 * 17^-1 * 3617,
3^-9 * 5^-3 * 7^-3 * 11^-1 * 13^-1 * 17^-1 * 19^-1 * 43867]

more

Replace s.factor() by QQ(s).factor() to convert the symbolic expression to a rational and to factor that rational. Indeed, SR(1/6).factor() yields 1/6 while QQ(1/6).factor() yields 2^-1 * 3^-1.

more