Anyway, in my Saturday morning isolation boredom, I learned (on my own) a couple of neat math oddities I hadn’t already known. I’ll start with a few similar ones I already knew, and end up with something I have proven to myself but that @Ether might have made a math quiz.

Known for years (I love φ):
x = (√5 - 1)/2 = 0.61803398874989484820458683436564…
φ = 1/x = 1.61803398874989484820458683436564…
φ² = 2.61803398874989484820458683436564…

x = √2 - 1 = 0.4142135623730950488016887242097…
1/x = 2.4142135623730950488016887242097…

Learned today (though it feeds into a tile pattern I used for a bathroom floor about a year before the guy who pulled me into FRC (@ExploitSage) was born!):
2 * atan(1/3) = atan(3/4)
2 * atan(1/2) = atan(4/3)
atan(1/3) + atan(1/2) = atan(1)

And also learned today. I have proven to myself, but I’d like someone else to explain it. I can’t give “credit” like the old CD, but I will like the first clear statement why the digits in the second case match those in the first.

x = 5 - √8 = 2.1715728752538099023966225515806…
x² = 4.715728752538099023966225515806…

yup, the same set of digits, one place down.

Also, I invite other cool/weird math stuff in this topic!

OK, here’s another one. Write a program (pick your language) to efficiently* generate Pythagorean triples of the form:

a² + (a+1)² = c²

* Efficiently: the program should do more work rendering output in decimal than in calculating the values. My gawk script is significantly fewer than 200 non-comment characters, generates 21 properly ordered triples in well under 0.1 seconds on a 6 year old PC, and terminates when it recognizes it is beyond gawk’s resolution limits. It could go on all day with a while (0=0) if gawk supported arbitrary resolution. It uses two variables, four assignment statements, one while statement, and one printf statement. You don’t have to get that far down, but at least close. Oh, and explain why it works! (The explanation should be longer than the functional parts of the program!)

Here's the gawk script to generate Pythagorean triples where the legs differ by one

BEGIN {
p=1
q=0
while ((p*p+q*q)%4==1) {
printf "%d² + %d² = %d²\n",
q%2?p*p-q*q:2*p*q, q%2?2*p*q:p*p-q*q, p*p+q*q;
p=2*p+q;
q=(p-q)/2;
}
}

Here's the explanation

Primitive* Pythagorean triples are of the form:

(p² - q²)² + (2pq)² = (p² + q²)²

Where p and q are mutually prime positive integers, not both odd. OBTW, It is trivial to prove the equality, and that all terms are integers if p and q are positive integers. It is easy to see that p and q must be mutually prime in order to get a primitive* Pythagorean triple; the calculated values would all have the square of the common factor of p and q as a factor. They cannot both be even, because they would have a common factor of 2. They cannot also both be odd, as all numbers in the triple would then be even (share a factor of 2) as odd*odd = odd and odd ± odd = even.

We need to find p & q where |(p² - q²) - 2pq| == 1, or alternately, p² - q² ≈ 2pq, a quadratic in p. That is, p ≈ (2q ± √(4q² + 4q²)) /2 ≈ (1 ± √2)q.
Ratios p/q near √2 are derived p’= p+2q, q’= p+q. Ratios near 1+√2 should be p’=2p+q, q’=p.
OK, will this work? Is it exactly one? Let’s prove this by induction.

Termination: By the nature of the formulas, one of p and q must be odd and the other even. Therefore, the sum of their squares is always 1 mod 4. This fails when we hit the resolution limit.

* That is, the greatest common factor of the three numbers is one.

Here’s one I discovered today. I am well acquainted with the formula for triangle numbers, and had previously worked out the formula for tetrahedral numbers. It was only today that I realized those formulas are just special cases of a general formula for triangular cases in an arbitrary number of dimensions. As soon as I saw the pattern, I very quickly convinced myself it was true.
The first two formulas are:

Triangle(n) = n*(n+1)/2

Tetrahedron(n) = n*(n+1)*(n+2)/6.
What I realized today was the more general formula for a k-dimensional triangle of edge length n:

T(k,n) = (n+k-1)!/((n-1)! k!) = choose(n+k-1, k), where choose(a,b) is the number of order independent possibilities of choosing b items from a set of a items, commonly denoted more like (ᵃᵦ), where the a and b are directly over and below each other. This is a very common operation in statistics calculations.

OBTW, the definition of T(k,n) would be 1 for k=0 and any value of n, and Σ(i=0,n,T(k-1,n-i)) for k>0.

Does anyone else see why the general formula is true?

The k=2 column can be interpreted as numbers of close-packed tangent identical circles drawn in a plane, with n circles on each edge. The k=3 column can be seen as numbers of close-stacked tangent cannonballs in space on a flat base, again with n cannonballs on each edge of the stack.

The numbers look familiar, but I can’t quite place them.

The cannonball piles I started doing with the Stronghold game pieces. I’d leave them that way at competitions at night, and if they are scattered in the morning, I knew someone was playing with the Field!

Wasn’t there a joke about one of these formulas (probably xkcd) about teasing a math student on “how close” this was to perfect and it’s probably in error. I’m probably mangling the joke badly.