Ask Your Question
1

How to factor the coefficient

asked 2015-10-21 06:25:47 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I have the following code :

r,s,u= var('r s u')
U=u^4-A*u^2+17*B;U
eq1=U.subs({r:-21,s:324});eq1
factor(eq1)

which yields

(u^2 - 4281747124104997066155259836393062400)*(u^2 - 4281747146564836134743374782202380288)

My question : is there a code where I can factor the equation to yield something like this

(u^2 - 2^24*3^36*5^2*17*19^2*29*47^2*173)*(u^2 - 2^24*3^34*29*173*55229^2)

Because my aim is to look at the non-square numbers that appear in both factorization. In this case 29*173.

edit retag flag offensive close merge delete

Comments

We cannot try your code without a proper definition for A and B.

slelievre gravatar imageslelievre ( 2015-10-21 07:32:03 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-21 07:40:02 +0200

slelievre gravatar image

updated 2015-10-22 07:08:33 +0200

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

Comments

Thank you @slelievre. This worked for me.

Sha gravatar imageSha ( 2015-10-22 03:31:24 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-10-21 06:25:47 +0200

Seen: 422 times

Last updated: Oct 22 '15