Site Logo
RanAwaySuccessfully's Website

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:

xn = x(n - 1) + 1 + 2(n - 1), where √xn = n

That 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 √xn = n, which means that the square root of xn is n, and that n² = xn. So we can just replace xn 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 a1, a2 and a3. So I had the sequence {a1, a2, a3, a4, ... an} fresh in my memory, and also that I could calculate a number on this series, say, a7, just by knowing the difference between each number in the set, thanks to an = a1 + (n - 1)d. In this case for example:

a7 = a1 + (7 - 1)d
a7 = 3 + (7 - 1)2 -- The first element (a1) is 3, and the difference (d) is 2
a7 = 3 + 6 * 2
a7 = 3 + 12
a7 = 15

And as you can see, the 7th element in that set, a7, 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 {x0, x1, x2, x3, x4...xn} = {0, 1, 4, 9, 16...x} and I altered the formula to look like x(n + 1) = xn + 1 + 2n. As you can see, n works as an index number for the sequence as well, if n = 4, then xn = x4 = 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) = xn + 1 + 2n it became xn = 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.