Find invertible matrix pairs where both matrices are integers

1 ビュー (過去 30 日間)
Douglas Anderson
Douglas Anderson 2022 年 1 月 7 日
コメント済み: John D'Errico 2022 年 1 月 8 日
Hello!
I think the summary says it all! Looking for 3x3, but assume that's not critical.
Have found solution for matrix pair where one is integer, but other is not.
Thanks!
Doug Anderson
  3 件のコメント
Douglas Anderson
Douglas Anderson 2022 年 1 月 7 日
I have a method to generate a matrix of integer elements, i.e., doubles that look like integers! I know you can't invert a true integer matrix, AND "isinteger" only identifies if it's a true integer class. Is there a method to say that this is an integer "for all practical purposes"?
This is for security software. Have the matrix I posted, just looking for others. It's been working well.
Again, thanks.
Doug

サインインしてコメントする。

採用された回答

John D'Errico
John D'Errico 2022 年 1 月 7 日
編集済み: John D'Errico 2022 年 1 月 7 日
It seems trivial.
A = eye(3)
A = 3×3
1 0 0 0 1 0 0 0 1
inv(A)
ans = 3×3
1 0 0 0 1 0 0 0 1
Both are entirely integer. As it turns out, A is idempotent, so it is its own inverse, but that was not expressed as an issue.
But surely you are asking about other matrices, that are also fully integer, yet have an all-integer inverse? This too should be entirely doable. The trick is to consider how to create them.
N = 3;
M = 5;
L = tril(randi(2*M,[N,N])-M,-1) + eye(N)
L = 3×3
1 0 0 1 1 0 1 -4 1
A = L*L'
A = 3×3
1 1 1 1 2 -3 1 -3 18
format long g
inv(A)
ans = 3×3
27 -21 -5 -21 17 4 -5 4 1
So A is a fully integer randomly created matrix. It has the property of a fully integer inverse. (if we ignore the crap that sometimes arise in the least significant bits of the inverse. They are just due to floating point trash.) If you wish to know why this works, look carefully at how I created the matrix. Look carefully at the matrix L.
A nice property of this creation scheme, is it will work for any size of matrix A. Just change the value of N. As well, it will be blazingly fast, requiring no solve.
  1 件のコメント
John D'Errico
John D'Errico 2022 年 1 月 8 日
An interesting question about an integer valued matrix where the inverse is also integer valued, is if the eigenvalues must all be 1.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 1 月 7 日
syms v
M = [1 2 3; 4 5 7; 8 9 v]
M = 
sol = solve(det(M) == 1)
sol = 
12
newM = subs(M, v, sol(1))
newM = 
inv(newM)
ans = 
  1 件のコメント
Douglas Anderson
Douglas Anderson 2022 年 1 月 7 日
Thank you, Walter, but I don't have the symbolic math toolbox!

サインインしてコメントする。

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by