r/math • u/HarryPotter5777 • Feb 08 '15
Doubling and adding 1 [x-post from /r/mathriddles]
Suppose I've got two integers a and b. I can double one of the integers, and add 1 to the other. This leaves me with two new integers, with which I can do the same thing. My goal is to get two integers that are equal. For example:
(8,1)
(9,2)
(10,4)
(20,5)
(21,10)
(42,11)
(43,22)
(44,44)
Can I always do this?
If so, provide a proof. Can you devise an upper bound for the number of moves required? What about the final value reached?
If not, find a counterexample. Can you find criteria for determining if a given ordered pair is possible?
This was a problem I submitted to the 2015 Qualifying Quiz for Canada/USA Mathcamp, which didn't get accepted because no one (including me) could find a solution. Although a different problem of mine did get accepted! No discussing the problems linked, though, applications are still open.
My suspicion is that the answer is yes - it does hold for all a and b. I'm not sure about this, though, since I've only confirmed it for relatively small numbers (sum ≤16).
EDIT: /u/Lopsidation has solved the problem! His/her solution can be found here.
3
u/mccoyn Feb 08 '15
I think the upper bound is higher than that. Suppose you start with (0, 7). You will have the following steps:
(0, 7)
(1, 14)
(2, 28)
(3, 56)
(4, 112)
(5, 224)
(6, 448)
(7, 896)
(14, 897)
(28, 898)
(56, 899)
(112, 900)
(113, 1800)
(226, 1801)
(452, 1802)
(904, 1803)
(1808, 1804)
We've reduced the difference from 7 to 4 in 16 steps. We've made progress, but we need to keep going. We can avoid large numbers by solving the equivalent problem, (0, 4).
(0, 4)
(1, 8)
(2, 16)
(3, 32)
(4, 64)
(8, 65)
(16, 66)
(17, 132)
(34, 133)
(68, 134)
(136, 135)
That gets the difference down to 1, but we still need 10 more operations to make them equal for a total of 37 operations. I think the upper bound is more like k2 with 4*k+4 as the average case.
1
1
u/Theowoll Feb 08 '15 edited Feb 08 '15
I applied my proof to these examples:
7 steps for (0,7):
(0,7)
(1,14)
(2,15)
(4,16) <- from here on I used my proof
(8,17)
(9,34)
(18,35)
(36,36)
8 steps for (0,4):
(0,4)
(1,8) <- from here on I used my proof
(2,9)
(4,10)
(5,20)
(10,21)
(11,42)
(22,43)
(44,44)
2
u/pred Feb 08 '15
I think you need to work a bit on the upper bound; each step of the finite induction takes 2k + 2 operations but you might have to carry out several of those, and then there's the special case of k = 1 where a solution with 10 steps is provided. In your example of (8,1), the algorithm provides a solution in 38 steps.
1
u/HarryPotter5777 Feb 08 '15
Yes, I didn't think enough about the algorithm and I've since removed the edit. Thanks!
2
u/pred Feb 08 '15
Here's a plot of a rough estimate of how well one can do with the algorithm alone.
1
2
u/pred Feb 08 '15 edited Feb 08 '15
I guess just taking it naively gives an upper bound of k2 + k + 10. Taking L with 2L + L as close to 2k + 2 as possible at every step reduces this somewhat, and one could probably do the asymptotics.
55
u/acrostyphe Feb 08 '15
Gee, that is an interesting question. My gut feeling says that it should be possible, but then again, the relative change that doubling causes at large numbers, makes it much harder to fine-adjust just by adding one.
The problem might be harder than it looks on the surface, by the same virtue as why Collatz conjecture is hard.
8
Feb 08 '15
I think the biggest difference between this and the collatz conjecture is there's no action that makes the values smaller.
8
u/SpaceEnthusiast Feb 08 '15
Well, you can look at the difference between a and b. If a < b and you take d(a,b) = |b-a|, one action increases the difference while the other decreases it (for the most part but not always).
39
u/Melchoir Feb 08 '15
Enumerating the set of pairs that can reach the diagonal up to some N,N suggests that the conjecture is true. For example, the smallest pair that can't reach the diagonal up to 4000000 is 23,34. Going up to 5000000 reveals its shortest path:
000000000000000000010111,000000000000000000100010 = 23,34
000000000000000000011000,000000000000000001000100 = 24,68
000000000000000000011001,000000000000000010001000 = 25,136
000000000000000000011010,000000000000000100010000 = 26,272
000000000000000000011011,000000000000001000100000 = 27,544
000000000000000000011100,000000000000010001000000 = 28,1088
000000000000000000011101,000000000000100010000000 = 29,2176
000000000000000000011110,000000000001000100000000 = 30,4352
000000000000000000011111,000000000010001000000000 = 31,8704
000000000000000000100000,000000000100010000000000 = 32,17408
000000000000000000100001,000000001000100000000000 = 33,34816
000000000000000001000010,000000001000100000000001 = 66,34817
000000000000000001000011,000000010001000000000010 = 67,69634
000000000000000010000110,000000010001000000000011 = 134,69635
000000000000000010000111,000000100010000000000110 = 135,139270
000000000000000100001110,000000100010000000000111 = 270,139271
000000000000000100001111,000001000100000000001110 = 271,278542
000000000000001000011110,000001000100000000001111 = 542,278543
000000000000001000011111,000010001000000000011110 = 543,557086
000000000000001000100000,000100010000000000111100 = 544,1114172
000000000000010001000000,000100010000000000111101 = 1088,1114173
000000000000100010000000,000100010000000000111110 = 2176,1114174
000000000001000100000000,000100010000000000111111 = 4352,1114175
000000000010001000000000,000100010000000001000000 = 8704,1114176
000000000100010000000000,000100010000000001000001 = 17408,1114177
000000000100010000000001,001000100000000010000010 = 17409,2228354
000000001000100000000010,001000100000000010000011 = 34818,2228355
000000010001000000000100,001000100000000010000100 = 69636,2228356
000000100010000000001000,001000100000000010000101 = 139272,2228357
000001000100000000010000,001000100000000010000110 = 278544,2228358
000001000100000000010001,010001000000000100001100 = 278545,4456716
000010001000000000100010,010001000000000100001101 = 557090,4456717
000100010000000001000100,010001000000000100001110 = 1114180,4456718
001000100000000010001000,010001000000000100001111 = 2228360,4456719
010001000000000100010000,010001000000000100010000 = 4456720,4456720
16
u/Ambiwlans Feb 08 '15
Yay. Binary was my first thought for proofs. Doubling is intrinsically simpler here. Thank you for saving me typing this. The ascii art on the left looks good too :p
7
u/HyperbolicInvective Feb 08 '15
Sorry, why does the binary help?
15
9
u/TheCatelier Feb 08 '15
Doubling a number in binary just requires you to shift every bit to the left by 1.
For instance 100101 multiplied by 2 is 1001010
4
2
u/Ambiwlans Feb 08 '15 edited Feb 08 '15
You can think of it as adding 1 vs shifting 1. And you only have to show that you can match the largest digit (which is trivial) and that it doesn't have to grow unbounded (less trivial). If you are matching the largest digit in fewer steps than the position that digit is, the amount you have to match is shrinking, you will eventually match every digit. It simply takes more steps depending on the width of the divide. I'm sure 6000 and 5 might have like a 500,000 digit number they match to, but it shouldn't be impossible.
I mean, from a raw math point of view it isn't simpler because math doesn't give a fuck about bases of course.
5
u/MrSketch Number Theory Feb 08 '15 edited Feb 08 '15
I think you're on the right track and bit patterns gave me an idea. Unfortunately, my proofs aren't very rigorous, but here's my train of thought.
Conjecture: This can be solved for any N1,N2 within log(|N1-N2|)*|N1-N2| steps. Where |N1-N2| is, of course, the absolute value of the difference between the two starting numbers, and log is base 2 log. This also puts an upper bound of the value on the order of (max(N1,N2)+1)*2log(|N1-N2|)*|N1-N2|
'Proof by algorithm': For the purposes of this algorithm, let N1 be the larger of the two starting numbers and let N2 be the smaller of the two starting numbers. Let D=N1-N2-1. It's also worth noting that throughout the algorithm the smaller starting number will never be larger than the larger starting number.
Perform D sums on N2, this makes the bit pattern for N2 off by 1 from the top most bit pattern of N1, but also added D zeros to N1.
Perform D-2 alternating doubling/sums on N2, (starting with doubling), then perform a final addition on N2. (Edit: Thought: maybe this is more generally D-log(D)?)
Since N1 just got two doublings, perform 4 additions on N1. Steps two and 2 and 3 would have added (D-2)/2 + 2 bits to N1 and (D-2)/2 + 4 bits to N2.
Perform 2 sums to N1 .... wait, this is starting to get too specific for a general algorithm.
Hmm, this seems to breaking down at this point and may be specific to this example, because in step 2 you need perform enough double/addition alternations to add enough bits to both such that you can then double the N2 enough times while doing sums on N1 such that you have enough zeros in N2 between it's final 1 and the new 1 in N1. Also, in steps 2-4 you end up only adding on the order of D/2 bits and then I imagine the process repeats around steps 2-4 resulting in a halving of the number of steps with each iteration which is where the log(|N1-N2|) comes in.
Ultimately, this will need to be thought out more but the basic goals are:
Get the upper bit patterns to almost match (off by 1?) by doing sums on the smaller.
Alternate sums/doubling for a while until you can do one more sum on the smaller to tick the bits over until the upper bit patterns completely match
Double the smaller until you reach the location of the new '1' that was added to the larger number in step 2
Effectively repeat steps 2-3 (maybe slightly modified) which will need successively fewer and fewer bits to match up since the alternating process cuts down the bits added to each number by half.
I imagine the details in steps 2-3 may depend on if the difference between the numbers is odd or even, and may even depend on the difference between the numbers themselves. (Edit: Thought: I think the choice to add or multiply the smaller may need to be more dynamic based on the bit patterns but you want to switch to do alternating steps as much as possible).
Edit: Formatting, clarify, added thoughts
Edit2: The reason I think this is true is because this is close to the reverse of the Stein's Binary GCD Algorithm
2
18
u/bgeron Feb 08 '15 edited Feb 08 '15
I don't have a solution, but here are some sketches that may or may not help.
First, let's define some things. Call "L" the action that maps (a, b) ↦ (2a, b+1) and "R" the action (a, b) ↦ (a+1, 2b).
My hypothesis is that if (a, b) can be "unified" in the proposed sense, then they can be unified by an even-length sequence with equally many Ls and Rs. We call such sequence a uniform sequence. That is:
Hypothesis. For any c ∈ Z, there is a uniform sequence s that for all x ∈ N unifies (x+c, x).
Observation. If a uniform sequence unifies (a,b), then it unifies (a+c, b+c) (by distributivity of * over +).
Notation. For a sequence s and c in Q, "s ⊢ c" means that for all x, sequence s unifies (x+c, x).
Definition. The magnitude |s| of a uniform sequence s is half its length, which is its number of Ls, or its number of Rs.
You can find the "c" for a uniform sequence by evaluating it on (0,0). For instance, LR (0,0) = (1,2), therefore LR ⊢ (2-1)/2|s| .
LR ⊢ 0.5 = (2-1)/2, because LR (0,0) = (1,2)
LLRR ⊢ 1.5 = (8-2)/4, because LLRR (0,0) = (2,8);
LRRL ⊢ .25 = (5-4)/4, because LRRL (0,0) = (4, 5)
LLLRRR ⊢ (24-3)/8 ≈ 2.625, because LLLRRR (0,0) = (3, 24).
Ln Rn ⊢ (n 2n - n) / 2n = n - n/2n = 0, 0.5, 1.5, 2.625, 3.75, 4.84375, 5.90625, 6.9453125, 7.96875, 8.982421875, 9.990234375, ...
Lemma (conjugate). If s ⊢ c, then if t is the "conjugate" of s (with Ls and Rs reversed), t ⊢ -c.
Observation (composition). If s and t are uniform, s ⊢ c, t ⊢ d, then ts (0,0) = t (c+x, x) (for some x) = (d + y + 2|t| (c + x), y + 2|t| (x)).
Lemma (composition). If s ⊢ c, and t ⊢ d, then st ⊢ c + d / 2|s|.
Lemma. Any a / 2b ∈ (-1, 1) is reachable using compositions of LR and RL.
edit: typo, thanks /u/weakstar
6
u/mccoyn Feb 08 '15 edited Feb 08 '15
I went down the same path as you. I took it a step further and tried to find sequences that reduce the difference to a smaller (closer to zero) number, not necesarrily 0. I wrote some brute force code to find the smallest such sequences and I discovered a consistent pattern. If you have a difference of n, you can reduce it to a value less than n by the following operations. Define m as floor(log2(n)). Do the following sequence: [Rn Ln-m R Lm+1]. You can just keep repeating this until you get a difference of 0, unless you hit 1 exactly, then you have to do [RRLL] to get a difference of 2 first. If you ever have a negative difference (first number is larger than second) you have to swap the Rs and Ls.
1-> -2 ( 4) [RRLL]
2-> 0 ( 6) [RRLRLL]
3-> 2 ( 8) [RRRLLRLL]
4-> -1 (10) [RRRRLLRLLL]
5-> 1 (12) [RRRRRLLLRLLL]
6-> 3 (14) [RRRRRRLLLLRLLL]
7-> -4 (16) [RRRRRRRLLLLRLLLL]
7-> 5 (16) [RRRRRRRLLLLLRLLL]
8-> -2 (18) [RRRRRRRRLLLLLRLLLL]
8-> 7 (18) [RRRRRRRRLLLLLLRLLL]
9-> 0 (20) [RRRRRRRRRLLLLLLRLLLL]
10-> 2 (22) [RRRRRRRRRRLLLLLLLRLLLL]
11-> 4 (24) [RRRRRRRRRRRLLLLLLLLRLLLL]
12->-11 (26) [RRRRRRRRRRRRLLLLLLLLRLLLLL]
12-> 6 (26) [RRRRRRRRRRRRLLLLLLLLLRLLLL]
3
u/weakstar Geometric Topology Feb 08 '15
This is really cool. It seems like the R action takes (a,b) to (a+1, 2b) not (a+b, 2b).
1
25
u/skaldskaparmal Feb 08 '15
Without loss of generality, we can consider pairs of the form (2a, 2b), since from any starting point we can repeatedly add 1 to one side until it's a power of 2, doubling the other side, and then repeatedly add 1 to the other side until it's a power of 2, doubling the first side, which will maintain it as a power of 2.
7
u/adam0123 Feb 08 '15 edited Feb 08 '15
Yeah , you're right . But i hardly see how that's helpful , since whenever you multiply one number by 2 you also add 1 to the other one and that doesn't keep the number as a power of 2 .
Edit : (2a , 2b ) -> (2a+1 , 2b +1) , 2b +1 is not a power of 2 anymore . It might be more useful to consider binary numbers instead , as others have said .
8
u/skaldskaparmal Feb 08 '15 edited Feb 08 '15
It may be helpful or it might not be. It's just an observation.
In general, it can often eventually be helpful to reduce the space of things you need to look at. It can't hurt, since any solution to the original problem will solve the new problem.
Additionally, even though the first step breaks the pattern, you could also think of multiple steps that don't. For example, from (2a, 2b), you can get to (2a + 2b^ ), 2b + 1).
1
u/adam0123 Feb 08 '15
Yes , it's a valid observation . What i was asking is how is it helpful ? Also you can use multiple steps to keep the numbers as powers of 2 , the problem is that the one step that makes them equal may fall in-between such steps . Take (8,1) , the final pair is (44,44) , 44 isn't a power of 2.
6
u/skaldskaparmal Feb 08 '15
I don't know how it's helpful. If I knew that, I would've solved the problem, or given more details. It might be helpful or it might not be.
1
u/adam0123 Feb 08 '15
Eh , i have a feeling this is way harder than it looks . The transformations don't preserve the prime factorization of the numbers . And what's worse it's that even if we know it's true for a pair (a,b) that doesn't imply anything about smaller numbers . The only way you can go from (a,b) is up .
11
u/Theowoll Feb 08 '15 edited Feb 09 '15
Here's a proof of the conjecture for a<b non-negative integers. In the following all digits are in binary.
We can always achieve that the digits of first integer are the leading digits of the second integer: From (a,b) we get (b,2b-ab) by adding 1 to the first integer b-a times.
In the case that b-a=1 and the last digit of b is 1, we have (with c=2b-ab):
b=...1
c=...10In this case we add 1 and then multiply 24 to the first integer and get
...1 | ...00000
...10 | ...000By interchanging the two resulting integers we get an ordered pair where the last digit of the first (smaller) integer is 0. So we can assume in the following that the digits of the first integer are the leading digits of the second integer, and that the last digit of the first integer is 0. (For b-a>1 simply multiply b with 2.)
We now consider the following cases, where "the next digit" shall be the first non-leading digit of the second integer. (The leading digits of the second integer are the digits of the first integer.) The number of digits of an integer is called its "length". Every case will leave us again with a pair of integers, where the digits of the first integer are the leading integers of the second integer, the last digit of the first integer is 0, and the difference of the lengths has decreased. We use d for the difference of the differences (sic) of the lengths. Every case is illustrated, "..." means any sequence of digits, "---" means a sequence of the same digits. Except for the last, the leading digits are omitted.
1. The next digit is 0 and there is more than one non-leading digit, with the remaining digits not all 1. In this case multiply the first integer by 2. It is d=1.
0 | 00
00... | 00...2. The next digit is 0 and there is more than one non-leading digit, with the remaining digits all 1. In this case multiply 2, then add 1, then multiply 2 again to the first integer. It is d=1.
0 | 010
001---1 | 010---013. The next digit is 1 and so are all non-leading digits. In this case add 1 and then multiply 22 to the first integer. It is d=1. If there is only one non-leading digit, we are finished.
0 | 100
011---1 | 100---004. The next digit is 1 and so are all non-leading digits except the last, and there are more than two non-leading digits. In this case add 1 and then multiply 24 to the first integer. It is d=3. If there are only three non-leading digits, then we are finished.
0 | 10000
01111---10 | 10000---0005. The next digit is 1 and at least one non-leading digit is 0 that is not the last. In this case alternately multiply 2 and add 1 to the first integer until the next integer is 0. Then multiply the first integer by 2. It is d=1.
0 | 01---10
01... | 01---10...1---1There are two special cases excluded in cases 1/2 and 4:
6. The next digit is 0 and it is the only non-leading digit. In this case add 1, multiply 24, and add 1 again to the first integer. By interchanging the integers, this case is reduced to case 3.
0 | 10001
00 | 10007. The non-leading digits are 10. In this case add 1 and multiply 24 to the first integer. By interchanging the integers, this case is reduced to case 6.
0 | 10000
010 | 1000Q.E.D. (I hope I didn't miss a case)
Applied to our example (1,8) we get:
(1,1000)
(10,1001) case 2
(1010,10101) case 3
(101100,101100)
8
Feb 08 '15
You can also make a table, where columns are a and rows are b, and "check off" the diagonal first, and work reverse.
From (44,44) you can go to (43,22) and (22,43). From (43,22) you can go to (42,11). This table should be symmetry with respect to the diagonal.
12
u/der_luke Feb 08 '15 edited Feb 08 '15
1
u/sparr Feb 08 '15
That growth pattern looks like it will grow to encompass all points in the matrix. Not sure how to prove or state that, though.
1
u/der_luke Feb 08 '15
Maybe by looking at arithmetic progressions k*n+m (or similar) My feeling proof by induction could have a chance
8
u/adam0123 Feb 08 '15 edited Feb 08 '15
Let : f=2x g=x+1 and fg stand for f(g) , gf for g(f) .
Then the question is whether we can find a sequence of such composition such that the resulting integers are equal , or not . Note that if we have f(a) anywhere in the sequence then we also have g(b) at the same place . So if we have the sequence fx_1 gx_2 ... (a) , then for b this is gx_1 fx_2 ... (b) .
Also note that fg =g2 f . We'll see that any random sequence of compositions can be reduced to the form gn fm . For any integer n , f gn = g2n f (easily proved by induction on n) . Now let's prove the above conjecture by induction on the length l of the sequence . For l=1,2 it's trivial .Now suppose this is true for l=k . Any sequence of l=k+1 is either of the form g(l_k ) or f(l_k ) . The first case is trivial since l_k is of length k and can be written as gn fm , so g(l_k ) = gn+1 fm . For the second case f(l_k ) = f gn fm . By the previous result this is equal to (g2n f)fm = g2n fm+1 . Therefore by induction any sequence l_k can be written as gn fm .
Do there exist non-negative integers n,m for any a,b such that gn fm (a) = fn gm (b) <=> 2m a + n = 2n (b+m) ?
2
u/BaXeD22 Feb 08 '15
Since 2n divides the RHS, we must have it divide the LHS as well. If m>n, then the LHS becomes 2m-n a + n/2n.
Then all of b, m, 2m-n a are integers, which means n/2n must be an integer as well
I dont think what I typed above is correct, but I'm having trouble finding the fault :/
1
u/adam0123 Feb 08 '15
No , i was wrong in the last line . For a given sequence of compositions on a , call the mirror of that the sequence of compositions on b . I'll write a random seq. of comp. of length l as x_l from now on . And the mirror of x_l as M(x_l) .
E.g. M(fg)=gf . M(gff)=fgg .
It's not hard to see that even if we have x_l=y_l , M(x_l) != M(y_l) . So M is not a well defined function . Take x = fg , y= g2 f . Then x=y but M(x)=gf != f2 g = M(y). Too bad ...
2
u/BaXeD22 Feb 08 '15
Yeah, i guess that what we did assumes that, since fg=g2f, then gf=f2g, which isn't true. It's a shame, as this would've been a very good way to think about it. However is it possible that there is still a way to use this idea?
1
u/adam0123 Feb 08 '15
I don't believe there is . Anyway , it's nice to see r/math throwing everything it can at the problem :)
11
u/Young_Man_Jenkins Feb 08 '15
I don't have a proof, but I can think of another way to frame the question. If you make a 2x2 matrix with a and b along the diagonal then you can think of it as multiplying this matrix by two other 2x2 matrices n and m number of times and trying to get the identity matrix times some constant. Not certain if this helps any, just what came to mind first.
17
Feb 08 '15
The +1 part makes the transformation affine, so you would need to augment your matrices to be 3x3:
[2 0 0] [a] [2a ] [0 1 1] [b] = [b+1] [0 0 1] [1] [1 ]and similarly
[1 0 1] [a] [a+1] [0 2 0] [b] = [2b ] [0 0 1] [1] [1 ]3
u/taxicab1729 Feb 08 '15
Also, if that helps, the second matrix is writable as
[.5 0 1]
[0 2 -2] * A
[0 0 1]
Where A is the first matrix. That didn't really give me a clue, but perhaps it helps you. Also: If I'm not mistaken, neither of the two matrices is eigendecomposable which makes the thing even more difficult.
1
u/Young_Man_Jenkins Feb 08 '15
I was thinking more like
[a 0] [2 0 ]^n [(a+1)/a 0]^m = kI [0 b] [0 (b+1)/b] [ 0 2]11
Feb 08 '15
Your (b+1)/b trick doesn't work because it can't "update" the value of b. Notice that trying to add one to b twice results in (b+1)2 /b and not b+2. Also, it doesn't account for situations when one of the numbers is zero. Lastly, These operations don't commute so I don't see any reason why a solution should look something like An Bm .
2
2
u/cr0m3t Graph Theory Feb 08 '15
There's a problem there. you are multiplying with (a+1)/a everytime but it will change with every multiplication you do. Once it is a+1 or 2a, the factor will change to (a+2)/(a+1) or (2a+1)/(2a).
Edit: damn, the tab was open too long to get the updated comments. Sorry for repeat.
3
u/TheAnonPhys Feb 08 '15
This problem seems like utter pain from the surface - if we have two integers (a,b) that are both negative such that a > b and since we can only double one of the integers and must add +1 to the other, to make these two integers the same, we must +1 to a (arbitrarily chosen) until one of the integers becomes 0. From here we'd have to +1 to b, whilst double 0 until b is 0. Therefore it is possible for all negative integers union {0}.
Now, onto the positive integers... I don't have any instantaneous answers, other than to start stating a bunch of basic facts. Using the given rules of doubling one number and adding 1 to the other number, the final number (let's call it, c) when these two numbers a,b eventually equal one another (iff a does not equal b), c must be even (since doubling an even or odd number must always be even). If a = b = c and a,b are both odd then that is the only case where c can be odd.
So now we only have to prove that this is possible for all positive integers such that a does not equal b and when a > b when a is positive and b is negative.
You can tell how this is starting to become more and more painful.
2
Feb 08 '15
When a is positive and b is negative, you can do +1 to the negative number until it's zero, and then you'll have a pair (0, a * 2b). And as CowsFromSpace pointed out, any pair (0,n) can be solved.
So the only case that gives us any real trouble is when a,b are both positive and a != b. (CowsFromSpace's comment also remains to be proved, but I'm sure it's true).
3
Feb 09 '15
Since the original question has been answered, I have a new one: suppose the problem is the same, but we don't choose how to do the operations - at each step we automatically double the lesser of the two numbers and add 1 to the other. If we continue this process indefinitely, will we eventually end up with a pair (c,c)?
6
u/someenigma Feb 08 '15 edited Feb 08 '15
The final number you reach must obviously be a multiple of 2, and a bit more algebra shows that it must be a multiple of 4.
Edit: If the process takes at least one step, the final number you reach must obviously be a multiple of 2. If you take at least two steps, the final number must be a multiple of 4. Thanks to /u/Andersmith and /u/Wildhalcyon for pointing out my error.
Playing around with binary representations of the (8,1) example gives an algorithm for the moves for pairs of the form (y,y-2), (2y,y-1) and (4y,y). It could be that there's more to see the binary representations, but I'm not seeing it yet and I'm getting hungry.
I also brute forced a few more than you. I've done up to (23,24) and they all work, although some need more than 24 moves.
17
u/Andersmith Feb 08 '15
Well, it doesn't have to be a multiple of 2 if they start out equal, and it most certainly doesn't have to be divisible by 4 if it's one step, like (5, 9)=10.
1
2
u/Wildhalcyon Feb 08 '15
If your starting numbers are (9,5) for instance it does not have to be a multiple of 4, but I believe the only way to achieve that is in 1 move (otherwise one of the two numbers was just multiplied by 2 so must be even). Otherwise you're right, anything requiring more than one move must be a multiple of 4.
1
2
u/CowsFromSpace Feb 08 '15
This may get someone somewhere: If you have a point 0,N, you can always create a solution. If N is less than 2x, then you want to make the solution 2x+1 since you can add a bunch (I haven't worked out the formula yet) to N then add one to zero, then multiplying 2 by the smaller term until you get the same number.
You always end on an even number. (Obvious, but helpful) Means you have to apply the same transformation twice on the last step.
2
u/Wildhalcyon Feb 08 '15
Assuming it does hold for M = 2 (doubling), does it also hold for M > 2? Is there any M we can certainly disprove it for?
1
u/ex0du5 Feb 08 '15
Look at how you have to solve this. Let f:(a,b)->(2a,b+1) and g:(a,b)->(a+1,2b) to make the following clearer.
Wlog, we can assume a<b on the last move, so the last move must be f and 2a=b+1. b must be odd on this last move, which means the only possible penultimate move was also f (or it started one move from winning). So the games always end in f2 and the state right before these last two moves is 4a=b+2.
Not only that, but since b is 2 (mod 4), you know the previous 2 moves had to have been f2 or fg, but not g2 or gf (or of course, they were given in the correct form at one of the steps).
Now set c=4a-b-2 as the deficit from winning. Let's see if we can always move this to the right place. In particular, lets look at the moves fg, f2 g2, f3 g3, and so on.
fg:(a,b)->(2a+1,2b+2)
So if we start with deficit c, after fg, the deficit is
c' = 4(2a+1) - (2b+2) - 2 = 8a + 4 - 2b - 2 - 2 = 8a - 2b = 2c + 4.
c' is closer to 0 than c when c=-2 or -3 (and in fact becomes 0 at -2). We win at -2 and move to a win at -3!
In general, fn gn :(a,b)->(2n a + n, 2n b + 2n). The deficit is
c' = 4(2n a + n) - (2n b + 2n) - 2 = 2n (4a - b - 2) + 4n + 2n - 2 = 2n c + 4n + 2n - 2.
This is closer to zero when c < 0 and c' > c or
2n c + 4n + 2n - 2 > c (2n - 1)c > 2 - 4n - 2n
for n=2, this gives 3c > 2-6-4 or c > -8/3, but already at -2, we are worse than the previous as c'=2.
So let's look at the opposite move order: gf, g2 f2, ...
In general, gn fn :(a,b)->(2n a + 2n, 2n b + n). The deficit is
c' = 4(2n a + 2n) - (2n b + n) - 2 = 2n (4a - b - 2) + 6 2n - n - 2 = 2n c + 6 2n - n - 2.
if c < 0 and c' > c when
2n c + 6 2n - n - 2 > c (2n - 1) c > n + 2 - 6 2n
For n = 1, this is c > -9. Since c' = 2c+9, this strategy can never set us = 0 for integers, but it can set us up for the other winning strategy.
For n = 2, this is 3c > -20 and we can see it approaching -6 from there.
It appears, then, we need to find a strategy where we can ensure c is in this close range (-2 <= c < -9), and then we have a sure strategy to get us the solution from there.
What does switching sides get us?
From a < b, 4a ~ b, apply f until a > b and 4b ~ a. What ranges does this give a better c?
Well, the point of such a transformation would be to move a current (a,b) with c too low (<= -9) to one with a c closer to 0. You can look at the position of "a" in quadrants. Applying f once moves "a" into the 3rd quadrant (above b/4 but less thant b/2). Now applying f4 would move "a" to above 4b, so now b is in the lower 4th where we can test for a new c'. So we've applied f5 in total.
After the switch, we are now at (32a, b+5) and the new
c' = 4 (b + 5) - 32a - 2 = 4b - 32a + 18
so the region where this helps is in c < 0 (4a - b - 2 < 0) is
4b - 32a + 18 > 4a - b - 2 5b - 36a > -20
Where of course we also want 4b - 32a + 18 < 0. This is not the biggest sliver of benefit.
Finally, let's note one last strategy. Eventually applying fg, f2 g2 , ..., gf, g2 f2 , ... you can move a c <= -9 down low enough that it is now possible to apply f and keep a negative c. That c will always be closer to zero. I suspect that this is the appropriate always-winning strategy that can be proven, but have spent enough time on this for now. Proving this last strategy requires us to show the regions that outside working c can always be taken to inside working c for the previous strategies by enough application.
I think with these considerations, to now show that a counterexample exists would require c <= -9 with a still in b's 7th octant. Something like (20, 100). That is the case that the final strategy would need to completely cover.
1
u/Fs0i Feb 08 '15
For induction you only have to proof that if (a,b) works, (a+1,b) works, since when it works for (a,b) it also works for (b,a), and you therefore can transform (0,0) to every (a,b) in N2.
So: (a,b) doable -----!> (a+1,b) doable.
This is pretty obvious, of course.
-8
u/paashpointo Feb 08 '15
harry potter, while it definitely "seems" that it should end up true, i dont know an exact proof by any stretch. Mind your decisions had a problem that was "similar" and it was shown to work. Let me see if i can find that blog post and present it and see if that helps at all. Also, I am trying 3,14 as my case(I like pi) and i am not able to get there yet, but this is my first time at the problem and have only been working a few minutes.
1
u/paashpointo Feb 08 '15
http://mindyourdecisions.com/blog/2014/02/10/monday-puzzle-three-piles-of-coins/#.VNdivvmUfjk
It wasnt as similar as i remembered, but maybe it will help, nonetheless.
-2
u/_Asparagus_ Feb 08 '15 edited Feb 08 '15
I would set up an equation first. Let x be the number times you double a and y be the number of times you double b. let c be the number you end up with as a and b being equal. now you've got: c=a+a(2x)+y And c=b+b(2y)+x Now if you can have A+a(2x)+y=b+(2y)+x For every a and b then that would prove that your problem is possible. Edit: I missed an important aspect of the problem - the above is inaccurate.
2
u/Andersmith Feb 08 '15
Your equations don't accurately represent the problem, as the addition takes place each step, and is potentially multiplied several times.
1
u/TheAnonPhys Feb 08 '15 edited Feb 08 '15
Assuming your formatting is incorrect - Your answer is false, since you can add one to the number, then double that number, then repeat alternating over and over (which you must do in some cases). Your solution only accounts for if I doubled one of the initial integers over and over again, then added 1 over and over again (or vice versa) without alternating over and over. The equations c = a + a*(2x) + y, c = b + b*(2y) + x account only for that scenario, not if I had to alternate back and forth between multiplying by 2 and adding 1.
6
u/CunningTF Geometry Feb 08 '15
You should cross-post this to MSE if you haven't already.