Ask Your Question

Determinant Function on Qp

asked 2021-05-10 22:01:39 +0100

whatupmatt gravatar image

See attachmentC:\fakepath\Screenshot (104).png

I basically have 2 matrices with entries in Qp. I cant exactly do Matrix2.charpoly() as this is det (xI-Matrix2) and I want determinant of (I-xMatrix2). So I decided to just type det(I-x*Matrix2) but it gives me error. Is there a way to fix this?

If you want me to be honest, I get an error just from I-x*Matrix2. So it might not even be the determinant function.

edit retag flag offensive close merge delete


Could you please provide your code so that we can understand ? The picture does not show the whole construction.

tmonteil gravatar imagetmonteil ( 2021-05-10 22:21:28 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-05-10 22:31:56 +0100

tmonteil gravatar image

updated 2021-05-10 22:33:52 +0100

Given the picture, i have to guess your construction (tell ):

Your field K :

sage: K = Qp(5,prec=70)                                                                                                                                                                                      
sage: K                                                                                                                                                                                                      
5-adic Field with capped relative precision 70

Your matrix I (which is the identity) :

sage: I = matrix.identity(K,15)

There is no information about the construction of Matrix2, hence, i will pick one randomly:

sage: M = I.parent()                                                                                                                                                                                         
sage: M                                                                                                                                                                                                      
Full MatrixSpace of 15 by 15 dense matrices over 5-adic Field with capped relative precision 70
sage: Matrix2 = M.random_element()

On my installation,

sage: Matrix2.charpoly()

works well.

The folowing does not work:

sage: x*Matrix2

because, by default x is a symbol, to be used in symbolic expressions like sin(x)*sqrt(2).

What you might want is a polynomial indeterminate. The following non-Pythonic constructions builds both the polynomial ring R and the indeterminate x

sage: R.<x> = K[]                                                                                                                                                                                            
sage: R                                                                                                                                                                                                      
Univariate Polynomial Ring in x over 5-adic Field with capped relative precision 70

WIth such a x, you can do:

sage: det(I - x*Matrix2)

The difference with the previous charpoly result seem to be some residual things due to bounded precision:

sage: det(I - x*Matrix2) - Matrix2.charpoly()
O(5^-1843)*x^15 + O(5^-1813)*x^14 + O(5^-1585)*x^13 + O(5^-1544)*x^12 + O(5^-1316)*x^11 + O(5^-1275)*x^10 + O(5^-1047)*x^9 + O(5^-1006)*x^8 + O(5^-1006)*x^7 + O(5^-1047)*x^6 + O(5^-1275)*x^5 + O(5^-1316)*x^4 + O(5^-1544)*x^3 + O(5^-1585)*x^2 + O(5^-1813)*x + O(5^-1843)
edit flag offensive delete link more


Great thanks. I have a question on this. Suppose I have a matrix with rational entries. So let's say Matrix is = [a, b] [c ,d]. How can I quickly make Sage consider this over K, the p adic integers. Do I have to explicitly type out K(a), K(b), K(c), K(d). This is really annoying if the matrix is huge

whatupmatt gravatar imagewhatupmatt ( 2021-05-10 23:25:41 +0100 )edit

Having defined a matrix m over QQ, and a field K of p-adic numbers, use m.change_ring(K).

slelievre gravatar imageslelievre ( 2021-05-10 23:36:44 +0100 )edit

Great thanks.

whatupmatt gravatar imagewhatupmatt ( 2021-05-11 03:48:34 +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


Asked: 2021-05-10 22:01:39 +0100

Seen: 171 times

Last updated: May 10 '21