Saved in:
Bibliographic Details
Main Authors: Pamplona, João Vitor, Pinheiro, Maria Eduarda, Santos, Luiz-Rafael
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2504.20017
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866918272523304960
author Pamplona, João Vitor
Pinheiro, Maria Eduarda
Santos, Luiz-Rafael
author_facet Pamplona, João Vitor
Pinheiro, Maria Eduarda
Santos, Luiz-Rafael
contents Magic squares are a fascinating mathematical challenge that has intrigued mathematicians for centuries. Given a positive (and possibly large) integer \( n \), one of the main challenges that still remains is to find, within a computational time, a magic square of order \( n \), that is, a square matrix of order \( n \) with unique integers from \( a_{\min} \) to \( a_{\max} \), such that the sum of each row, column, and diagonal equals a constant \( \mathcal{C}(A) \). In this work, we first present an integer constraint satisfaction problem for constructing a magic square of order \( n \). Nonetheless, the solution time of this problem grows exponentially as the order increases. To overcome this limitation, we also propose a that constructs magic squares depending on whether \( n \) is odd, singly even, or doubly even. Moreover, we provide a proof of the correctness of this novel approach. Our numerical results show that our method can construct magic squares of order up to \num{70000} in less than \num{140} seconds, demonstrating its efficiency and scalability.
format Preprint
id arxiv_https___arxiv_org_abs_2504_20017
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Constructing Magic Squares: an integer constraint satisfaction problem and a fast approach
Pamplona, João Vitor
Pinheiro, Maria Eduarda
Santos, Luiz-Rafael
Optimization and Control
Magic squares are a fascinating mathematical challenge that has intrigued mathematicians for centuries. Given a positive (and possibly large) integer \( n \), one of the main challenges that still remains is to find, within a computational time, a magic square of order \( n \), that is, a square matrix of order \( n \) with unique integers from \( a_{\min} \) to \( a_{\max} \), such that the sum of each row, column, and diagonal equals a constant \( \mathcal{C}(A) \). In this work, we first present an integer constraint satisfaction problem for constructing a magic square of order \( n \). Nonetheless, the solution time of this problem grows exponentially as the order increases. To overcome this limitation, we also propose a that constructs magic squares depending on whether \( n \) is odd, singly even, or doubly even. Moreover, we provide a proof of the correctness of this novel approach. Our numerical results show that our method can construct magic squares of order up to \num{70000} in less than \num{140} seconds, demonstrating its efficiency and scalability.
title Constructing Magic Squares: an integer constraint satisfaction problem and a fast approach
topic Optimization and Control
url https://arxiv.org/abs/2504.20017