So, not about the tree anymore per se, but more about Zeckendorf! Well -- this question arose out of the study of the tree, obviously. You see (to use briefly the terminology I was using to discuss the trees so I can state the original motivation), the v function has an oddness center (i.e. a point (h,k) st v(h+x)+v(h-x)=2k), but it also has a bunch of "pseudo-oddness centers", points (h,k) st v(h+x)+v(h-x) is usually 2k but not always. And whether it is or not is governed by the equation S(n+x)=S(n)+S(x).
Here by S I mean the Zeckendorf left-shift operation -- although, as you may recall from previous entries, it's actually well-defined even if you allow pseudo-Zeckendorf representations without consecutivity restrictions. (And thus in particular it also works for dual Zeckendorf.)
Anyway, so we have the question: When is S(n+m)=S(n)+S(m)? More generally, how can we determine S(n)+S(m)-S(n+m), without actually doing the addition? (We can also ask the same for S(n-m)+S(m)-S(n).) And, given n, what is the natural density of {m: S(n+m)≠S(n)+S(m)}?
Well, I have answers to all these questions! Likely this is already known, but I figured it out the other night and I thought it was neat.
Note that the difference S(n)+S(m)-S(n+m) is always one of 0, 1, or -1. Now, my actual rule for how to compute this quantity is a little complicated, so I'm going to hold off on stating it for a moment. But, the resulting rule for d({m: S(n+m)≠S(n)+S(m)}) is actually quite simple!
Namely, write n in Zeckendorf; let's say n = ΣiFki for i≥2, ki increasing (so k0 is the smallest), and the usual consecutivity restriction.
Then, the natural density that we're looking for is simply Σi(-1)ki-k0φ-ki.
Another thing worth noting, btw, is that for each n, the only nonzero value taken on by S(n)+S(m)-S(n+m) will be (-1)k, where k is the number of zeroes on the end of the Zeckendorf representation of n. Now you may say here, wait, just n? What about m? This function is symmetric, surely m must also have an effect? Well, that's the thing! The value can only be nonzero when this zero count has the same parity for both numbers! If they disagree, it's necessarily 0. (And of course it's always 0 when n=0, for which the count is undefined.)
Btw, a neat little thing about this parity: Did you know that the parity of the number of 0s on the end of the Zeckendorf representation of n, is always the opposite of the last digit of the dual Zeckendorf representation of n? Similarly, if you look at the parity of the number of 1s on the end of the dual Zeckendorf representation of n, this is always the same as the last digit of the Zeckendorf representation of n.
So, we could also say that you can only get a nonzero result if n and m have the same last digit in dual Zeckendorf, in which case the potential nonzero value is (-1)1+d (d being the digit), although I don't actually think that's a good way to think about this.
OK, so, what's the actual rule? Well, this is a little annoying to state properly. Heh, I realized the other day that it can be given as a finite state machine, but I'm not going to subject you to that.
I think the easiest way I've come up with to state it is: First, write n and m in Zeckendorf, and then take the digit-wise sum -- just add them up straight, yes you'll get 2s, you'll get consecutive 1s, it doesn't matter. Then, find the largest k such that there is a suffix of the form (2(01)*00)k2(01)*0ℓ≤1 (if there even is such a k, which there may not be). (Note: The exponents on the 01 may be different between the different copies of 2(01)*00, they don't need to all match or anything like that, otherwise it wouldn't be finite-state.) If there is no such k, or if k is odd, then S(n)+S(m)-S(n+m)=0. If k is even, then S(n)+S(m)-S(n+m)=(-1)ℓ.
So yay, an answer!
EDIT next day: I guess we could write this as -- assuming no leading zeroes and valid input -- it's an exception iff the digit-wise sum satisfies the regex
Now, what about subtraction? Well, first off, let's dispense with the natural density question. If we fix n and look at {k: S(k-n)≠S(k)-S(n)}, well, this is just a translation of the set {k: S(k+n)≠S(k)+S(n)}, so we already know the answer to that. And if on the other hand we look at {k: S(n-k)≠S(n)-S(k)}, well, then we're just looking at finite sets, so this question is uninteresting.
But, we can still ask about a rule for determining S(n-m)+S(m)-S(n), where want to determine this without actually performing the subtraction. And, this too has an answer! It's very similar to the above, except that, while we write m in Zeckendorf as before, we have to write n in dual Zeckendorf.
Then, we perform the subtraction to get a string of 1s, 0s, and -1s. If we simply subtract each of these digits from 1, to get 0s, 1s, and 2s, we can then apply the same algorithm as before.
So, in order to get a nonzero value, it must be the case that the parity of the number of 0s on the end of m in Zeckendorf, must be the same as the parity of the number of 1s on the end of n in dual Zeckendorf. Or -- for a less useful rephrasing -- the last digit of m in dual Zeckendorf must be opposite the last digit of n in Zeckendorf. Hm.
So anyway yeah that's neat!
Now, where does this addition rule even come from, anyway? Why does it work? This is going to be the handwavy explanation I used to originally come up with it; I can prove it, too, although not from scratch, but I can if I make use of this paper. But I don't want to get into formalism here.
Anyway, fundamentally it comes down to, if you were to actually carry out the addition in Zeckendorf, is there any part that would not commute with left-shift? And the answer is yes. Simply performing the addition of digits with no transformations is obviously no problem. And we already know that handling consecutive 1s commutes with left-shift, that's why left-shift is well-defined on pseudo-Zeckendorf representations. But what about handling of 2s? In most places, 0200 becomes 1001; that commutes with left-shift. But what doesn't is how it works in the 2s place and the 1s place. 20 is equal to 101, and 2 is equal to 10. The former gives you a difference of -1, the latter gives you a difference of 1.
So, to get S(n+m)≠S(n)+S(m), you must either have both with a 1 in the 1s place, or both with a 1 in the 2s place, right? Not so fast! Remember, adding two 1s in most places yields not only a carry upwards of 1, but also a carry of 1 downwards two places. This means that it's possible to get one of these problematic additions by adding, say, 101 (4) and 100 (3). The carry in the 3s place yields a problematic addition in the 1s place. Or imagine you add 10100 (11) and 10001 (9); the carry in the 8s place causes a carry in the 3s place, which cascades into a problematic carry in the 1s place.
Of course, these chains can get longer than that! But as long as you have 2(01)*, you get an exception with a value of 1, or if you have 2(01)*0, you get an exception with a value of -1.
Except, not so fast! What if something else up above could nullify that 2? Well, that can happen! Look at what happens if you add 1001 (6) to itself. That 2 in the 1s place should generate an exception... except, that the 2 in the 5s place results in a downward carry to put a 1 in the 2s place. The consecutivity drains a 1 away from the 1s place, up to the 3s place, leaving nothing that can generate an exception in the 1s place. So, we get an exception to the exception -- a value of 0 after all.
And just as with our chains of 1s that can generate an exception, we can have longer chains here too; for instance, if you were to add 101001 (19) and 100001 (14), the carry in the 13s place would generate a carry in the 5s place, into the 2s place, which would still prevent the problematic carry in the 1s place.
But wait! If an offset chain up above can drain away a 1 from a problematic carry... then a further offset chain even higher can drain away a 1 from the carry that would prevent the problematic carry, resulting in an exception after all! An exception to the exception to the exception. For instance, if you were to add 1001001 (27) to itself, the carry from the 21s place into the 8s place would prevent the carry in the 5s place, allowing the carry in the 1s place to happen after all, yielding a value of 1. You see?
And so forth; one can have more and more such offset chains, each of which deactivates the one coming after it. So whether you get an exception or not is determined by the parity of the count of them. And whether you get 1 or -1 is determined by whether the problematic carry, if it occurs, ultimately occurs in the 1s place or the 2s place. So that's why this is the correct rule; and that's not a proof, exactly, but using the paper linked above it can be turned into one.
Josh says Steven Miller might be a good person to talk to determine whether any of this is original and where I can find references for whatever might need citing... well, I'm not going to even think about writing a paper on this until various other papers are out of the way!
EDIT much later: Btw, if we want the overall natural two-dimensional natural density for the different possibilities -- well, actually proving it seems annoying, but for a difference of 0, it ought to be 2φ-5/2 (i.e. √5-3/2), for a difference of 1 it should be 1-φ/2, and for -1 it should be 5/2-3φ/2. (And for 1 or -1, it should be 7/2-2φ, or 5/2-√5.)
Here by S I mean the Zeckendorf left-shift operation -- although, as you may recall from previous entries, it's actually well-defined even if you allow pseudo-Zeckendorf representations without consecutivity restrictions. (And thus in particular it also works for dual Zeckendorf.)
Anyway, so we have the question: When is S(n+m)=S(n)+S(m)? More generally, how can we determine S(n)+S(m)-S(n+m), without actually doing the addition? (We can also ask the same for S(n-m)+S(m)-S(n).) And, given n, what is the natural density of {m: S(n+m)≠S(n)+S(m)}?
Well, I have answers to all these questions! Likely this is already known, but I figured it out the other night and I thought it was neat.
Note that the difference S(n)+S(m)-S(n+m) is always one of 0, 1, or -1. Now, my actual rule for how to compute this quantity is a little complicated, so I'm going to hold off on stating it for a moment. But, the resulting rule for d({m: S(n+m)≠S(n)+S(m)}) is actually quite simple!
Namely, write n in Zeckendorf; let's say n = ΣiFki for i≥2, ki increasing (so k0 is the smallest), and the usual consecutivity restriction.
Then, the natural density that we're looking for is simply Σi(-1)ki-k0φ-ki.
Another thing worth noting, btw, is that for each n, the only nonzero value taken on by S(n)+S(m)-S(n+m) will be (-1)k, where k is the number of zeroes on the end of the Zeckendorf representation of n. Now you may say here, wait, just n? What about m? This function is symmetric, surely m must also have an effect? Well, that's the thing! The value can only be nonzero when this zero count has the same parity for both numbers! If they disagree, it's necessarily 0. (And of course it's always 0 when n=0, for which the count is undefined.)
Btw, a neat little thing about this parity: Did you know that the parity of the number of 0s on the end of the Zeckendorf representation of n, is always the opposite of the last digit of the dual Zeckendorf representation of n? Similarly, if you look at the parity of the number of 1s on the end of the dual Zeckendorf representation of n, this is always the same as the last digit of the Zeckendorf representation of n.
So, we could also say that you can only get a nonzero result if n and m have the same last digit in dual Zeckendorf, in which case the potential nonzero value is (-1)1+d (d being the digit), although I don't actually think that's a good way to think about this.
OK, so, what's the actual rule? Well, this is a little annoying to state properly. Heh, I realized the other day that it can be given as a finite state machine, but I'm not going to subject you to that.
I think the easiest way I've come up with to state it is: First, write n and m in Zeckendorf, and then take the digit-wise sum -- just add them up straight, yes you'll get 2s, you'll get consecutive 1s, it doesn't matter. Then, find the largest k such that there is a suffix of the form (2(01)*00)k2(01)*0ℓ≤1 (if there even is such a k, which there may not be). (Note: The exponents on the 01 may be different between the different copies of 2(01)*00, they don't need to all match or anything like that, otherwise it wouldn't be finite-state.) If there is no such k, or if k is odd, then S(n)+S(m)-S(n+m)=0. If k is even, then S(n)+S(m)-S(n+m)=(-1)ℓ.
So yay, an answer!
EDIT next day: I guess we could write this as -- assuming no leading zeroes and valid input -- it's an exception iff the digit-wise sum satisfies the regex
/^(.*(1(10)*0|0(01)*00))?((2(01)*00){2})*2(01)*0?$/but hoo boy personally I find that less clear than the above description.
Now, what about subtraction? Well, first off, let's dispense with the natural density question. If we fix n and look at {k: S(k-n)≠S(k)-S(n)}, well, this is just a translation of the set {k: S(k+n)≠S(k)+S(n)}, so we already know the answer to that. And if on the other hand we look at {k: S(n-k)≠S(n)-S(k)}, well, then we're just looking at finite sets, so this question is uninteresting.
But, we can still ask about a rule for determining S(n-m)+S(m)-S(n), where want to determine this without actually performing the subtraction. And, this too has an answer! It's very similar to the above, except that, while we write m in Zeckendorf as before, we have to write n in dual Zeckendorf.
Then, we perform the subtraction to get a string of 1s, 0s, and -1s. If we simply subtract each of these digits from 1, to get 0s, 1s, and 2s, we can then apply the same algorithm as before.
So, in order to get a nonzero value, it must be the case that the parity of the number of 0s on the end of m in Zeckendorf, must be the same as the parity of the number of 1s on the end of n in dual Zeckendorf. Or -- for a less useful rephrasing -- the last digit of m in dual Zeckendorf must be opposite the last digit of n in Zeckendorf. Hm.
So anyway yeah that's neat!
Now, where does this addition rule even come from, anyway? Why does it work? This is going to be the handwavy explanation I used to originally come up with it; I can prove it, too, although not from scratch, but I can if I make use of this paper. But I don't want to get into formalism here.
Anyway, fundamentally it comes down to, if you were to actually carry out the addition in Zeckendorf, is there any part that would not commute with left-shift? And the answer is yes. Simply performing the addition of digits with no transformations is obviously no problem. And we already know that handling consecutive 1s commutes with left-shift, that's why left-shift is well-defined on pseudo-Zeckendorf representations. But what about handling of 2s? In most places, 0200 becomes 1001; that commutes with left-shift. But what doesn't is how it works in the 2s place and the 1s place. 20 is equal to 101, and 2 is equal to 10. The former gives you a difference of -1, the latter gives you a difference of 1.
So, to get S(n+m)≠S(n)+S(m), you must either have both with a 1 in the 1s place, or both with a 1 in the 2s place, right? Not so fast! Remember, adding two 1s in most places yields not only a carry upwards of 1, but also a carry of 1 downwards two places. This means that it's possible to get one of these problematic additions by adding, say, 101 (4) and 100 (3). The carry in the 3s place yields a problematic addition in the 1s place. Or imagine you add 10100 (11) and 10001 (9); the carry in the 8s place causes a carry in the 3s place, which cascades into a problematic carry in the 1s place.
Of course, these chains can get longer than that! But as long as you have 2(01)*, you get an exception with a value of 1, or if you have 2(01)*0, you get an exception with a value of -1.
Except, not so fast! What if something else up above could nullify that 2? Well, that can happen! Look at what happens if you add 1001 (6) to itself. That 2 in the 1s place should generate an exception... except, that the 2 in the 5s place results in a downward carry to put a 1 in the 2s place. The consecutivity drains a 1 away from the 1s place, up to the 3s place, leaving nothing that can generate an exception in the 1s place. So, we get an exception to the exception -- a value of 0 after all.
And just as with our chains of 1s that can generate an exception, we can have longer chains here too; for instance, if you were to add 101001 (19) and 100001 (14), the carry in the 13s place would generate a carry in the 5s place, into the 2s place, which would still prevent the problematic carry in the 1s place.
But wait! If an offset chain up above can drain away a 1 from a problematic carry... then a further offset chain even higher can drain away a 1 from the carry that would prevent the problematic carry, resulting in an exception after all! An exception to the exception to the exception. For instance, if you were to add 1001001 (27) to itself, the carry from the 21s place into the 8s place would prevent the carry in the 5s place, allowing the carry in the 1s place to happen after all, yielding a value of 1. You see?
And so forth; one can have more and more such offset chains, each of which deactivates the one coming after it. So whether you get an exception or not is determined by the parity of the count of them. And whether you get 1 or -1 is determined by whether the problematic carry, if it occurs, ultimately occurs in the 1s place or the 2s place. So that's why this is the correct rule; and that's not a proof, exactly, but using the paper linked above it can be turned into one.
Josh says Steven Miller might be a good person to talk to determine whether any of this is original and where I can find references for whatever might need citing... well, I'm not going to even think about writing a paper on this until various other papers are out of the way!
EDIT much later: Btw, if we want the overall natural two-dimensional natural density for the different possibilities -- well, actually proving it seems annoying, but for a difference of 0, it ought to be 2φ-5/2 (i.e. √5-3/2), for a difference of 1 it should be 1-φ/2, and for -1 it should be 5/2-3φ/2. (And for 1 or -1, it should be 7/2-2φ, or 5/2-√5.)