Back
Math!

Double Count Series

A fun math problem I was told about, and then spent way too much time solving.

Published on

My morning

The time: 4 in the morning. My sleep schedule: destroyed.

I woke up this morning and checked my phone. It was way too early for me, so I decided to head back to bed. Just before closing my eyes, I saw a notification—something about a math problem. There was no chance I was going back to bed.

The problem

The problem is pretty simple. We want to create a formula for the set: S=1,1,2,2,3,3,4,4,S=1,1,2,2,3,3,4,4,\dots

There’s only one constraint: no using the modulus, floor, ceiling, or absolute value functions.

Before reading the rest of this post, I’d suggest trying to solve this problem on your own! I promise it’s fun.

A solution

The first thing I did to find the solution was to create a “base” function. This function would be able to model every other term (e.g. a1,a3,a5,a_1,a_3,a_5,\dots). This function was pretty easy to find, just a basic line: Sn=(1+n)2S_n=\frac{(1+n)}{2}

Let’s check our work:

nnSnS_n
11(1+1)2=1\frac{(1+1)}{2}=1
22(1+2)2=32\frac{(1+2)}{2}=\frac{3}{2}
33(1+3)2=2\frac{(1+3)}{2}=2
44(1+4)2=52\frac{(1+4)}{2}=\frac{5}{2}
55(1+5)2=3\frac{(1+5)}{2}=3
66(1+6)2=72\frac{(1+6)}{2}=\frac{7}{2}
77(1+7)2=4\frac{(1+7)}{2}=4

Every odd value for nn works fine, but every even value fails! Let’s try to fix this by applying another function on top. The function on top must have some special oscillating nature such that it can be equal to 00 for every odd value, and equal to 12\frac{-1}{2} for every even value.

My first thought was something similar to the business cycle curve:

And it turns out this works! The function f(x)=cos(xπ)f(x)=\cos(x\pi) gives us a table that looks like this:

xxf(x)f(x)
11cos(1π)=1\cos(1\pi)=-1
22cos(2π)=1\cos(2\pi)=1
33cos(3π)=1\cos(3\pi)=-1
44cos(4π)=1\cos(4\pi)=1
55cos(5π)=1\cos(5\pi)=-1
66cos(6π)=1\cos(6\pi)=1
77cos(7π)=1\cos(7\pi)=-1

Now all we have to do is transform this function to meet our criteria: g(x)=cos(xπ+π)14g(x)=\frac{\cos(x\pi+\pi)-1}{4}.
Notice how I added the "+π+\pi" here. This is to shift the function off by one value of xx.

xxg(x)g(x)
11cos(1π+π)14=0\frac{\cos(1\pi+\pi)-1}{4}=0
22cos(2π+π)14=12\frac{\cos(2\pi+\pi)-1}{4}=\frac{-1}{2}
33cos(3π+π)14=0\frac{\cos(3\pi+\pi)-1}{4}=0
44cos(4π+π)14=12\frac{\cos(4\pi+\pi)-1}{4}=\frac{-1}{2}
55cos(5π+π)14=0\frac{\cos(5\pi+\pi)-1}{4}=0
66cos(6π+π)14=12\frac{\cos(6\pi+\pi)-1}{4}=\frac{-1}{2}
77cos(7π+π)14=0\frac{\cos(7\pi+\pi)-1}{4}=0

Look at that! Just the function we need. Now let’s add the two up to see our result:

Sn=cos(nπ+π)14+(1+n)2S_n=\frac{\cos(n\pi+\pi)-1}{4}+\frac{(1+n)}{2}

Some additional solutions:

We’re not quite done yet. There’s one other (related) way to solve this problem I thought of. This way uses complex numbers! I was thinking about the spinning nature of ini^n and came up with the formula f(x)=i2xf(x)=i^{2x}. This function acts similarly to f(x)=cos(xπ)f(x)=\cos(x\pi). We can actually show why this is true using Euler’s formula (eix=cos(x)+isin(x)e^{ix}=\cos(x)+i\sin(x))! It can also be simplified to f(x)=(1)xf(x)=(-1)^x. I find the interconnectedness of all of these solutions pretty awesome!

Anyways, I hope this post was a fun read.

See you later,
Ilan Bernstein