Ask Your Question

Revision history [back]

Here is one way you could access the factorization you want.

First let's just define

sage: U = (u^2 - 4281747124104997066155259836393062400)*(u^2 - 4281747146564836134743374782202380288)

U is a symbolic expression, which is a product. Let's access the factors.

sage: a, b = U.operands()
sage: a
u^2 - 4281747124104997066155259836393062400
sage: b
u^2 - 4281747146564836134743374782202380288

Now each of a and b are also symbolic expressions, and they are sums. Let's access the summands.

sage: a0, a1 = a.operands()
sage: a0, a1
(u^2, -4281747124104997066155259836393062400)
sage: b0, b1 = b.operands()
sage: b0, b1
(u^2, -4281747146564836134743374782202380288)

Now we can factor a1 and b1 by first turning them into proper Sage integers.

sage: ZZ(a1).factor()
-1 * 2^24 * 3^36 * 5^2 * 17 * 19^2 * 29 * 47^2 * 173
sage: ZZ(b1).factor()
-1 * 2^24 * 3^34 * 29 * 173 * 55229^2

With a little work we could write a function that parses the expression tree and outputs a representation where each integer is decomposed into prime factors...

Here is one way you could access the factorization you want.

First let's just define

sage: U = (u^2 - 4281747124104997066155259836393062400)*(u^2 - 4281747146564836134743374782202380288)

U is a symbolic expression, which is a product. Let's access the factors.

sage: a, b = U.operands()
sage: a
u^2 - 4281747124104997066155259836393062400
sage: b
u^2 - 4281747146564836134743374782202380288

Now each of a and b are also symbolic expressions, and they are sums. Let's access the summands.

sage: a0, a1 = a.operands()
sage: a0, a1
(u^2, -4281747124104997066155259836393062400)
sage: b0, b1 = b.operands()
sage: b0, b1
(u^2, -4281747146564836134743374782202380288)

Now we can factor a1 and b1 by first turning them into proper Sage integers.

sage: ZZ(a1).factor()
-1 * 2^24 * 3^36 * 5^2 * 17 * 19^2 * 29 * 47^2 * 173
sage: ZZ(b1).factor()
-1 * 2^24 * 3^34 * 29 * 173 * 55229^2

With a little work we could write a function that parses the expression tree and outputs a representation where each integer is decomposed into prime factors...

To get the squarefree part:

sage: bb1 = abs(ZZ(b1))
sage: bb1.squarefree_part()
5017
sage: bb1.squarefree_part().factor()
29 * 173