# Making a magic square matrix singular

14 Ansichten (letzte 30 Tage)
Feng Cheng Chang am 1 Apr. 2013
We know that any magic square matrix of odd order is not singular. When each element of the matrix is subtracted by the sum-average of the total elements, then this perturbed matrix becomes singular, and the determinant of the resulted matrix is zero. That is,
det(magic(n)-ones(n)*((1+n*n)/2)) = 0, for any odd n.
Can anyone help me the proof or find literture in this subject?
##### 8 Kommentare7 ältere Kommentare anzeigen7 ältere Kommentare ausblenden
Matt J am 2 Apr. 2013
Bearbeitet: Matt J am 2 Apr. 2013
But what for?
Well, it shows you that there are bad ways to compute determinants, even for integer matrices. The formula det(P)=prod(eig(P)) clearly doesn't work here very well, again because of precision issues.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Ahmed A. Selman am 1 Apr. 2013
I don't think details are required since
A=magic(n)-ones(n)*((1+n*n)/2)
is changed into an antisymmetric matrix, any such A matrix must satisfy (basic math.. etc)
det(A) = -1^n * det(A)
since n is odd, det(A) must be zero (thus, A is singular). Changing A from magic(n) to (magic(n)-ones(n)*((1+n*n)/2) ) as mentioned in the question is enough to destroy the symmetry of A.
Yet, since this is too basic, and it works the same for magic(n) with n is odd or even, (also, produces antisymmetric), I'm afraid you already know this. I tried (quickly, to be honest) other means like the nice arguments above, but didn't got anything useful so I thought to share, it might help. Regards.
##### 7 Kommentare6 ältere Kommentare anzeigen6 ältere Kommentare ausblenden
Matt J am 8 Apr. 2013
Bearbeitet: Matt J am 9 Apr. 2013
Ahmed,
We established several Comments ago that Aij=-Aji is not satisfied for the modified magic square matrix.
There may be a way to extend the determinant equation to the weirder kind of asymmetry that this matrix exhibits, but it looks like it would take some work. Showing that ones(n,1) is a null-vector of the matrix seems to me like the quicker proof, not to mention that it also covers even-valued n.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (3)

Jonathan Epperl am 1 Apr. 2013
The row-sum, column-sum and diag-sum of a magic square are all the same, and the magic square uses all the integeres 1:n^2. Thus, the sum of all elements must be n^2*(n^2+1)/2, and each row, column, diag sum must be n*(n^2+1)/2.
Now look at what you wrote, multiply it from the right by ones(n,1), and you'll see that you will get zero. Voila, thus the matrix is singular.
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Jonathan Epperl am 5 Apr. 2013
Bearbeitet: Jonathan Epperl am 22 Apr. 2013
Just to fill that hole in your knowledge: A square Matrix A is singular if and only if
• inv(A) does NOT exist
• det(A)==0
• The range of A is not all of R^n
• THE KERNEL OF A IS NONTRIVIAL
• ...
That last point there means that if you can find a nonzero vector v such that A*v==0, then you have proven that A is singular, and ones(n,1) is such a vector.

Melden Sie sich an, um zu kommentieren.

Matt J am 1 Apr. 2013
Bearbeitet: Matt J am 1 Apr. 2013
Let x=ones(n,1)/n and P be the perturbed matrix. You can verify that
P*x=0
proving that P is singular.
##### 5 Kommentare4 ältere Kommentare anzeigen4 ältere Kommentare ausblenden
Feng Cheng Chang am 2 Apr. 2013
Dear Matt J,
The result I got (by using OCTAVE within machine precession) is 0, but not -0.3211. I hope someone can verify it.
F C 04/01/2013

Melden Sie sich an, um zu kommentieren.

Feng Cheng Chang am 6 Apr. 2013
I have already accepted the expected simple answer from Ahmed A Selman, so I would like to conclude this "Question-Answer" contribution.
Also I would like to thank Walter Roberson, Matt J and Jonathan Epperl for the further extensive discussion related to the subject.
It gives me the great opportunity to find the interesting result unexpectedly. Hope anyone can see it.
For any n x n non-singular square matrix A, I can make it singular by perturbing the same amount to each of the matrix elements. That is
det(A-ones(n)/sum(sum(inv(A))) == 0
I would like to extend "the making a matrix singular" further to include the perturbation of any single element, any row or coulumn elements, or even the entire matrix elements in the prescribed distribution. Please watch my contribution in MATLAB Files Exchange in the near future.
For now, please try the followings:
for n=1:9, A=rand(n); P=A-1/sum(sum(inv(A))); detP=det(P); n,A,P,detP, end;
Best wishes,
Feng Cheng Chang 04/06/2013
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Linear Algebra finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by