I n d on e s i an   Jo u r n al   o El e c t r i c al   En gi n e e r i n g   an d   C o m p u te r   S c i e n c e   V o l .   20 ,   N o .   2 N o v e m b e r   20 20 ,   pp.   106 2 ~ 10 69   IS S N :   25 02 - 4752 ,   D O I :   10. 1 1591 / i j e e c s . v 20 .i 2 . pp 106 2 - 1069             1062       Jou r n al   h o m e pa ge ht t p: / / i j e e c s . i a e s c or e . c om   A   n e w   a l g o r i t h m   f o r   w a t e r   r e t e n t i o n   o n   m a g i c   sq u a r e       S h ath A .   S al m an ,   A m al   A . I b r ah i m   M a t he m a t i c s   a nd  C o m pu t e r   A ppl i c a t i o n,   A ppl i e S c i e nc e s ,   U n i v e r s i t y   o f   T e c hno l ogy ,   I r a q       A r ti c l e   I n fo     A B S TR A C T   Ar t i c l e   h i s t or y :   R e c e i v e A pr   20 ,   202 0   R e v i s e A pr   21 ,   2020   A c c e pt e M a y   5 ,   202 0       T he   a r t i c l e   de s c r i be s   n e w   a l g o r i t hm s   f o r   w a t e r   r e t e n t i o us i ng   m a g i c   s qua r e ,   ba s e o t he   pr o pe r t i e s   o f   m a g i c   s qua r e   w h i c i s   de f i n e a s   a n × n   m a t r i w i t h   po s i t i v e   e n t r i e s   e na b l i ng   t o   po ur i ng   a m o unt s   o f   w a t e r   o v e r   t he   m a g i c   s qua r e   a n m e a s ur i ng   t he   a m o unt   o f   w a t e r   t ha t   do e s   no t   l e a o ut   o f   t he   s qua r e .   T he   ne w   m e t ho e f f e c t i v e ne s s   e v a l u a t i o i s   c o nf i r m e b y   t he   c a l c ul a t i o i n   m a ny   a ppl i c a t i o ns ;   o ne   o f   t he m   i s   w a t e r   r e t e nt i o n.   Ke y w or d s :   A l go r i t h m     H e t e r o   m a gi c   s qu a r e   M a gi c   s qu a r e     U l t r a -   m a g i c   s qu a r e   W a t e r e t e n t i o n   C opy r i gh t   ©   2020   I n s t i t ut e   o f   A dv anc e E ng i ne e r i ng   and   S c i e nc e .     A l l   r i gh t s   r e s e r v e d .   Cor r e s pon di n g   Au t h or :   S ha t ha   A s s a a d   S a l m a n,   D e pa rt m e n t   o f   A ppl i e S c i e n c e s ,   U n i v e r s i t y   of   T e c hn o l o g y ,   Al - S i n a a   S t r e e t ,   B a g ha d a d,   I ra q .   E m a i l :   10017 8@ uo t e c hn o l o g y . e du. i q       1.   I N TR O D U C TI O N     M a gi c   s qua r e s   be i n a   m a t h e m a t i c a l   t h e m e   of   e n t e r t a i nm e nt   a t t r a c t e t h e   a t t e nt i o n   o f   m a n y   m a t h e m a t i c i a n s   a n t h e r e f o r e   m a gi c   s qua r e s   a r e   c o n s i de re a n   e xa m pl e   of   t h e   be a ut y   of   m a t h e m a t i c s   s ub j e c t s   a n h a v e   m a n y   a ppl i c a t i o n s   [1 - 6] .   T h e   f i r s t   m a gi c   s qua r e   i s   fo un i n   C hi na   a n i s   c a l l e L o   S h s qua r e   w h i c h   i s   a   s qua r e   m a t ri w i t po s i t i v e   i n t e ge r s   i w hi c a l l   t h e   l i n e s   ( r o w s ,   c o l um n ,   di a go n a l s )   a r e   e qua l   t o   t h e   s a m e   v a l ue .   T h e   m a gi c   s qu a r e s   a t t r a c t e w i de   a t t e nt i o n,   w hi c l e t o   t h e i t ra n s i t i o n   t o   I n di a ,   E u r o pe   a n t h e   Is l a m i c   w o r l i o r de r   t o   s t udy   t h e m   a n d   t o   kn o w   t h e i c h a ra c t e ri s t i c s .   T h e   p r e v a i l i n g   b e l i e t h e w a s   t h a t   t h e s e   s qua r e s   po s s e s s e m a gi c a l   p r o pe rt i e s   a n t h e r e f o r e   w e r e   l i n ke i m a n y   c ul t u r e s   b y   a s t r o l o g y   a n di v i n a t i o [7 - 9 ].   I n   r e c e n t   y e a r s   m a g i c   s qua r e s   ha v e   be e n   l i nke w i t h   w a t e r e t e nt i o n   t o   r e a c h   t h e   m a gi c   s qu a r e s   t ha t   t ra a s   m uc h   a s   po s s i b l e   of   w a t e r.   T h e   p r o b l e m   of   w a t e r   r e t e n t i o n   i s   t o   po u r   w a t e o a   c e r t a i n   s u r f a c e   a nd  c a l c ul a t e   t h e   a m o u n t   o f   w a t e r   t h a t   w i l l   s e t t l e   i n s i de   t h e   h o l e s   o f   t h a t   s u r f a c e .   T h e   r e s t   o t h e   e xc e s s   w a t e r   i s   l e a ki ng  t hr o ug h   t h e   e dge s ,   a n t h us   f i n d i n m a x i m u m   m a gi c   s qua r e   t h a t   r e t a i ni n w a t e r.   F i gu r e   1   i l l us t ra t e s   a   m a gi c   s qu a r e   w h o s e   h e i g ht   i s   de t e rm i n e by   t h e   v a l ue   w i t h i e a c h   c e l l .           F i gu r e   1 .   M a gi c   s qu a r e   r e p r e s e nt a t i o n   Evaluation Warning : The document was created with Spire.PDF for Python.
In do n e s i a J   E l e c   E ng  &   Co m S c i     IS S N :   2502 - 4752       A   n e w   al gor i t hm   f or   w at e r   r e t e nt i on   on   m agi c   s q uar e   ( Shat h A .   Sal m an )   1063   2.   WA TER   R E TEN TI O N   D ue   t o   t h e   i m po r t a n c e   of   w a t e r   i n   m a n y   a s pe c t s   o l i f e ,   i n   a ddi t i o n   t o   c l i m a t e   c h a n ge ,   i t   w a s   n e c e s s a r y   t o   f i n w a y s   t o   s t o r e   w a t e r   a nd  o n e   o f   t h e s e   m e t h o ds   a r e   s t o ra ge   o f   w a t e r   o n   t h e   m a t h e m a t i c a l   s ur f a c e s .   W a t e r   r e t e n t i o n   o n   m a g i c   s qua r e s   i s   o n e   o f   t h e   b e a ut i f ul   a pp l i c a t i o n s   o f   m a gi c   s qua r e   w h e r e     t h e   w a t e r   i s   s t o r e i n   t h e   m a gi c   s qua r e   by   ge n e r a t i ng  a   w a l l   s u rr o un ds   t h e   c e l l s   w i t h   t h e   s m a l l e s t   v a l ue s   i w h i c h   t h e   r e t e n t i o n   o f   w a t e r .   I t   w a s   r e po r t e f o r   t h e   f i r s t   t i m e   i 2007   by   K n e c h t .   I n   2010  a   c o m pe t i t i o w a s   o r ga ni z e t o   f i n t h e   m a g i c   s qua r e s   w h i c h   c a n   s t o r e   a s   m u c h   w a t e r   a s   po s s i b l e .   It   i s   p o s s i b l e   t de t e r m i n e     t h e   t o t a l   u ni t s   o f   w a t e r   t ra ppe by   f i n di ng  t h e   di f f e r e n c e   be t w e e n   e a c h   c e l l   w i t h i n   t h e   w a l l   w i t h   t h e   l o w e s t   v a l ue   of   t h e   w a l l   a n c o l l e c t   a l l   t h e   r e s ul t i n v a l ue s   t o   f i n t h e   t o t a l   v a l ue .   T h e   p r i n c i p l e   of   s t o r i n w a t e r   o n   m a g i c   s qua r e   do e s   n o t   de pe n o n   t h e   na t u ra l   m a gi c   s qua r e s ,   b ut   ov e r r i de s   i t   t o   o t h e r   t y pe s   of   m a gi c   s qua r e s ,   fo r   e xa m pl e   s e m i - m a g i c   s qua r e ,   pa n d i a go n a l   m a gi c   s qua r e ,   a s s o c i a t i v e   m a gi c   s qua r e   a n u l t ra - m a gi c   s qua r e   a s   s h o w n   i n   F i gu r e   2 .   F o r   m o r e   de t a i l s   a b o ut   t h i s   a p pl i c a t i o n   s e e   [ 10 - 16 ].   O t h e r   a ppl i c a t i o n s   a r e   a l s o   us e d   m a g i c   s qua r e   i c o m b i n a t o ri c s   [ 17 - 21 ]           F i g u re   2 .   ( a )   A s s o c i a t i v e   m a g i c   s q u a re   re t a i n i n g   5 6   u n i t s   o f   w a t e r   ( b )   S e m i   m a g i c   s q u a re   re t a i n i n g   4   u n i t s   o f   w a t e r       3.   S O M E   T Y P ES   O F   M A G I C   S Q U A R E   In  t hi s   s e c t i o s o m e   de f i n i t i o n s   a nd  t y pe s   fo r   t h e   m a gi c   s q ua re   a r e   gi v e n.       D e fi n i t i o n   (1). [ 22 ]   S e m i - m a gi c   s qua r e   i s   a   m a g i c   s qua r e   w h i c h   s a t i s f i e s   t h e   c o n d i t i o n   o f   m a gi c   e xc e pt   t h a t   t h e   s um   o o n e   o f   t h e   d i a go n a l s   or   b o t h   i s   n o t   e qu a l   t o   t h e   m a gi c   c o n s t a nt   a s   gi v e i F i gu r e   3 .       1   5   9   6   7   2   8   3   4     F i gu r e   3 .   S e m i   m a g i c   s qu a r e     D e fi n i t i o n   (2).   [ 23 ]   I a   s q u a re   m a t r i x   w hi c a c h i e v e d   t he   c o nd i t i o o f   a   na t u ra l   m a g i c   s q u a re   a nd   i a d d i t i o t he   s u m   o f   t he   b ro ke d i a g o n a l s   a re   e q u a l   t o   t he   m a g i c   c o ns t a n t   i t   i s   c a l l e d   a   p a nd i g o n a l   m a g i c   s q u a re   w hi c h   i s   g i v e i n   F i g u re   4 .           F i gu r e   4 .   P a ndi go n a l   m a gi c   s qu a r e   Evaluation Warning : The document was created with Spire.PDF for Python.
                                IS S N :   2502 - 4752   In do n e s i a J   E l e c   E ng  &   Co m S c i ,   V o l .   20 ,   N o .   2 N o v e m be r   20 20  :     10 62   -   10 69   1064   D e fi n i t i o n   (3).   [ 24 ]   A   n a t u r a l   m a gi c   s qu a r e   f o r   w hi c e a c h   p a i o f   n u m b e r s   i s   s y m m e t ri c   v e r s us   c e nt r e ,   s u m   t o       + i s   kn o w n   a s   a s s o c i a t i v e   m a g i c   s qua r e   a s   i F i gu r e   5 .       4   9   2   3   5   7   8   1   6     F i gu r e   5 .   A s s o c i a t i v e   m a gi c   s qu a r e       D e fi n i t i o n   (4).   S qua r e s   t ha t   a r e   b o t h   p a n   di a go na l   a n d   a s s o c i a t i v e   a r e   c a l l e d   ul t ra - m a gi c   a s   gi v e n   i F i gu r e   6 .           F i gu r e   6 .   U l t ra - m a gi c   s q ua r e       D e fi n i t i o n   (5).   [25 ]     H e t e r o   s qua r e   i s   s qu a r e   m a t ri x   w h o s e   e n t r i e s   po s i t i v e   n u m b e r s   f r o m   1   t o         s uc t ha t   t h e   s um   o f   r o w s ,   c o l um n s ,   a n d   di a go na l s   h a s   di f f e r e n t   s um s .   I t   c a b e   c o n s t r uc t e by   a rr a ngi n g   s uc c e s s i ve   i nt e ge r s   i a   s pi r a l   w a y   a s   i n   F i gu r e   7       9   8   7   2   1   6   3   4   5     F i gu r e 7 .   H e t e r o   s qua r e       4.   A N   A LG O R I TH M   F O R   B U I LD I N G   WA TER   R E TEN T I O N   O N   M A G I C   S Q U A R O F   O R D ER   7,   9,   11 ,   1 3.   T w o   a l go r i t hm s   a r e   gi v e n   i t hi s   s e c t i o f o r   m a gi c   s qu a r e s   o o r de r   7 ,   9,   11   a nd  1 3     A l go r i th m   1   In p ut :   m a g i c   s qu a r e   o f   o r de r     O ut put :   t h e   u ni t   o f   w a t e r   r e t e nt i o n   o n   m a g i c   s qu a r e .   S te p   1   T h e   f i r s t   a n d   l a s t   r o w s   a n t h e   f i r s t   a n d   l a s t   c o l um n s   a r e   a   w a l l   s u rr o u n d i n g   t h e   i nn e r   m a t r i x.   S te p   2   T h e   c o rn e r s   o f   t h e   i nn e r   m a t r i c a b e   de t e rm i n e us i n g   t h e   f o l l ow i n f o ur  f o r m ul a s .   a   =   m a x   (                     ,   m i n   (                     ,                     ))   b   =   m a x   (                     ,   m i n   (                     ,                 ))   c   =   m a x   (                     ,   m i n   (                     ,                 ))   =   m a x   (                   ,   m i n   (                 ,                 ))       Evaluation Warning : The document was created with Spire.PDF for Python.
