Bill Allombert on Wed, 12 Apr 2023 11:36:06 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Find an invertible integer matrix that satisfies given conditions.
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: Find an invertible integer matrix that satisfies given conditions.
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Wed, 12 Apr 2023 11:34:51 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1681292083; c=relaxed/relaxed; bh=spD11KucfzRdHx3At4Ws1vw4OJx+T26VDUzx8aU0Jvc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; b=WHmadZzqxzn4HSihgfd+GN0iyyvSsnFJbx7O0+FtsESJYCHperKpxQdvt2SD4m9Wj02hYbDgU7PJTxcjCBCnBAOvvznx+ah5wzaBgZq3prC4ZAYXdRBS4ZoV5JRyKe8ZJjoyTbzSNa3WGPbknXwhv/Ws71v0Y4zCBU6c/5/UTNi809LBYn+A20wL3PsRQZRBfgy+KEj7dRB4mzgsmXmgzoNxbtmppIpjOgyObLDWibkdIx11fTKsOUyCt83he2iyih3Djf8PADSnBDxrHTVN14sHYIK1QkbrILAnu9E43WLrjKg8Kg9dlePJ2BouyO2PrXP6rtM4qBxS3sMO8lvWqK23yBKCAjqRZEL5kldTlmJrXGTHIWLkU0LsvFaC6GhtwNdmGbuzzRj/XQT/lIyh3S3d0vMlTpoULhXudRWKWSVvZ6chzhTARgTKFDYRiI54ZfVaxsaTELz5T2c7siYDcXAHwU3sWQ688+hyhwRz3ZeTGzQRvTGZedA3Yxx/eJ1K/+w+QUxVAcDMIr2gJO7vjgPMVFf6e2sHw0Iv8Ay83GQWeH9JFoVFtNAscpJWGoln7HmowMnps3AHT/PVsqKFTaauIiI8J4r2nbXwM7UI/yGsD5/KNngMm0e5Hq67NNKjE3cK0U9dDUhRPUl/mQN1JS2fC4KU+iwwY4+AN/ynG6c=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1681292083; cv=none; b=aSKDQReiWB6VYql4YHjViHexcqJHjxgultseXh3Kjo8Zau57TK/ISBNbVohCjQbhIvmswUd7ihFqZEaeEXoxN3z8qgnW2tQBELJcs8e0qjqCFFW5m8EYnnksWjDizGFHENfSYFNeDib8Fq4pw0YZfothikvBTVzS3nzYyUD24hwYEtVYnnxS2gM3iFPwldXU0UThQmxW5e047KWM09v/PsPGYOX3ay/MvRVhLeFrHSSn9gj2X1A8wRgjy8Cxj+0JcLr8M+GveOJC+XOaVwSkpYqbmCOJmI0Jr1T9zTk4Qb+jw8honVrb/H2EdfOrfRSN3ylMJ6X/sslVGMUo4Z5VHo24HKam/ZtKobblbGw7GsC/kuFBLFM5SU5Gw0S/5jZqkjD6SL69HfWhNPQYN+VyWcBBveYI9bhNe6VPJ24AnrCeuY3cii2aifA/yvUgbx5n+Q3veceA9DP6zX/iG06BrHoBGCUMM6SuvOStTdOGdCOr1pm4fX82XjabTieouQHaIO5gI4zldejK7InGBJS47uzWGvOh+uxP6WioGE2OixKQWIfBSl2dShUY5YqVjTSHLaH7J8GVrp1cS39eAi+kn8PjPlHXj4BHQ4zjaWNBegoC0/+OeB5igVMFHRc7ku48h59xfOQvyMJwZ2kGaGWM/lESPIdGjiPfEPkBKJ9ZjFY=
- Authentication-results: smail; arc=none
- Delivery-date: Wed, 12 Apr 2023 11:36:06 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1681292083; bh=spD11KucfzRdHx3At4Ws1vw4OJx+T26VDUzx8aU0Jvc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=LIZ8DAbiQBdQODJ4KwDsvpYPgWT5GYxDAGuOucVEONE4+xD120aTTqXbPRuvHFNE+ s8LjjY1H+qfUNZIS5FDDZIByYIPhqbROBNKtMfjE2AJmyfuP+TtSLQ6Vkpj4DO33fp oBTleImbU5OCeRkhZGENEsZv9eMJ/pLsyiG2YvMeW0W3RQ72eviradnP/cQBN/7Eqo Mk7uZMuk9GGLx2kFLNSLH4UyVjWI2YHn4ZovuWgwiaDhFNk8iC6NjEPR3hvocxpzu+ i7F8s0pgljqqXswUX+dWENnwEgI1Wpnf764KAx1lqXh7MAS03R5tiH0nFAxVAXxNgZ 81Edz3LbFJGN5vdS5IxmAQmd3/pcZBw22qpjxhyK7ZZnY82+zXtzAJIhxUVy5T2HlJ l8bhCgGL2NNJM8ZXM0S07nm85fXimg9lADd37LNGPDS5YPk53Ha8buWkweB8GTjj0b 8Ny3bQu7zndku5XsoijjISlmqIEaIKuYjKcCuBPfiPK1bBJEKfbQ2gcpuYJ60K+y/O 8AocbJnIjHRDNEIxP7KpjLfKmrlnO8AWeTPWAdgqeyJ7D0yonUlV+KscKXyeqO4DQh Ok3O9dKYS4s7p2BFU2bwqrT7fHZMcQrP83hX6ZWiA8EHnHba+Zz4YD4nmNXeAtCrXi 56/veu60H1Q4ukfwpX7Uutgo=
- In-reply-to: <9781d7e9-25df-6bac-a791-60c5b2e4d33f@normalesup.org>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <CAGP6POK-_rePogmmcNvqO=s9tgdHWKMtyyg6UcwZMd2Uc19xHQ@mail.gmail.com> <CANXmBjyyZijGpJEeuY-Dx0VYRMi+bd=Q6a+yDe5s4LrzkaAdCQ@mail.gmail.com> <CANXmBjwYk65_C4VU6Ecz6LmFrD8r44=Mbd5kGfPpyZou02P7uw@mail.gmail.com> <9781d7e9-25df-6bac-a791-60c5b2e4d33f@normalesup.org>
On Wed, Apr 12, 2023 at 09:24:45AM +0200, Aurel Page wrote:
> Dear Zhao,
>
> Your problem is equivalent to finding an isomorphism between two
> Z[t]-lattices. This is a nontrivial task, but there are algorithms for it,
> if you want an efficient solution. You can look at the work of Tommy
> Hofmann, he has several papers on this topic. If you don't care too much
> about efficiency, I think a solution that is reasonable to implement is to
> first parametrise the set of solutions of the linear equation (with mathnf
> or matsolvemod), and then backtrack the coefficients, for instance column by
> column, using the fact that for k columns to admit an extension to an nxn
> invertible matrix over Z, a necessary and sufficient condition is that their
> HNF must have k pivots equal to 1. There are also many quick necessary
> conditions, for instance M1 and M2 must be conjugate over Q and mod p for
> every p.
For 2x2 matrices, the program in attachment solves it.
M=[1,2;3,4];
N=[5,-2;-1,0];
P=isom(M,N)
M*P-P*N
matdet(P)
? P=isom(M,N)
%3 = [1,0;2,-1]
? M*P-P*N
%4 = [0,0;0,0]
? matdet(P)
%5 = -1
Over the rationals, the problem can be solved with matfrobenius(,1). Sometime
we are lucky and get an integral matrix.
M1 = [0, 1, 0, 0; -4, 0, 0, 0; 0, 0, 0, 1; 0, 0, -4, 0];
M2 = [0, 1, 4, 0; -4, 0, 0, -4; 0, 0, 0, 1; 0, 0, -4, 0];
[F1,P1]=matfrobenius(M1,2)
[F2,P2]=matfrobenius(M2,2)
P = P1^-1*P2
matdet(P)
M1*P-P*M2
? P = P1^-1*P2
%5 = [1,0,0,1;0,1,0,0;0,0,1,0;0,0,0,1]
? matdet(P)
%6 = 1
? M1*P-P*M2
%7 = [0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0]
So here P is the solution.
In general:
1) compute the matrix of the linear map P -> M1*P-P*M2
2) compute a basis of its integral kernel (K_1,...,K_r) with matkerint
3) solve the Diophantine equation matdet(sum x_i*K_i) = ±1 (with unknown x_1,...,x_r).
4) Return P = sum x_i*K_i
The difficult part is obviously 3).
For n=2, the Diophantine equation is a binary quadratic form, so can be solved by PARI.
Hofmann shows that solving the equation can be reduced to solve a set of
norm equations in orders of number fields.
Cheers,
Bill
isom(M,N)=
{
my(R=
[M[1,1]-N[1,1],M[2,1],-N[1,2],0;
M[1,2],M[2,2]-N[1,1],0,-N[1,2];
-N[2,1], 0, M[1,1]-N[2,2],M[2,1];
0,-N[2,1],M[1,2],M[2,2]-N[2,2]]);
my(K=matkerint(R),Kx=K*[x,1]~);
if(#K!=2,error(K));
my(P=matdet(Mat([Kx[1..2],Kx[3..4]])));
my(S);
if(P==1 || P==-1,
S = [0,1]~
, poldegree(P)==1,
my([u,v,d]=bezout(polcoeff(P,1),polcoeff(P,0)));
if(d!=1,return(0));
S=[u,v]~;
, my(Q=Qfb(Vec(P)));
my(s1=qfbsolve(Q,1),s2=qfbsolve(Q,-1));
S = if(s1,s1~,s2,s2~,return(0)));
S = K*S;
Mat([S[1..2],S[3..4]])~;
}
test()=
{
M=[1,2;3,4];
N=[5,-2;-1,0];
P=isom(M,N);
M*P-P*N
}