Main Page | Report this Page
Science Forum Index  »  Mathematics Forum  »  Odd order Magic square with 0 Determinant...
Page 1 of 1    

Odd order Magic square with 0 Determinant...

Author Message
AI...
Posted: Sun Nov 01, 2009 4:11 am
Guest
Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?
 
Libra/Virgo...
Posted: Sun Nov 01, 2009 5:21 am
Guest
# Use it from top level of repository, and specify name one
# or more patches you wish to see webrevs of.
#
# Implementation
# --------------
# It works by it takes a temporary clone of the parent repository, and
pushes
# patches up to the specified patch in the series. Then, using a list
of the
# files the specified patch modifies, it copies these to a new
temporary repository.
#
# This new (probably small) repository is then cloned, and the same
list of
# files from the current repository are copied to this repo and
committed.
#
# Finally, we invoke webrev on this temporary repository against it's
# parent.

REAL_CHILD=$(pwd)

# FIXME need to make sure this version of hg has support for "qgoto"
HG=/usr/bin/hg
QUIET="-q"
# setting this to a non-empty string makes the script emit more
messages
DEBUG=""
# XXX hardcoding the path to webrev here is probably wrong
WEBREV=/ws/onnv-tools/onbld/bin/webrev

# write an awk script that can print deleted and added files
# from a given patch
function write_deleteadd_script {

cat > /tmp/patch_webrev.$$.awk <<EOF
#!/bin/nawk -f

# This awk scripts patch files, printing which files were
# added and deleted from the new area.

# An example record:

#diff --git a/newfile b/newfile
#new file mode 100644
#--- /dev/null
#+++ b/newfile
# at (no spam) at (no spam) -0,0 +1,1 at (no spam) at (no spam)
# at (no spam) diff --git a/deleteme b/deleteme
#deleted file mode 100644
#--- a/deleteme
#+++ /dev/null
# at (no spam) at (no spam) -1,1 +0,0 at (no spam) at (no spam)

BEGIN {
seen_deleted=0
seen_added=0
}

/^deleted file mode [0-9]+\$/ {
seen_deleted=1
# set \$0 to be the next line
getline
}

/^new file mode [0-9]+\$/ {
seen_added=1
# set \$0 to be 2 lines further down
getline
getline
}

{
if (seen_added==1){
added_file=\$NF
len=length(added_file)
print "added "substr(added_file,3,len-2)
seen_added=0
}

if (seen_deleted==1){
deleted_file=\$NF
len=length(deleted_file)
print "deleted "substr(deleted_file,3,len-2)
seen_deleted=0
}
}
EOF
chmod 755 /tmp/patch_webrev.$$.awk
}

function usage {
echo "patch-webrev.ksh <patch> [ <patch2> <patch2> ... patchn>"
exit 1
}

function log_debug {
if [ -n "$DEBUG" ] ; then
echo $ at (no spam)
fi
}


# print a list of files that given patch modifies
function changed_files {
ws=$1
patch=$2
if [ ! -f $ws/.hg/patches/$patch ]
then
echo "ERROR changed_files() unable to find $ws/.hg/patches/$patch"
exit 1
fi
LIST=$(/usr/xpg4/bin/grep -e +++ -e --- $ws/.hg/patches/$patch \
| awk '{print $2}' | sed -e 's,^a/,,g;s,^b/,,g' | grep -v /dev/null
| sort -u)
echo $LIST
}

# print a list of files that a given patch deletes
function deleted_files {
ws=$1
patch=$2
echo $(cat $ws/.hg/patches/$patch | /tmp/patch_webrev.$$.awk | grep
"^deleted " | awk '{print $2}')
}

# print a list of files that a given patch adds
function added_files {
ws=$1
patch=$2
echo $(cat $ws/.hg/patches/$patch | /tmp/patch_webrev.$$.awk | grep
"^added " | awk '{print $2}')
}

