## Randomly Finding a Mathematical Formula

Once upon a time, a blog post I was making was going to be published on July 1st. Was. It sure ain't July 1st anymore though...anyway, enough about that.

This is a post about how sometimes I just stumble on random things for who knows what reason. Like this thing, for example:

**x _{n} = x_{(n - 1)} + 1 + 2(n - 1)**, where

**√x**

_{n}= nThat thing up there probably doesn't make much sense to you, but it's basically a way for you to calculate the square of a number. It's a weirder version of this thing down here: **n² = (n − 1)² + (n − 1) + n**. This formula basically says that you can know the square of a number just by knowing the square of the previous number and the previous number itself. Let's say I want to know 15²:

15² = (15 - 1)² + (15 - 1) + 15

15² = 14² + 14 + 15

15² = 196 + 14 + 15

15² = 210 + 15

15² = 225

Both formulas are actually the same, they're just structured differently. Above I wrote **√x _{n} = n**, which means that the square root of x

_{n}is n, and that n² = x

_{n}. So we can just replace x

_{n}by n². Similarly, √x

_{(n - 1)}is just the square root of the previous number, so (n - 1)² can replace it.

n² = (n - 1)² + 1 + 2(n - 1)

n² = (n - 1)² + 2(n - 1) + 1

n² = (n - 1)² + (n - 1) + (n - 1) + 1

n² = (n - 1)² + (n - 1) + n ~~- 1 + 1~~

n² = (n - 1)² + (n - 1) + n

Now the question is, how in the world did I just randomly stumble upon this? I mean, I knew that this was probably something that was already well-known, but I still thought it was weird how I got here.

Well, for some background, the time I wrote that formula I had just recently learned Arithmetic progression at school. For example {3, 5, 7, 9...} is an Arithmetic progression where the first element is 3, the second is 5, the third is 7, basically increasing by 2. You can also refer to each number as its placement, but instead of 1st, 2nd and 3rd numbers, you can call them a_{1}, a_{2} and a_{3}. So I had the sequence {a_{1}, a_{2}, a_{3}, a_{4}, ... a_{n}} fresh in my memory, and also that I could calculate a number on this series, say, a_{7}, just by knowing the difference between each number in the set, thanks to **a _{n} = a_{1} + (n - 1)d**. In this case for example:

a_{7} = a_{1} + (7 - 1)d

a_{7} = 3 + (7 - 1)2 -- The first element (a_{1}) is 3, and the difference (d) is 2

a_{7} = 3 + 6 * 2

a_{7} = 3 + 12

a_{7} = 15

And as you can see, the 7th element in that set, a_{7}, really is 15: {3, 5, 7, 9, 11, 13, **15**, ...}

I basically did this with square roots as well. While I was bored at school, I started messing with my calculator and tried to see the difference between each square root. It went sort of like this:

1² - 0² = 1 - 0 = 1

2² - 1² = 4 - 1 = 3

3² - 2² = 9 - 4 = 5

4² - 3² = 16 - 9 = 7

5² - 4² = 25 - 16 = 9

You can see why I was intrigued by this. I realized that the difference between a square and the previous square was following a pattern. Basically, it's increasing by two every step and it begins at 1, so you could write it as 2n + 1. So, if I had 4² - 3² = 7 and wanted to convert 7 into 2n + 1, I would use n = 3 since (2 * 3) + 1 = 7. You might think this is only overcomplicating things, but this is where I had a sudden moment of realization. **n** was the exact number of the lower square, in this case, 3². And that was **always** the case:

5² - *4*² = 9 -> 9 = (2 * *4*) + 1

6² - *5*² = 11 -> 11 = (2 * *5*) + 1

7² - *6*² = 13 -> 13 = (2 * *6*) + 1

8² - *7*² = 15 -> 15 = (2 * *7*) + 1

And as such, I realized that (n + 1)² - n² = 2n + 1, or to put it simply, (n + 1)² = n² + 2n + 1. You might notice something a bit weird though with the way the formula is structured, it focuses on the previous number rather than the "current" number. I think that the way I originally saw it was "if you have a number and its square, you can calculate the next square using this formula" rather than "if you want to calculate the square of a number, you can do it using this formula if you know the previous number and its square". They're functionally the same:

(5 + 1)² = 5² + 2 * 5 + 1

6² = 5² + 10 + 1

6² = 25 + 10 + 1

6² = 35 + 1

6² = 36

Then my knowledge about Arithmetic progressions made me turn this into the sequence {x_{0}, x_{1}, x_{2}, x_{3}, x_{4}...x_{n}} = {0, 1, 4, 9, 16...x} and I altered the formula to look like x_{(n + 1)} = x_{n} + 1 + 2n. As you can see, n works as an index number for the sequence as well, if n = 4, then x_{n} = x_{4} = 16. 4² is 16, and 16 is the 4th number in the sequence, which is the value of n.

As for 0...we'll just call it the 0th number just so this can make sense. It's common in programming, but it's probably weird and nonsensical anywhere else. Some time after this I started to learn JavaScript, and I decided to implement this in it to see if I was able to understand it well. And here it is. In short, it uses this code:

function sequentialSquare() {
var x = [0]; // List of Squares
var n = 0; // Index / Current Square Root Result
var r = 0; // Index / Current Square Number
var sequentialFunction = setInterval(function () {
r = x[n] + 1 + 2 * n;
x.push(r);
p1 = document.createElement("P");
p2 = document.createTextNode("√" + x[n + 1] + " = " + (n + 1));
p1.appendChild(p2);
document.getElementById("htmlidgoeshere").appendChild(p1);
n++;
}, 100);
}

Like always, feel free to use that code if you need it. You're probably going to need to adjust it a bit though. After I tried to search this formula on the internet and stumbled upon the Wikipedia page, I changed the values of n around, so instead of it looking like x_{(n + 1)} = x_{n} + 1 + 2n it became x_{n} = x_{(n - 1)} + 1 + 2(n - 1).

That's about it, really. I just wanted to share something I thought was interesting and show that sometimes we can find cool things by complete accident, like in this case.