Determinant of integer matrices
Afficher commentaires plus anciens
Is there a version of the det function in R2020a that alway gives determinant 0 for small singular integer matrices?
4 commentaires
Jan
le 23 Avr 2021
How do you define "small singular integer matrices"?
Rudolf Fruehwirth
le 23 Avr 2021
Rudolf Fruehwirth
le 23 Avr 2021
Matt J
le 23 Avr 2021
And it should work without prior knowledge whether the entries are integer or not. Probably asking too much...
No, one of hte answers below meets that requirement.
Réponses (2)
Since you know A is an integer matrix, can't you just do,
d=round(det(A));
3 commentaires
John D'Errico
le 23 Avr 2021
Modifié(e) : John D'Errico
le 23 Avr 2021
Really? I think you know better than that.
A = randi(10000,[9,10]);
A(end+1,:) = randi(10,[1,9])*A
A is purely integer.
We know that A is singular, since the last row is an integer linear combination of the first 9 rows, A is composed of purely integer entries.
det(A)
Will rounding the determinant prove successful?
round(det(A))
It does not look like 0 to me.
Admittedly, the question was about "small" matrices. But the above seems small to me. Is it? At what point does it become small?
Matt J
le 23 Avr 2021
OK. Well, maybe the A(i,j) are supposed to be "small" in mangitude as well...
A = randi(3,29,30);
A(end+1,:) = round(rand(1,29)*2-1)*A
rank(A)
det(A)
round(det(A))
Ok, I guess it works, some of the time. But not this one.
If the matrix is truly tiny, well yes.
A = magic(4)
rank(A)
det(A)
round(det(A))
But you really cannot trust that rounding the determinant will work unless things are truly tiny.
This might work,
A = randi(10000,[9,10]);
A(end+1,:) = randi(10,[1,9])*A;
determinant=double(det(sym(A)))
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!