Triangle Numbers Algorithm: What is it?

In summary: That would be my guess too. But the OP can already find the indices by hand by doing a bit of thinking. So I think this thread may have been unnecessary.In summary, the conversation discusses the process of finding the number of unique grid points in a Cartesian coordinate system by starting at a corner and making one step in each of the three positive directions. The resulting sequence of numbers is called the triangle numbers, and it is possible to find the specific algorithm to determine the unique grid points through research, such as searching for "Gauss sum of integers." However, it may be possible to manually calculate the indices of the grid points by using a bit of thinking.
  • #1
FQVBSina
39
8
I was investigating the number of unique grid points in a Cartesian coordinate system if I were to start at a corner (say coordinate 1,1,1), and make one step in each of the three positive directions (coordinates 1,2,1; 2,1,1; and 1,1,2). Now I went from 1 point to 3 points.

I repeat the same process for the three new points and I found 6 unique new points, and then from the 6 I found 10. It turns out this 1,3,6,10 sequence (which I predict the next number is 15) is called the triangle numbers.

My question is, what is the name of the algorithm that finds the number of unique grid points in the way I did it? I knew there must be an existing pattern/equation out there but I don't know what it is called.

Thanks!
 
Mathematics news on Phys.org
  • #2
FQVBSina said:
My question is, what is the name of the algorithm that finds the number of unique grid points in the way I did it? I knew there must be an existing pattern/equation out there but I don't know what it is called.
You could google Triangle Number and get an answer faster than by asking the question here. Or Google "gauss sum of integers".
 
  • Like
Likes berkeman
  • #3
jbriggs444 said:
You could google Triangle Number and get an answer faster than by asking the question here. Or Google "gauss sum of integers".
I tried. I am looking for the specific algorithm that finds the unique grid points, and searching for Triangle Numbers gives too many mathematical theories. I will try Gauss sum when I get back. Thanks
 
  • #4
Google Images searches usually help me get through the clutter faster. Not sure if that helps...
 
  • #5
FQVBSina said:
I tried. I am looking for the specific algorithm that finds the unique grid points, and searching for Triangle Numbers gives too many mathematical theories. I will try Gauss sum when I get back. Thanks
So you don't want the number (total count) of grid points at a given plane away from the origin. You want the sequence number associated with a given grid point in terms of x, y and z?

Off the top of my head, that should be achievable by taking the sum of x, y and z, and finding that tetrahedral number, finding the sum of x and y and finding that triangular number and then adding tetrahedral number + triangular number + z to get the result.

Tweak for off-by-one errors and scan order in populating the triangles.
 
Last edited:
  • Like
Likes QuantumQuest
  • #6
You are literally producing triangles that way, and the sum of all the coordinates of the points is always 3 (starting at (1,1,1)) plus the number of steps.

You can quickly generate a list of these points if you loop over two coordinates and calculate the last one accordingly.
 
  • Like
Likes QuantumQuest
  • #7
@FQVBSina The formula for your nth number is ## S_n=\frac{(n+1)n}{2} ##. This is because your nth number is ## S_n=1+2+3+...+n ## which is the sum of an arithmetic series. The arithmetic series is a well known formula.
 
  • #8
mfb said:
You are literally producing triangles that way, and the sum of all the coordinates of the points is always 3 (starting at (1,1,1)) plus the number of steps.
I am not sure to whom you are responding. If it is in reference to the x,y,z algorithm that I proposed, it is not literally producing triangles. It involves evaluating one cubic polynomial in x, y and z.
 
  • #9
Why do you want a cubic polynomial? In the way I understand the first post, everything is linear.

I'm not sure what "specific algorithm that finds the unique grid points" means. I proposed an algorithm that produces a list of these points. If OP is just interested in the number, then the triangle numbers are the answer already and I don't understand what this thread is about.
 
  • #10
mfb said:
I'm not sure what "specific algorithm that finds the unique grid points"
Nor am I -- so I took a guess: given a grid point, find its index in the diagonal scan order.
 

1. What is the Triangle Numbers Algorithm?

The Triangle Numbers Algorithm is a mathematical formula used to find the sum of all the numbers in a triangular shape. It is also known as the Triangular Numbers Algorithm or the Gauss's Method.

2. How does the Triangle Numbers Algorithm work?

The algorithm works by adding consecutive numbers in a triangle shape, starting with 1 at the top and increasing by 1 for each row. For example, the first row will have 1 number, the second row will have 2 numbers, the third row will have 3 numbers, and so on. The sum of all the numbers will give the triangular number.

3. What is the significance of the Triangle Numbers Algorithm?

The Triangle Numbers Algorithm has several applications, such as in number theory, geometry, and computer science. It is also used to solve various mathematical problems, including finding the number of possible combinations and the number of lattice points in a triangular grid.

4. How is the Triangle Numbers Algorithm related to Pascal's Triangle?

Pascal's Triangle is a triangular array of numbers that follows the same pattern as the Triangle Numbers Algorithm. The numbers in each row of Pascal's Triangle are the coefficients of the binomial expansion. This means that the Triangle Numbers Algorithm can be used to find the numbers in Pascal's Triangle.

5. Can the Triangle Numbers Algorithm be generalized to find the sum of numbers in other shapes?

Yes, the Triangle Numbers Algorithm can be generalized to find the sum of numbers in other shapes, such as squares, pentagons, and hexagons. The formula for these shapes is similar to the Triangle Numbers Algorithm, with the only difference being the number of sides in the shape.

Similar threads

Replies
3
Views
491
Replies
4
Views
625
  • Advanced Physics Homework Help
Replies
8
Views
1K
Replies
66
Views
4K
Replies
19
Views
2K
Replies
7
Views
1K
  • Programming and Computer Science
Replies
1
Views
961
  • Precalculus Mathematics Homework Help
Replies
8
Views
425
  • Programming and Computer Science
Replies
14
Views
2K
Back
Top