Sum of Diagonals in 1001x1001 Spiral

  • Context: Undergrad 
  • Thread starter Thread starter AntonVrba
  • Start date Start date
  • Tags Tags
    Sum
Click For Summary

Discussion Overview

The discussion revolves around calculating the sum of the diagonals in a 1001x1001 spiral, which is constructed by starting with the number 1 and moving in a clockwise direction. Participants explore both mathematical formulas and programming approaches to derive the sum.

Discussion Character

  • Mathematical reasoning
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant presents a 5x5 spiral example and notes that the sum of the diagonals is 101, prompting the question of the sum for a 1001x1001 spiral.
  • Another participant provides a hint regarding the numbers at the corners of the spiral, suggesting a formula involving n, where n is the size of the spiral.
  • A participant shares a closed-form formula for the sum of the diagonals for an nxn spiral, specifically stating it as (2/3)n^3 + (1/2)n^2 + (4/3)n - 3/2, and calculates the sum for n=1001 as 669171001.
  • A different participant confirms their program yields the same result and seeks to prove the equivalence of their program to the provided formula.
  • Another participant expresses gratitude for the formula and mentions their own similar formula published later, indicating a shared interest in the topic.
  • One participant references Galileo's solution and suggests that their iterative math might contribute to understanding the formula better.

Areas of Agreement / Disagreement

Participants generally agree on the formula provided for the sum of the diagonals, as multiple contributors arrive at the same numerical result for n=1001. However, there is no consensus on the derivation of the formula or the equivalence of different approaches.

Contextual Notes

Some participants reference their own contributions and earlier works, indicating a historical context to the discussion. There are also mentions of potential errors in earlier posts, such as a typographical error regarding the publication date.

Who May Find This Useful

This discussion may be useful for those interested in mathematical patterns, programming solutions for mathematical problems, and historical contributions to mathematical formulas.

AntonVrba
Messages
92
Reaction score
0
Consider a spiral starting with the number 1 and moving to the right in a clockwise direction, below is an example of a 5 by 5 spiral and the diagonal is highlighted:


21 22 23 24 25
20 07 08 09 10
19 06 01 02 11
18 05 04 03 12
17 16 15 14 13

The sum of both diagonals is 101.

if the spiral formed in the same way to 1001 by 1001, then what is the sum of both diagonals?
 
Mathematics news on Phys.org
HINT:

the number in the top right corner is n^2, the other corners are given by: n^2-n+1, n^2-2n+2, and n^2-3n+3.
 
Answer:


Argh, my stupid computer crashed while I finished typing out the solution here.
Luckily my closed form formula was still copied to mthe memory:
Sum of diagonals for the nxn spiral (n is odd): (2/3)n^3+(1/2)n^2+(4/3)n-3/2

Which gives for n=1001: 669171001

[/Color]
 
I wrote a program and came up with the same answer.
Code:
class Diagonals{
	public static void main(String args[])
	{
		int x = 0, y = 0, sum = 0;
		for(int i = 1; i <= 1001*1001; i++)
		{
			if(Math.abs(x) == Math.abs(y))
				sum+=i;
			if(y >= Math.abs(x))
				x++;
			else if((y <= -x && x > 0) || (y < x && x <= 0))
				x--;
			else if(x > 0)
				y--;
			else if(x < 0)
				y++;
		}
		System.out.println(sum);
	}
}

How can I prove my program equivalent to your formula?
 
Galileo said:
Answer:


Argh, my stupid computer crashed while I finished typing out the solution here.
Luckily my closed form formula was still copied to mthe memory:
Sum of diagonals for the nxn spiral (n is odd): (2/3)n^3+(1/2)n^2+(4/3)n-3/2

Which gives for n=1001: 669171001

[/Color]
You were once the only author on the net to publish this formula. How do you come to this result? I published a similar formula much later. Sorry for not quoting you.

My contribution in APL Quote Quad (December 20027) fell in the category "APL as a tool of thought".

Regards
 
Tribute and addendum to Galileo's solution .
Perhaps someone can make use of the iteration math I am contributing to find a way to Galileo's formula.

Galileo's solution formula
(2/3)n^3+(1/2)n^2+(4/3)n-3/2The algorithm I made up used n^2 +((n-1)^2)+1)*3 for each +2 iteration starting at 1.
Starting at 2 it yields the even diagonal sums.
Your formula for even diagonals would leave out the last -3/2. Yours is a straightforward answer. Good one Galileo.

mathal
 
Last edited:
Andrex said:
You were once the only author on the net to publish this formula. How do you come to this result? I published a similar formula much later. Sorry for not quoting you.

My contribution in APL Quote Quad (December 20027) fell in the category "APL as a tool of thought".

Regards
Erratum: I mean "December 2007" (not "December 20027").
 

Similar threads

  • · Replies 19 ·
Replies
19
Views
4K
  • · Replies 68 ·
3
Replies
68
Views
13K
  • · Replies 44 ·
2
Replies
44
Views
10K
  • · Replies 58 ·
2
Replies
58
Views
5K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
0
Views
2K