Ask Your Question
0

Factorizing matrix entries that are polynomials

asked 2023-08-22 14:25:39 +0100

vidyarthi gravatar image

Suppose i have a polynomial matrix like:

var('x')
g=graph.CompleteGraph(4)
h=g.am()
t=h-x*identity_matrix(4)
t1=t.adjugate()
t1

Then, how do i get t1 in the factorized/simplified form. Specifically, I see that there are exactly two distinct entries in t1, and each of them can be factorized into two distinct monomial powers. But, how do I get this directly, without having to factorize each element separately. Any hints? Thanks beforehand.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2023-08-22 17:46:03 +0100

vidyarthi gravatar image

Thanks to @MaxAlexseyev, to get what I wanted, which is the adjugate matrix having all its individual entries factored, I used the command t1.apply_map(lambda z:factor(z)), which does the work.

edit flag offensive delete link more

Comments

You do not need to wrap factor in a lambda expression ; this wrapping is useful to wrap a method?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-08-22 22:30:35 +0100 )edit
2

answered 2023-08-22 14:41:40 +0100

Max Alekseyev gravatar image

I'm not sure if I got your question correct, but if you want to find a common factor of the matrix elements, you can do so by computing gcd:

c = gcd(t1.list())

Then you can divide your matrix by this common factor and simplify the rest:

print( (t1 / c).apply_map(lambda z: z.full_simplify()) )

which gives

[-x + 2     -1     -1     -1]
[    -1 -x + 2     -1     -1]
[    -1     -1 -x + 2     -1]
[    -1     -1     -1 -x + 2]

Btw, if you know upfront that you'll deal with polynomial entries, it's better to define a polynomial ring in variable x, which eliminates the need in calling .full_simplify():

R.<x> = QQ[]
g=graphs.CompleteGraph(4)
h=g.am()
t=h-x*identity_matrix(4)
t1=t.adjugate()
c = gcd(t1.list())
print( t1 / c )
edit flag offensive delete link more

Comments

Thanks! I actually wanted to factorize each of the individual matrix entries. On writing factor(t1.list()), I get error saying it cannot factor the list. Any workaround?

vidyarthi gravatar imagevidyarthi ( 2023-08-22 17:37:08 +0100 )edit

Got it! I used t1.apply_map(lambda z:factor(z))to get what I wanted.

vidyarthi gravatar imagevidyarthi ( 2023-08-22 17:44:20 +0100 )edit

Then you can simply use t1.apply_map(factor).

Max Alekseyev gravatar imageMax Alekseyev ( 2023-08-25 04:00:13 +0100 )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: 2023-08-22 14:25:39 +0100

Seen: 66 times

Last updated: Aug 22 '23