Yes, that’s right, that Challenge #12, posted one year, five months, and a day ago. You see, I have this nasty habit of starting things and not finishing them… well, better late than never!
Question two of the aforementioned challenge asked this:
Given a positive integer n, in how many ways can n be written as a sum of powers of two, when each power is allowed to occur at most twice? Say denotes the number of different ways to write n as a sum of powers of two with at most two copies of each power allowed. What can you say about the function h?
These representations using at most two copies of each power of two are sometimes called hyperbinary representations. For example, 11 can be written as or as . It turns out these are the only hyperbinary representations of 11, so .
How to analyze this? We can use a similar approach to that outlined in the solution to part III (which asked a similar question, but allowing any number of copies of each power of two). First let’s think about odd numbers, that is, numbers of the form . Any representation of an odd number must include an odd number of copies of (otherwise the sum won’t be odd!), but since at most two copies are allowed, there must be exactly one copy of . If we take away the and divide everything else by two, we get a valid representation of . The reverse works as well: if we start with any valid representation of , multiply everything by two, and add a copy of , we get a valid representation of . This means that
What about even numbers? A valid representation of has either two copies of , or none. If it has none, we can simply divide by two to get a valid representation of (and vice versa); if two, we can take away the copies of and then divide by two to get a representation of , and vice versa. Therefore,
These two equations, and , along with the fact that , are enough to completely characterize . We can easily compute for the first few values of :
It’s immediately striking, of course, that isn’t strictly increasing: that is, just because doesn’t mean . In fact, even as the values of continue to get bigger on average, there are still some values of 1 hiding in there. In fact, , and the obvious conjecture is that for every .
The next thing we notice, after staring a bit, is that the sequence contains a lot of palindromes! Every section sandwiched in between two 1’s seems to read the same forwards and backwards. Let’s make some graphs so we can see these patterns more easily: below I’ve made graphs showing as goes from 1 to 100, 1000, and 10000, respectively.
Pretty! We can clearly see the symmetric structure here, and the way that it occasionally (every ) jumps back down to 1.
Here’s another way to think about building the sequence. We start with the first two elements:
Now we copy the red part onto the end of the sequence (the copy will be blue), leaving a blank space in front of each blue number:
, , ,
Now we fill in each blank (in green) by adding the two numbers on either side of it:
, , ,
Now the blue and green part becomes the new red part:
Now we repeat! Copy the red part to the end, leaving a blank in front of each copied number:
, , , , , ,
Fill in each blank by adding the two numbers on either side:
, , , , , ,
And again: blue and green become the new reds, copy the red numbers to the end with a blank in front of each:
, , , , , , , , , , , ,
And fill in the blanks by adding:
, , , , , , , , , , , ,
And so on. It takes a little bit of thought, but it can be seen that the method I’ve described here is really just a different way of expressing the equations and ! But thinking about it this way makes it apparent why a 1 always shows up at , and also why we end up with palindromes.
I’ll stop there for now; in an upcoming post I’ll bring things full circle by showing how these numbers relate to the Calkin-Wilf tree of
Thanks for the post. I find this number sequence interesting. The further along you go in the sequence, the maximum value gets larger but the minimum is always 1.
Well, goodness, you made the post. What will I hassle you about now?
That does remind me to try using that tree structure from the other post on your problem #3, because if it’s possible to generate it in a similar way it might answer the asymptotic growth problem you mention.
JM: Interesting, isn’t it? In fact, not only does 1 occur infinitely many times; EVERY number does! That is, no matter where you are in the sequence, there will always be another 2, and another 3, and so on…
Jason: Don’t worry, I’m sure you’ll be able to find *something* to hassle me about. 😉 What “tree structure” are you talking about? I’m not sure which post you’re referring to.
My comment to your challenge.
A couple more observations:
The highest number between two 1’s is always a Fibbonocchi number, and is the next highest Fibbonocchi number from the one before it.
The most common number (I think) is 5, because 5 is the first number to appear 4 times between a set of 1’s, and 4 is (I think) the maximum.
Jason: ah, right, I remember that now, it’s quite clever. Actually, maybe I’ll take another post to describe your solution, with some accompanying pretty pictures. =)
Thanks for posting this long awaited solution. I don’t know if you ever saw it, but I started to try to solve this problem back in March 2009 and I left several (somewhat long-winded) responses. After reading your solution and seeing how simple and elegant it is, I’m embarrassed I didn’t think about it that way. However, if you don’t mind taking a look at my attempt, I’d like to know if there is some connection between the pattern I saw and the actual solution. Thanks for continuing to produce a really interesting site!
Don’t be embarassed; sometimes it’s the simple, elegant solutions which are the hardest to see! I can assure you that I went down many convoluted rabbit trails the first time I thought about this problem.
Anyway, I do remember your comments but must confess that I never read them in great detail. I will take a look and let you know of any connections I can see!
After looking more carefully at your comments on that old post, I am happy to report that your explorations were very much related to the solution I posted here. Most, if not all, of the conjectures you made are absolutely correct, and you also uncovered some interesting structure and questions that I hadn’t thought about. I hope to write up some of this in detail in an upcoming post!
Thanks for your time and attention. I look forward to the upcoming posts.
Pingback: Walking Randomly » Carnival of Maths #58
Pingback: More hyperbinary fun « The Math Less Traveled
Pingback: Hyperbinary conjecture seeking proof for a good time, long walks on the beach « The Math Less Traveled
Pingback: The hyperbinary sequence and the Calkin-Wilf tree « The Math Less Traveled
Pingback: The hyperbinary sequence and the Calkin-Wilf tree | The Math Less Traveled