In do n e s i a J   E l e c   E ng  &   Co m S c i     IS S N :   2502 - 4752       A   n e w   al gor i t hm   f or   w at e r   r e t e nt i on   on   m agi c   s q uar e   ( Shat h A .   Sal m an )   1065   S te p   3     T h e   c o r n e r s   o f   t h e   r o w   t h a t   d i v i de   t h e   i n t e rna l   m a t r i i nt o   t w o   e qua l   pa r t s   c a b e   fo un us i n g   t h e   f o l l ow i n fo r m u l a e .   e   =   m a x   (                     ,   m i n   (                     ,   a ,   b ))   f   =   m a x                     ,   m i (                 ,   c ,   d))   S te p   4     T h e   c o r n e r s   o f   t h e   c o l um n   t ha t   di v i de s   t h e   i n t e rn a l   m a t ri x   i n t o   t w o   e qua l   pa rt s   c a n   b e   de t e r m i n e us i n g     t h e   f o l l ow i n f o r m u l a s .   =   m a x                     ,   m i (                     ,   a ,   c ))   =   m a x                     ,   m i (                 ,   a ,   b ))   S te p   5   F i nd  t h e   pi l l a r s   o f   t h e   s e c o n c o l um n   o f   t h e   i nn e m a t r i x   a s   f o l l ow s .   i   =   m a x                     ,   m i n   (                   ,   a ,   b ))   j   =   m a x                     ,   m i n   (               ,   b ,   d))   S te p   6     F i nd  t h e   pi l l a r s   o f   t h e   f o ur t c o l um n   o f   t h e   i nn e m a t ri x   a s   f ol l o w s .   =   m a x   (                   ,   m i n   (                   ,   a ,   b ))   l   =   m a x   (                   ,   m i (               ,   a ,   c ))   S te p   7     F i nd  t h e   pi l l a r s   o f   t h e   s e c o n r o w   of   t h e   i nn e r   m a t r i x   a s   f o l l ow s .   m   =   m a (                   ,   m i (                   ,   c ,   d))   =   m a x   (                   ,   m i n   (               ,   c ,   d))   S te p   8   F i nd  t h e   pi l l a r s   o f   t h e   f o ur t r o w   of   t h e   i nn e m a t r i x   a s   f o l l ow s .   O   =   m a (                   ,   m i (                   ,   b ,   d ))   P   =   m a (                   ,   m i (               ,   b ,   d ))   S te p   9     F o r   t h e   c e l l s   t ha t   l i e   i t h e   c e n t r e   o f   t h e   i nn e m a t ri x   t h e r e   a re   t w o   s t e ps .   1.   F o r   t h e   m a i n   d i a go n a l   a n a l l   d i a go n a l s   pa ra l l e l   t o   i t ,   f i n d   t h e   g r e a t e s t   e l e m e nt   w i t t h e   e xc e pt i o n   o v a l ue s   t h a t   w e r e   p r e v i o us l y   e xt r a c t e d   2.   T h e   s a m e   p r o c e dur e   i s   f o l l ow e fo r   t h e   s e c o n di a go na l   a nd  t h e   pa ra l l e l   di a go n a l   f o r   i t .   By   us i n t h e   f o r m ul a   z   =   m a (                   ,   m i n   (g,   h,   e ,   f ))   W h i c h   v a ri e s   a c c o r di ng  t o   t h e   s e l e c t e c e l l ,   w h e r e                     i s   t h e   c e l l   l o c a t e d   i t h e   c e nt e a n d   (g ,   h,   e ,   f a r e   t h e   c o r n e r s   o f   t h e   r o w   a n d   c o l um t ha t   t h e   i n t e r s e c t i o n   o f   t h e m   i s   t h e   c e l l                 .   S te p   10   If                     i s   l e s s   t ha n                     t h e n   c o n s i de r                     t o   b e   a   b l oc i n   t h e   w a l l   a n i f                     i s   l e s s   t ha                   t h e c o n s i de r                     a s   a   b l o c i t h e   w a l l .   O t h e r w i s e   i f                     i s   l e s s   t ha t h e   b o t t h e t h e y   bo t c e l l   a r e   a   b l o c ks   i t h e   w a l l .   If                     i s   g r e a t e r   t h a b o t h   c e l l   t hi s   m e a n   t h a t   i t   i s   a   b l o c i t h e   w a l l .   S te p   11     If                     i s   l e s s   t ha n                     t h e n   c o n s i de r                     t o   b e   a   b l oc i n   t h e   w a l l   a n i f                     i s   l e s s   t ha               t h e c o n s i de r                 a s   a   b l o c i n   t h e   w a l l .   O t h e r w i s e   i f                     i s   l e s s   t ha n   b o t h   c e l l s   t h e n   t h e y   a r e   a   b l oc ks   i t h e   w a l l .   If                     i s   g r e a t e r   t h a b o t c e l l s   t hi s   m e a t ha t   i t   i s   a   b l o c i n   t h e   w a l l .   S te p   12   If                     i s   l e s s   t ha n                     t h e n   c o n s i de r                     t o   b e   a   b l oc i n   t h e   w a l l   a n i f                     i s   l e s s   t ha               t h e c o n s i de r                 a s   a   b l o c i n   t h e   w a l l .   O t h e r w i s e   i f                     i s   l e s s   t ha n   b o t h   c e l l s   t h e n   t h e y   a r e   a   b l oc ks   i t h e   w a l l .   If                     i s   g r e a t e r   t h a b o t c e l l s   t hi s   m e a t ha t   i t   i s   a   b l o c i n   t h e   w a l l .   S te p   13   If                     i s   l e s s   t ha n                 t h e n   c o n s i de r                 t o   b e   a   b l o c i n   t h e   w a l l   a n d   i f                     i s   l e s s   t ha n                 t h e c o n s i de r                 a s   a   b l o c i t h e   w a l l .   O t h e r w i s e   i f                     i s   l e s s   t ha b o t h   c e l l s   t h e t h e y   a r e   b l o c ks   i n   t h e   w a l l .   If                     i s   g r e a t e r   t ha n   b o t c e l l s   t h i s   m e a t ha t   i t   i s   a   b l oc i n   t h e   w a l l .   S te p   14   T h e   a m o unt   o f   w a t e r   t h a t   a r e   r e t a i n e d   i t h e   m a gi c   s qu a r e   a re   c a l c ul a t e by   f i n di n g   t h e   di f f e r e n c e   b e t w e e n   e ve r y   c e l l   t ha t   r e t a i n i ng  w a t e r   a n d   t h e   s m a l l e s t   v a l ue   i t h e   w a l l ,   a t   l e a s t   c a l c ul a t e   t h e   s um   o f   t h e m .       A l go r i th m   2   S te p   1   Co n s i de r   t h e   f i r s t   a n d   l a s t   r o w s   a n d   t h e   f i r s t   a nd  l a s t   c o l um n s   a s   a   w a l l   s u rr o u n d i n g   t h e   i nn e r   m a t r i x.   Evaluation Warning : The document was created with Spire.PDF for Python.
                                IS S N :   2502 - 4752   In do n e s i a J   E l e c   E ng  &   Co m S c i ,   V o l .   20 ,   N o .   2 N o v e m be r   20 20  :     10 62   -   10 69   1066   S te p   2   D i v i de   t h e   m a t ri x   i nt o   f o ur   pa rt s   a s   s h o w n .     A     C         B     D     S te p   3   T h e   c e l l s   o f   t h e   W a l l   t ha t   a r e   l o c a t e i n   p a r t   A   c a n   b e   de t e rm i n e us i n t h e   s a m e   m e t h o a s   i n   t h e   f o l l ow i n fo r m u l a   a nd  t h e   c o o r di n a t e s   c ha n ge   de pe n di n g   o t h e   l o c a t i o o f   t h e   s e l e c t e c e l l .   A   =   m a (        ,   m i (               )   S te p   4   T h e   c e l l s   i p a r t   B   a r e   de t e rm i n e d   us i ng  t h e   s a m e   w a y   a s   i t h e   f o l l ow i n g   f o r m ul a.   B   =   m a x   (      ,   m i (               )   S te p   5   T h e   c e l l s   i C   a r e   de t e r m i n e a s   i t h e   f o r m ul a .   =   m a x   (      ,   m i (               )   S te p   6   T o   f i n d   t h e   c e l l s   i D   us e   t h e   s a m e   m e t h o a s   i t h e   f o rm ul a .   D   =   m a (      ,   m i (               )   S te p   7   If          i s   l e s s   t ha        t h e c o n s i de r          a s   a   b l o c i n   t h e   w a l l   a n d   i f          i s   l e s s   t h a        t h e c o n s i de r          t o   b e   a   b l oc i n   t h e   w a l l   o t h e r w i s e   i f          i s   l e s s   t ha n   b o t c e l l s   t h e t he y   a r e   b l o c ks   i t h e   w a l l   i f          i s   g r e a t e t ha bo t c e l l s ,   t h i s   m e a t h a t   i t   i s   a   b l o c i t h e   w a l l .   S te p   8   If          i s   l e s s   t ha        t h e n   c o n s i de r          a s   a   b l o c i n   t h e   w a l l   a n d   i f          i s   l e s s   t h a        t h e n   c o n s i de r          t o   b e   a   b l oc i n   t h e   w a l l .   O t h e r w i s e   i f          i s   l e s s   t h a b o t c e l l s   t h e n   b o t h   c e l l s   a r e   b l o c ks   i t h e   w a l l   i f          i s   g r e a t e t h a b o t h   c e l l s   t hi s   m e a n   t h a t   i t   i s   a   b l o c i t h e   w a l l .   S te p   9   If          i s   l e s s   t ha        t h e c o n s i de r          t o   b e   a   b l o c i n   t h e   w a l l   a n d   i f          i s   l e s s   t h a        t h e n   c o n s i de r          a s   a   b l oc i n   t h e   w a l l .   O t h e r w i s e   i f          i s   l e s s   t h a b o t c e l l s   t h e n   b o t h   c e l l s   a r e   b l o c ks   i t h e   w a l l   i f          i s   g r e a t e t h a b o t h   c e l l   t hi s   m e a t ha t   i t   i s   a   b l o c i n   t h e   w a l l .   S te p   10   If          i s   l e s s   t ha        t h e n   c o n s i de r          a s   a   b l o c i n   t h e   w a l l   a n d   i f          i s   l e s s   t h a        t h e n   c o n s i de r          t o   b e   a   b l oc i n   t h e   w a l l .   O t h e r w i s e   i f          i s   l e s s   t ha n   b o t t h e b o t h   c e l l s   a r e   b l o c ks   i t h e   w a l l   i f          i s   g r e a t e r   t h a bo t c e l l s   t hi s   m e a t ha t   i t   i s   a   b l o c i n   t h e   w a l l .   T h e   l a s t   f o ur   s t e ps   a r e   o n l y   e xe c ut e fo r   t h e   c o o r di na t e s   l i s t e d.       5.   EX A M P LES     S o m e   e xa m pl e s   o f   w a t e r   r e t e n t i o n   a l go r i t h m s   us i ng  m a g i c   s q ua r e s   f o r   o r de r   5,   a n d   9 .   N o w   a n   e xa m pl e   f o r   A ppl y i n g   a l go ri t hm   1   i s   i nt r o duc e .   Ex am p l e   (1):   T o   f i nd  t h e   u ni t s   o f   w a t e r   r e t e n t i o o t h e   m a g i c   s qua r e   o f   o r de 7 .   S te p   1   Co n s i d e r   t h e   f i r s t   a n d   l a s t   r o w s   a n d   t h e   f i r s t   a nd  l a s t   c o l um n s   a s   a   w a l l   s u rr o u n d i n g   t h e   i nn e r   m a t r i x.       4   25   46   19   31   32   18   27   44   16   45   12   2   29   47   10   14   6   48   20   30   21   43   1   42   5   41   22   33   11   49   3   24   15   40   34   7   13   37   17   39   28   9   35   36   23   38   26   8       Evaluation Warning : The document was created with Spire.PDF for Python.
In do n e s i a J   E l e c   E ng  &   Co m S c i     IS S N :   2502 - 4752       A   n e w   al gor i t hm   f or   w at e r   r e t e nt i on   on   m agi c   s q uar e   ( Shat h A .   Sal m an )   1067   S te p   2     a   =   m a x   (4 4,   m i n   (25 ,   27 ))  =   44    b   =   m a x   (7 ,   m i (34 ,   35))   =   34   c   =   m a x   (2 ,   m i n   ( 32,   29) =   2 9   =   m a x   (39 ,   m i (2 8,   26))   =   39   S te p   3   e   =   m a x   (4 3,   m i n   (21 ,   44 ,   34))   =   43   f   =   m a x   (41 ,   m i (2 2,   29 ,   3 9))  =   41   S te p   4   =   m a x   (45 ,   m i (1 9,   44 ,   2 9))  =   45   =   m a x   (37 ,   m i (2 3,   44 ,   3 4))  =   37   S te p   5   i   =   m a x   (16 ,   m i n   ( 46,   44 ,   29))   =   29   j   =   m a x   (13 ,   m i n   ( 36,   34 ,   39))   =   34   S te p   6   =   m a x   (12 ,   m i (3 1,   44 ,   3 4))  =   31   l   =   m a x   (17 ,   m i n   ( 38,   44 ,   29))   =   29   S te p   7   m   =   m a (1 0,   m i (47 ,   2 9,   39))   =   29   =   m a x   (20 ,   m i (3 0,   29 ,   3 8))  =   29   S te p   8   o   =   m a x   (11 ,   m i (3 3,   34 ,   3 9))  =   33   =   m a x   (15 ,   m i (4 0,   34 ,   3 9))  =   34.   S te p   9   =   m a x   (42 ,   m i (4 5,   37 ,   4 3,   41))   =   42 .   =   m a x   (48 ,   m i (3 1,   29 ,   2 9,   29))   =   48 .   s   =   m a ( 49,   m i (29 ,   34,   33 ,   34))   =   49 .   S te p   10     44    25  a nd  2 7,   t hus   44   i s   b l o c i t h e   w a l l .     S te p   11       34  a n d   36 ,   t h us   36  a n d   34   a r e   b l o c ks   i n   t h e   w a l l .     S te p   12       32  a n d   29 ,   t h us   32  a n d   29   a r e   b l o c ks   i n   t h e   w a l l .     S te p   13   39    28  a nd  2 6,   t hus   39   i s   b l o c i t h e   w a l l .     S te p   14   (29  - 1 2)  +   ( 29  - 2)  +   (29   - 20)   =   53   (42    16)   +   (42     10)   +   (42     14)   +   (42     6)   +   (42     1)  =   163   (33    11)   +   (33     7)   +   (33     13)   =   68   (37    5)   +   (37     3)  +   (37     24)  +   (37     1 5)  +   (37     1 7)  =   121   U n i t s   =   53  + 163   +   68   +   12 =   4 05   i n   F i gu r e   8.       4   2 5   4 6   1 9   3 1   3 2   1 8   2 7   4 4   1 6   4 5   1 2   2   2 9   4 7   1 0   1 4   6   4 8   2 0   3 0   2 1   4 3   1   4 2   5   4 1   2 2   3 3   1 1   4 9   3   2 4   1 5   4 0   3 4   7   1 3   3 7   1 7   3 9   2 8   9   3 5   3 6   2 3   3 8   2 6   8     F i gu r e   8 .   M a gi c   s qu a r e   o f   o r de w i t 40 u ni t s   o f   r e t e nt i o n   Evaluation Warning : The document was created with Spire.PDF for Python.
                                IS S N :   2502 - 4752   In do n e s i a J   E l e c   E ng  &   Co m S c i ,   V o l .   20 ,   N o .   2 N o v e m be r   20 20  :     10 62   -   10 69   1068   N ow   a e xa m pl e   f o r   a pp l y i n a l go r i t hm   i s   i n t r o duc e .   Ex am p l e   (2):  To   f i nd  t h e   u ni t s   o f   w a t e r   r e t e n t i o o t h e   m a g i c   s qua r e   o f   o r de 5 ,   t h e   f o l l ow i n g   s t e ps   a r e   us e d   S te p   1   T h e   w a l l   o f   t h e   m a t r i x   i s   t h e   1 st   a n d   5 th   r o w   a n d   t h e   1 st   a n 5 th   c o l um n .   S te p   2     D i v i de   t h e   m a t ri x   i nt o   f o ur   pa rt s   a s   s h o w n .       1   2   0     4   4       1   5     3     9   8       5     0   7   6   3       S te p   3 :   f i n d   t h e   v a l ue   i b l o c A         =   m a x   (24 ,   m i (11 ,   14))                                                   =   24         =   m a x   (1,   m i (22 ,   24))                                                      =   22         =   m a x   (6,   m i (24 ,   15))                                                       =   15         =   m a x   (23 ,   m i (1 ,   6))                                                          =   23   S te p   4 :   f i n d   t h e   v a l ue   i b l o c B         =   m a x   (7,   m i (18 ,   17))                                                       =   17   S te p   5 :   f i n d   t h e   v a l ue   i b l o c C         =   m a x   (5,   m i (20 ,   21))                                                       =   20   S te p   6 f i n d   t h e   v a l ue   i b l o c D         =   m a x   (25 ,   m i (12 ,   13))                                                   =   25       1   2   0     4   4       1   5     3     9   8       5   2   0   7   6   3       T h e   w a l l   c e l l s   t ha t   a r e   c a l c ul a t e d   us i n g   t h e   a l go r i t hm .       T h e   b l o c f r o m   t h e   w a l l   t ha t   s u rr o u n d   t h e   i nn e r   m a t r i x.       T h e   c e l l   w hi c r e t a i n s   w a t e r.         Ca l c ul a t e   t h e   u ni t   o f   r e t a i n i ng  w a t e r   a s   f o l l ow   T h e   l o w e s t   v a l ue   i n   t h e   w a l l   i s   15   (15 - 1)+   (15 - 5)  +   (15 - 2)   +   (1 5 - 6)   +   (15 - 7 +   ( 15 - 3)     T h e   u ni t   o f   t h e   c e l l   t ha t   r e t a i n i ng  w a t e r   i s   66   u ni t s       6.   C O N C LU S I O N   M a gi c   s qua r e   i s   ve r y   i m po r t a n t   i n   m a n y   r e a l   l i f e   a ppl i c a t i o ns ;   o ur   w o r gi v e s   o n e   of  t h e i r   i m po rt a nt   a ppl i c a t i o n s   w h i c h   a r e   w a t e r   r e t e n t i o n.   N e w   a l go r i t hm s   a r e   w r i t t e n   f o r   m a g i c   s qua r e   o f   o r de r   t h e n   t h e   w o r w a s   e xpa n de d   t o   i n c l ude   a l l   o dd  m a g i c   s qua r e .           Evaluation Warning : The document was created with Spire.PDF for Python.
In do n e s i a J   E l e c   E ng  &   Co m S c i     IS S N :   2502 - 4752       A   n e w   al gor i t hm   f or   w at e r   r e t e nt i on   on   m agi c   s q uar e   ( Shat h A .   Sal m an )   1069   R EF ER EN C ES   [ 1]   A . A . A bi y e v ,   e t   al . ,   " I nv e s t i g a t i o o f   c e nt e r   o f   m a s s   by   us i ng   m a g i c   s qu a r e s   a nd   i t s   po s s i b l e   e ng i n e e r i ng   a ppl i c a t i o ns , "   R ob ot i c s   a nd   A u t onom o us   s y s t e m s v o l .   49 ,   no .   (3 - 4) pp .   219 - 2 26 ,   200 4.     [ 2]   L . H . C o x,   " B o unds   o e nt r i e s   i 3 - d i m e n s i o na l   c o nt i ng e nc y   t a bl e s   s u bj e c t   t o   g i v e m a r g i n a l   t o t a l s , "   I n f e r e nc e   C ont r ol   i S t a t i s t i c a l   D at a bas e s   -   F r om   T he or y   t P r ac t i c e .   L e c .   N ot .   C om p .   Sc i .   Sp r i n ge r ,   N e w   Y or k ,   s e r i e s   2316 pp.   21 33 ,   2002 .   [ 3]   A.   S.   S h a t h a , " C o m put a t i o o f   o dd  m a g i c   s qua r e   u s i ng   a   ne w   a ppr o a c w i t h   s o m e   pr o pe r t i e s , "   E ng .   &   T e c h.   J our nal ,   v o l .   30 ,   no .   7,   p p . 1 203 - 121 0,   20 12 .   [ 4]   A.   S.   S ha t h a ,   " S o m e   p r o pe r t i e s   o f   m a g i c   s qua r e s   o f   d i s t i nc t   s qua r e s   a nd  c ub e   m a g i c   s qu a r e s , "   Al - M us t an s i r i y ah   J our nal   o f   Sc i e nc e v o l .   30 ,   no .   3 , pp .   60 - 63 ,   201 9.   [ 5]   D.   X.   Z e ng ,   e t   al ,   " O v e r v i e w   o f   r ubi k’ s   c ube   a nd  r e f l e c t i o ns   o i t s   a ppl i c a t i o i m e c ha n i s m , "   C h i ne s e   J our n al   o f   M e c han i c a l   E ng i ne e r i ng ,   31 ,   no . 1,   pp . 7 7,   20 18.   [ 6]   N . O . S c hm i dt ,   " L a t i n   s qu a r e s   a n t he i r   a pp l i c a t i o ns   t o   c r y pt o g r a ph y , "   M S . C .   B oi s e   St at e   U n i v e r s i t y ,   2016 .     [ 7]   D . L . A nde r s o n,   " M a g i c   s qua r e s :   di s c ov e r i ng   t he i r   hi s t o r y   a nd  t he i r   m a g i c ,"   M a t he m at i c s   T e ac hi n i t he   M i dd l e   Sc hoo l ,   6 ,   no .   8,   pp . 4 66,   2 001 .   [ 8]   B.   L.   K a u l   a nd  R .   S i ng h,   " G e ne r a l i z a t i o o f   m a g i c   s qua r e   ( num e r i c a l   l o g i c )     a n i t s   m ul t i pl e s   (   3 ) × (   3) , "   I J   I n t e l l i ge nt   Sy s t e m s   and   A p pl i c a t i on s ,   v o l .   1,   pp .   90 - 97 ,   2 013 .   [ 9]   J . S e s i a no ,   " M a g i c   s qua r e s :   T he i r   h i s t o r y   a nd  c o ns t r uc t i o n   f r o m   a nc i e nt   t i m e s   t o   A D   1600 , "   S pr i nge r ,   2 019 .   [ 1 0 ]   S.   H .   J a m e l ,   e t   a l . ,   " S t e p s   f o r   c o n s t r u c t i n g   m a g i c   c u b e   u s i n g   t w o   o r t h o g o n a l   L a t i n   s q u a r e s   a n d   a   m a g i c   s q u a r e , "   In   P r o c e e d i n g   o f   M U C E E T   M a l a y s i a n   T e c h n i c a l   U n i v e r s i t i e s   C o n f e r e n c e   o n   E n g i n e e r i n g   a n d   T e c h n o l o g y ,   p p .   2 0 - 22 ,   2 0 0 9 .   [ 11]   N o r dg r e n,   R .   P . ,   " O pr o pe r t i e s   o f   s pe c i a l   m a g i c   s qua r e   m a t r i c e s , L i ne ar   A l ge br and  i t s   A p pl i c a t i ons ,   v o l . 43 7,     no .   8,   pp.   2 009 - 202 5 20 12 .   [ 12]   Ö f v e r s t e d t ,   J . ,   " W a t e r   r e t e n t i o o n   m a g i c   s qu a r e s   w i t h   c o ns t r a i n t - b a s e d   l o c a l   s e a r c h, "   U pps a l a   U ni v e r s i t y ,   2012 .   [ 13]   D.   B.   O j ha e t   al . " G e n e r a l i z a t i o o f     m a g i c   s qua r e , "   I n t e r na t i onal   J our na l   of   A p pl i e E ngi ne e r i ng  R e s e ar c h ,   v o l .   1,   no .   4,   p p. 7 06 ,   2010 .   [ 14]   M.   T r e nk l e r ,   " C o nne c t i o ns - m a g i c   s qua r e s ,   c ube s   a nd  m a t c hi ng s , "   A ppl i c a t i ons   o f   M ode r M a t he m at i c a l   M e t ho ds ,   L j ubl j ana ,   1911 99 ,   2 001 .   [ 15]   J r ,   T .   T r o t t e r ,   " N o r m a l   m a g i c   t r i a ng l e s   o f   o r de r   n ,"   J ou r na l .   of   R e c r e a t i o na l   M at he m at i c s ,   v o l .   5 ,   no . 1 ,     pp.   28 - 32 ,   197 2.   [ 16]   T.   R.   H a g e do r n,   " M a g i c   r e c t a ng l e s   r e v i s i t e d , D i s c r e t e   m at he m at i c s ,   v o l .   207 ,   no . 1 - 3,   p p.   65 - 72 ,   199 9.   [ 17]   J . A . D e   L o e r a ,   K i m ,   E . D . ,   O nn,   S .   a nd  S a n t o s ,   F . ,   " G r a ph s   o f   t r a n s po r t a t i o po l y t o pe s , "   J our nal   of   C om b i na t o r i al   T he or y ,   Se r i e s   A ,   v o l .   116 ,   no . 8 ,   pp .   1 306 - 132 5,   20 09 .   [ 18]   C.   A.   F l o uda s ,   " D e t e r m i ni s t i c   g l o ba l   o pt i m i z a t i o n:   t he o r y ,   m e t ho ds   a nd  a pp l i c a t i o ns , "   Sp r i n ge r   Sc i e nc e   &   B us i ne s s   M e di a ,   v o l .   37 ,   201 3.   [ 19]   J.   A.   L i ndo n,   " A nt i - m a g i c   s qu a r e s , M at he m at i c s v o l .   7 ,   pp. 16 - 19 ,   1962 .   [ 20]   T .   S .   M o t z ki n,   " T he   m u l t i - i nd e x   t r a n s po r t a t i o p r o bl e m ,"   B u l l .   A m e r .   M at h.   So c v o l .   5 8,   no .   4 ,   pp.   4 94,   1 952 .   [ 21]   L.   J .   M o r d e l l ,   " O n   s u m s   o f   t h r e e   c ub e s , "   J ou r n a l   o f   t he   L o nd o n   M a t h e m a t i c a l   S oc i e t y v o l   1 ,   no .   3 ,   p p . 1 3 9 - 1 4 4 ,   1 9 42 .   [ 22]     M.   M.   A hm e d ,   " A l g e br a i c   c o m bi na t o r i c s   o f   m a g i c   s qu a r e , "   P h . D .   t he s i s ,   U n i v e r s i t y   of   C a l i f o r ni a ,   2 004 .     [ 23]   W . S . A ndr e w s ,   " M a g i c   s qu a r e s   a nd   c ube s , "   C os i m o ,   I nc . ,   2004 .   [ 24]   B . A r o nov ,   e t   al . ,   " A   g e ne r a l i z a t i o o f   m a g i c   s qua r e s   w i t h   a pp l i c a t i o ns   t o   d i g i t a l   h a l f t o ni ng , "   T he or y   o f   C om pu t i ng   Sy s t e m s ,   v o l .   42 ,   no .   2,   pp . 1 43 - 156 ,   2008 .   [ 25]   J.   S.   M a d a c hy ,   " M a da c hy ' s   m a t he m a t i c a l   r e c r e a t i o ns " D ov e r   P ub l i c at i on s ,   19 79 .       B I O G R A P H I ES   O F   A U T H O R S       S h at h a   S a l m an   i s   P h . D .   de g r e e   f r o m   A l - N a hr a i n   U ni v e r s i t y   i 20 05.   S he   h a s   be c o m e   a s s i s t a n t   pr o f e s s o r   o N ov e m be r   2005 .   H e r   M a s t e r   o f   A ppl i e M a t h e m a t i c s   f r o m   U ni v e r s i t y   of   T e c hno l o gy   I r a ( 1995 ) .   S he   o bt a i n e B a c he l o r   D e g r e e   i A ppl i e M a t he m a t i c s   f r o m   U ni v e r s i t y   of   T e c hno l o gy   ( I r a q)   i 19 90 .   H e r   r e s e a r c he s   a r e   i f i e l ds   o f   G e o m e t r i c   C o m bi nt o r i c s ,   A bs t r a c t   A l g e br a ,   G r a ph  t h e o r y ,   D i f f e r e nt i a l   E q ua t i o ns   O r di n a r y   a nd  F r a c t i o na l ,   N um e r i c a l   A na l y s i s   a nd   C o m pl e x   A na l y s i s .   A s   w e l l ,   s he   ha s   be e n   a   m e m be r   o f   I r a qi   o f   S c i e nt i f i c   c o m m i t t e e   s i nc e   1 995 .   S he   ha s   s e r v e d   a s   i nv i t e d   r e v i e w e r .   S h e   ha s   04   p ubl i s he d   a r t i c l e s   i n s i de   I r a a nd  s o m e   i i n t e r na t i o na l   j o ur na l s ,   pub l i s he d   bo o ks   i G e r m a ny .   F ur t h e r   i nf o   o hi s   s c ho l a r g o og l e .   ht t ps : / / s c ho l a r . g o og l e . c o m / c i t a t i o ns ? us e r = _W bhH y Q A A A A J & hl = e n& a ut hus e r = 1                                    G r a du a t e   o f   t he   U n i v e r s i t y   o f   T e c hno l ogy ,   D e pa r t m e n t   o f   A ppl i e d   S c i e nc e s ,   M a t he m a t i c s   B r a nc h,   C o m put e r   A ppl i c a t i o ns   2015 , S h e   o bt a i n e d   a   m a s t e r ' s   de g r e e   f r o m   t he   D e pa r t m e n t   o f   A ppl i e S c i e nc e s ,   M a t h e m a t i c s   B r a nc o f   C om put e r   A ppl i c a t i o ns   2 019 .     H e r   r e s e a r c he s   a r e   i f i e l d s   o f   G e o m e t r i c   C o m bi nt o r i c s ,   A bs t r a c t   A l g e br a ,   G r a ph  t h e o r y ;   S he   ha s   s o m e   p ubl i s he d   a r t i c l e s   i n s i d e   I r a q   a n s o m e   i n   i n t e r na t i o na l   j o u r na l s .     Evaluation Warning : The document was created with Spire.PDF for Python.