if [ $# -lt 1 ] ; then
usage
fi

MODIFIED=$($HG status | /usr/xpg4/bin/grep -e ^M -e^\\?)
if [ -n "$MODIFIED" ]
then
echo "WARNING: uncommitted changes $MODIFIED appear in $REAL_CHILD"
fi


OUTGOING_DESC=$($HG -R ${REAL_CHILD}/.hg/patches outgoing --template
'{desc}')
if [ -z "${OUTGOING_DESC}" ]
then
echo "ERROR: no outgoing changes in ${REAL_CHILD}/.hg/patches"
exit 1
fi

# quick sanity check
for PATCH in $ at (no spam) ; do
if [ ! -f .hg/patches/$PATCH ]
then
echo "Unable to find $REAL_CHILD/.hg/patches/$PATCH"
echo "Are you running this script from the top of the
workspace?"
exit 1
fi
done

# get the parent gate
PARENT=$( $HG paths | grep default | awk -F= '{print $2}' | sed -e 's/
^ //g')


TMP=/tmp/patch-webrev.$$
mkdir -p $TMP
mkdir $TMP/parent
cd $TMP/parent
$HG $QUIET init

log_debug "Making a qclone of $PARENT to $TMP/real-parent.hg"
$HG $QUIET qclone $PARENT $TMP/real-parent.hg

cd $REAL_CHILD
for PATCH in $ at (no spam) ; do
CHANGED_FILES=$(changed_files $REAL_CHILD $PATCH)

cd $TMP/real-parent.hg
log_debug "going to $PATCH in $TMP/real-parent.hg"
$HG $QUIET qgoto $PATCH
if [ $? -ne 0 ] ; then
# XXX difficult to know what to do here, should probably
# push the parent up to the patch one level beneath
# where the new patch in the child is, iterating if that
# patch isn't in the parent either
echo "Warning $PATCH not in parent, pushing all patches instead"
$HG qpush -a
fi

# divorcing parent from real-parent.hg by creating a new temp
workspace
(tar cf - $CHANGED_FILES ) | (cd $TMP/parent ; tar xf -)
# now pop those patches out again so we can deal with the next patch
$HG $QUIET qpop -a
cd $TMP/parent
$HG $QUIET add
$HG $QUIET -R $TMP/parent commit -m "State of $PARENT at patch
$PATCH"
done


write_deleteadd_script

# Now clone a child from this parent
log_debug "Cloning $TMP/parent to $TMP/child"
$HG $QUIET clone $TMP/parent $TMP/child

for PATCH in $ at (no spam)
do

CHANGED_FILES=$(changed_files $REAL_CHILD $PATCH)
DELETED_FILES=$(deleted_files $REAL_CHILD $PATCH)
ADDED_FILES=$(added_files $REAL_CHILD $PATCH)
cd $REAL_CHILD
log_debug "Copying changes from $REAL_CHILD to $TMP/child"
(tar cf - $CHANGED_FILES) | (cd $TMP/child ; tar xf - )
cd $TMP/child
if [ -n "$DELETED_FILES" ] ; then
$HG remove $DELETED_FILES
fi
if [ -n "$ADDED_FILES" ] ; then
$HG add $ADDED_FILES
fi
$HG $QUIET -R $TMP/child commit -m "${OUTGOING_DESC}"

done

log_debug "At this stage, we can use webrev in $TMP/child"
log_debug "For example here are outgoing changes in $TMP/child:"
$HG -R $TMP/child outgoing -p

log_debug "Once you're finished with $TMP, you should delete it."
rm /tmp/patch_webrev.$$.awk

log_debug "Generating webrev for you"
THISDIR=$(pwd)
cd $TMP/child
$WEBREV
if [ ! -d "${REAL_CHILD}/webrev" ] ; then
cp -r webrev $REAL_CHILD
cd $REAL_CHILD
rm -rf $TMP
else
echo "webrev directory already exists in $REAL_CHILD - not
overwriting it."
echo "your webrev is at $TMP/child/webrev."
fi
On Nov 1, 7:11 am, AI <vcpan... at (no spam) gmail.com> wrote:
[quote]Can you find any Odd order Magic square with 0 Determinant or Prove
that such
algorithm for generating odd-order magic sq exist[/quote]
This simple algorithm can generate a magic square of any odd size. ...
if(not $n % 2) { die "$n is not odd.\n"; } $x = int($n/2); $y = 0; my
at (no spam) S; ...
everything
Odd Magic Squares
\ { z[3]=z[1]; //150 IF N(Z5)<>0 THEN Z3=Z1:Z4=(Z2+1)-(Z6*X) ....
Order of Magic Square (Mode Screen Limit: 19) ODD-NUMBER: 4. ODD-
NUMBER: 9
Constructing odd order magic
squares.CommonsConstructing_odd_order_magic_squares.png‎ (373 × 191
pixels, ...
/File:Constructing_odd_order_magic_squares.png
Odd Magic Squares
The square told the people how big their sacrifice needed to be
in order to save ... For example, a 3x3 magic square would start like
so: 0 1 0 0 0 0 0 0 0 ...
CodeToad - Visual Basic Odd Magic Square .
8 posts - 7 authors - Last post: Jul 23, 2003
Top = 0 Grid.Rows = N Grid.Cols = N Me.Caption = "Odd Magic " _
& " Order : " & Str(N) Call MagicSquare End Sub ...
Magic Square -- and break vector (0, 1). In order for this
to produce a magic square, each break move ... A second method for
generating magic squares of odd order has been ...
: Magic square (odd order)
The last part of the procedure starting with 1 := 0; which ....
The procedure generated odd-order magic squares satisfactorily. For
orders up to 9, ...
Magic squares of any odd order can be constructed following a
pattern very ... 48 16 32 16 32 48 0 48 0 32 16 32 16 0 48 0 48 16 32
16 32 48 0 48 0 32 16 32 ...
... The "De La Loubere" rule for generating odd order magic
squares requires ... If we consider the numbers in a magic square
running from 0 to ...
A magic square of odd order n contains the integers from 1
to n2, ... all values in the square to zero for (i=0;i<n;i++) for
(j=0;j<n;j++) mSquare[i][j]=0; ...

#!/bin/ksh

# This script is a bit of a hack to allow us to use webrev on
MeAmI.org
# workspaces use MQ. Specifically, this allows us to more easily see
# the changes made over two versions of the same patch where
# patch is not at top level of qapplied.
# at (no spam) magic web http://www.meami.org

Thanks!
 
AI...
Posted: Sun Nov 01, 2009 5:50 pm
Guest
Great!!! Thank you Ken Pledger for that magic square. I think odd
order regular magic square from 1 to n with 0 determinant does not
exist but others (such as you have given) exists.

A Special Thanks to Gerry Myerson for interesting references.
 
Gerry Myerson...
Posted: Sun Nov 01, 2009 9:25 pm
Guest
In article
<2f23e44b-1b92-4aa2-b503-072b285f38c1 at (no spam) h40g2000prf.googlegroups.com>,
AI <vcpandya at (no spam) gmail.com> wrote:

[quote]Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?
[/quote]
See Peter Loly, Ian Cameron, Walter Trump, Daniel Schindel,
Magic square spectra, Linear Algebra and its Applications
430 (2009) 2659-2680. The abstract says, in part,

Mattingly also proved that odd order regular magic squares have a zero
eigenvalue with even multiplicity, m=0,2,4,... Analyzing results for
natural fifth order magic squares from exact backtracking calculations
we find 652 with m=2, and four with m=4.

--
Gerry Myerson (gerry at (no spam) maths.mq.edi.ai) (i -> u for email)
 
Ken Pledger...
Posted: Sun Nov 01, 2009 10:09 pm
Guest
In article
<2f23e44b-1b92-4aa2-b503-072b285f38c1 at (no spam) h40g2000prf.googlegroups.com>,
AI <vcpandya at (no spam) gmail.com> wrote:

[quote]Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?
[/quote]

13 14 11

15 22 1

10 2 26


Ken Pledger.
 
AI...
Posted: Sun Nov 01, 2009 10:10 pm
Guest
On Nov 2, 10:10 am, Gerry Myerson <ge... at (no spam) maths.mq.edi.ai.i2u4email>
wrote:
[quote]In article
ken.pledger-55F3B8.16094402112... at (no spam) news.eternal-september.org>,
 Ken Pledger <ken.pled... at (no spam) mcs.vuw.ac.nz> wrote:

In article
2f23e44b-1b92-4aa2-b503-072b285f3... at (no spam) h40g2000prf.googlegroups.com>,
 AI <vcpan... at (no spam) gmail.com> wrote:

Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?

13   14   11

15   22    1

10    2   26

That's what I'd call a semi-magic square - the rows and columns work,
but not the diagonals.

Also, I took OP to mean using the numbers 1, 2, ..., n^2,
each exactly once.

--
Gerry Myerson (ge... at (no spam) maths.mq.edi.ai) (i -> u for email)
[/quote]

Yes you are right, That's why I have mentioned it is not a regular
magic square.

BTW I tried to find reference but could not find proof.
 
Gerry Myerson...
Posted: Mon Nov 02, 2009 12:10 am
Guest
In article
<ken.pledger-55F3B8.16094402112009 at (no spam) news.eternal-september.org>,
Ken Pledger <ken.pledger at (no spam) mcs.vuw.ac.nz> wrote:

[quote]In article
2f23e44b-1b92-4aa2-b503-072b285f38c1 at (no spam) h40g2000prf.googlegroups.com>,
AI <vcpandya at (no spam) gmail.com> wrote:

Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?


13 14 11

15 22 1

10 2 26
[/quote]
That's what I'd call a semi-magic square - the rows and columns work,
but not the diagonals.

Also, I took OP to mean using the numbers 1, 2, ..., n^2,
each exactly once.

--
Gerry Myerson (gerry at (no spam) maths.mq.edi.ai) (i -> u for email)
 
Gerry...
Posted: Mon Nov 02, 2009 1:51 am
Guest
On Nov 2, 7:10 pm, AI <vcpan... at (no spam) gmail.com> wrote:
[quote]On Nov 2, 10:10 am, Gerry Myerson <ge... at (no spam) maths.mq.edi.ai.i2u4email
wrote:





In article
ken.pledger-55F3B8.16094402112... at (no spam) news.eternal-september.org>,
 Ken Pledger <ken.pled... at (no spam) mcs.vuw.ac.nz> wrote:

In article
2f23e44b-1b92-4aa2-b503-072b285f3... at (no spam) h40g2000prf.googlegroups.com>,
 AI <vcpan... at (no spam) gmail.com> wrote:

Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?

13   14   11

15   22    1

10    2   26

That's what I'd call a semi-magic square - the rows and columns work,
but not the diagonals.

Also, I took OP to mean using the numbers 1, 2, ..., n^2,
each exactly once.

--
Gerry Myerson (ge... at (no spam) maths.mq.edi.ai) (i -> u for email)

Yes you are right, That's why I have mentioned it is not a regular
magic square.

BTW I tried to find reference but could not find proof.
[/quote]
Do you mean you found the reference but the proof wasn't in it?
Or do you mean you tried to find the reference but you couldn't?

You might try finding contact details for one of the authors,
then ask him if he can send you the paper. Or just an example,
if that's all you need.
--
GM
 
AI...
Posted: Mon Nov 02, 2009 7:07 pm
Guest
On Nov 2, 4:51 pm, Gerry <ge... at (no spam) math.mq.edu.au> wrote:
[quote]On Nov 2, 7:10 pm, AI <vcpan... at (no spam) gmail.com> wrote:





On Nov 2, 10:10 am, Gerry Myerson <ge... at (no spam) maths.mq.edi.ai.i2u4email
wrote:

In article
ken.pledger-55F3B8.16094402112... at (no spam) news.eternal-september.org>,
 Ken Pledger <ken.pled... at (no spam) mcs.vuw.ac.nz> wrote:

In article
2f23e44b-1b92-4aa2-b503-072b285f3... at (no spam) h40g2000prf.googlegroups.com>,
 AI <vcpan... at (no spam) gmail.com> wrote:

Can you find any Odd order Magic square with 0 Determinant or Prove
that such Magic Square does not exist?

13   14   11

15   22    1

10    2   26

That's what I'd call a semi-magic square - the rows and columns work,
but not the diagonals.

Also, I took OP to mean using the numbers 1, 2, ..., n^2,
each exactly once.

--
Gerry Myerson (ge... at (no spam) maths.mq.edi.ai) (i -> u for email)

Yes you are right, That's why I have mentioned it is not a regular
magic square.

BTW I tried to find reference but could not find proof.

Do you mean you found the reference but the proof wasn't in it?
Or do you mean you tried to find the reference but you couldn't?

You might try finding contact details for one of the authors,
then ask him if he can send you the paper. Or just an example,
if that's all you need.
--
GM
[/quote]
Thanks, I have mailed the author. Let's see if he replies.

Regards,
AI
 
Gerry Myerson...
Posted: Tue Nov 03, 2009 6:12 pm
Guest
In article
<41eb9283-dba3-44a1-9ee0-bfd27914b0e6 at (no spam) y32g2000prd.googlegroups.com>,
AI <vcpandya at (no spam) gmail.com> wrote:

[quote]On Nov 2, 4:51 pm, Gerry <ge... at (no spam) math.mq.edu.au> wrote:
On Nov 2, 7:10 pm, AI <vcpan... at (no spam) gmail.com> wrote:


BTW I tried to find reference but could not find proof.

You might try finding contact details for one of the authors,
then ask him if he can send you the paper. Or just an example,
if that's all you need.

Thanks, I have mailed the author. Let's see if he replies.
[/quote]
If he does, I hope you'll report back to this newsgroup.

--
Gerry Myerson (gerry at (no spam) maths.mq.edi.ai) (i -> u for email)
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Sat Dec 12, 2009 12:51 am