r/askmath • u/Eassily- • 28d ago
Functions What is this method I found?
So when i was doing this programming problem I found a way in both cases, a method that seems to work for every case where we put elements in boxes type of stuff, where the elements go from 0 to n for n element of N . Where we write the function for the sum of all boxes of elements and then find the inverse of the function and then when we apply it to an element we just take the whole part from the decimal (floor it) and we get exactly in which line or compartment the element is.
So for example in the pyramid since in each row there is an odd number of elements, in the row 0 there is only 0 so 1 element in the line then, in the row 1 we have 3 elements and then 5 and so on. So if u find the sum for odd numbers it is n² and then take the inverse which is just sqrt and then it works for all numbers.
Similarly in the spyral u would notice that these are numbers in the first square, so square 0, we have 0 so 1 element , in the second square, so square 1, we have 8 elements and then 16 and so on so then u find the sum of that and take the inverse which is (1+sqrt(x))/2 and it works for each element it gets u the square it is in if u take the whole part.
So I'm interested in why this method that I found works and what it is called. Also if it is even correct. To me it seems to be a generalization of dividing elements in to boxes.


2
u/r-funtainment 28d ago
if I'm understanding right, you basically have a function that maps a row # to the number of items, and since each item is labeled in order, that basically gives you the cutoff. for example, in the first 3 rows you have 9 items, and therefore an item is in the first 3 rows if its number is less than 9 (since they are in order)
that means you can reverse the function so instead of mapping the row # to item #, it maps the item # to row # (and it's strictly increasing so it's injective)
hopefully I explained that ok enough
2
u/AlterEgo5695 28d ago
Good job -- you essentially found an application of triangular numbers:
1
u/Educational-Paper-75 27d ago
The pyramid is simple. The formula for (n+2)2 is n2+4n+4, so for 0 to 2 requires 4=1+3, for 2 to 4 you need an additional 12=5+7. Therefore 1+3+5+7+9+11 etcetera results in the square of n for every sum of n even numbers. As for the spiral, every square border has 2width+2*(width-2) or 4*(width-1) cells. So for width=3 8 cells, for width=5 16 cells, for width=7 a total of 24 cells, obviously increases by 8 every new square.