Ask Your Question
0

How to factorise a quantity obtained after summing?

asked 2020-04-05 09:38:08 +0100

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 flag offensive close merge delete

2 Answers

Sort by Β» oldest newest most voted
2

answered 2020-04-05 15:30:32 +0100

rburing gravatar image

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.

edit flag offensive delete link more
0

answered 2020-04-05 17:46:08 +0100

vdelecroix gravatar image

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]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-04-05 09:38:08 +0100

Seen: 253 times

Last updated: Apr 05 '20