The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A160523 a(n) is the determinant of the matrix returned by the MATLAB command magic(n). 1

%I #33 May 17 2023 13:01:50

%S 1,-10,-360,0,5070000,0,-348052801600,0,75035738059027200,0,

%T -41037749689303977660600,0,46138065481819513248350194800,0,

%U -95867954490405704140800000000000000,0,343347181141827635973213833586893432832000,0,-1962493419491568854064862681564905921231239717640,0

%N a(n) is the determinant of the matrix returned by the MATLAB command magic(n).

%C The MATLAB command is only supposed to be used when n >= 3. For n=2 it returns a non-magic square (none exist) with determinant -10.

%C [The MATLAB help page says: M = magic(n) returns an n-by-n matrix constructed from the integers 1 through n^2 with equal row and column sums. The order n must be a scalar greater than or equal to 3.]

%C From _Robert Israel_, Oct 27 2015: (Start)

%C For n >= 3, a(n) = 0 if and only if n is even.

%C a(n) is divisible by n^(n-2), because for odd n, magic(n) is the sum of an integer matrix of rank 2 and a matrix with entries divisible by n.

%C It appears that a(n) is divisible by n^(n-1). (End)

%H Robert Israel, <a href="/A160523/b160523.txt">Table of n, a(n) for n = 1..210</a>

%H MathWorks, <a href="http://www.mathworks.com/help/matlab/ref/magic.html">MATLAB help file for magic</a>.

%e n=3: magic(3) = [8 1 6 / 3 5 7 / 4 9 2 ], det(magic(3)) = 8*(5*2-7*9) - 1*(3*2-4*7) + 6*(3*9-4*5) = -360.

%p f:= proc(n)

%p if n::even then if n = 2 then return(-10) else return(0) fi fi;

%p LinearAlgebra:-Determinant(Matrix(n,n,(i,j) -> n*(i + (j - (n+3)/2) mod n) + (i + (2*j-2) mod n) + 1))

%p end proc:

%p seq(f(i), i=1..30); # _Robert Israel_, Oct 27 2015

%t a[n_] := Which[n == 2, -10, EvenQ[n], 0, True, Det@Table[ n*Mod[i + (j - (n+3)/2), n] + Mod[i + (2j-2), n] + 1, {i, n}, {j, n}]];

%t Table[a[n], {n, 1, 20}] (* _Jean-François Alcover_, May 17 2023, after _Robert Israel_ *)

%o (MATLAB) det(magic(n));

%K sign

%O 1,2

%A Magnus Bjerkeng (bjerkeng(AT)stud.ntnu.no), May 17 2009

%E Edited by _N. J. A. Sloane_, May 17 2009

%E Further edits by _Robert Israel_ and _N. J. A. Sloane_, Oct 27 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 19 10:22 EDT 2024. Contains 372683 sequences. (Running on oeis4.)