Pages

Bookmark and Share

Monday, April 8, 2024

Infinite sum with calculus

Prove that $$\sum_{k=1}^\infty \frac{\binom{2n}{n}}{4^n(2n+2)(2n+3)} = 1 - \frac{\pi}{4} $$

Wednesday, March 23, 2022

Partition Game

Alice and Bob are playing a game as follows. Originally there are $n > 1$ piles containing $s$ stones each. Alice starts by taking the first turn and at each step, the player chooses one pile and discards the other piles. Then that player divides the stones from that one pile into $n$ piles, such that each pile still contains at least 1 stone. The player that cannot move loses.

Determine all $s$ such that Alice has a winning strategy

Solution

We classify every natural numbers into winning numbers or losing numbers with the following recursion: The numbers $1, \dots, n-1$ are losing numbers. If a number can be partitioned into losing numbers, then it's a winning number. Otherwise it's a losing number. In other words, any given partition of a losing number must contain a winning number.

Now the game is a standard Sprague-Grundy game. If a player receives a state where one pile contains a winning number, then that state is a winning state. For example, $n$ is a winning number because the player can split it into ones, regardless of what the other numbers in the pile are. If a player receives a state where all piles are losing numbers, then it's a losing state.

Let $m=n-1$. Now we establish the base cases. $1, \dots, m$ are losing numbers. Then $n$ can be partitioned into all ones, and $mn$ can be partitioned into all $m$'s. It's easy to show that all the numbers in between can also be partitioned into summands between $1$ and $m$ inclusive, so $n,\dots,mn$ are winning numbers.

Now we claim: Let $x \equiv p \mod mn$ then $x$ is a winning number if and only if $p = 0$ or $p \geq n$, and it is a losing number if and only if $p \in [1,m]$. We prove it by induction on $k = \lceil x / mn \rceil$. The case of $k = 1$ is proven by the base case above.

Now suppose we have a number $x$ with residue in $[1,m] \mod mn$ and there is a way to partition this number into $n$ summands, all while staying within $[1,m] \mod mn$. The smallest sum (in the residue space) that can be attained is $n$, and the largest sum is $mn$, and they are all outside of $[1,m]$, a contradiction. So some of the summands must have residue $0$ or $\geq n \mod mn$. Let $y$ be this summand. Note that $ \lceil y / mn \rceil < \lceil x / mn \rceil$ in each of these cases. So $x$ is a losing number by induction hypothesis.

Now suppose we have a number $y$ divisible by $mn$, then we can partition it into $n$ numbers all having residue $m$. The easiest is of course to have the first $m$ terms $m$ and have the last term $y - m^2 = kmn - m^2 = (k-1)mn + m$. Each of these numbers are losing numbers with less quotient than $y$, so $y$ is a winning number.

Next, suppose we have $y$ with residue $[n, mn-1]$. Using the same argument as above, we can see that it can always be decomposed into the sum of $n$ numbers with residue $[1,m]$. However, the quotient of the summands are not necessarily less than $y$, but we have proved that the set in $[1,m]$ with quotient $k$ are losing numbers as well.

Friday, March 11, 2022

Toggling lights 3 at a time

Alice and Bob are playing a game. $n$ lights are put on a line with individual switches, initially all off. Then the two phases happen as follow:

1. Alice turns on some of these lights

2. Bob may do these actions: choose a contiguous block of 3 lights and toggle these 3 lights. He may repeat these actions as many times as he wants for different blocks.

And the scoring of the game is as follows:

In phase 1, Alice gets a -1 point for each light that she turns on. In phase 2, Alice gets a +1 point every time Bob performs an operation. Then at the end of the game, Alice gets $i$ points if light $i$ is on. Obviously Alice wants her score to be as high as possible, and Bob wants her score to be as low as possible. Determine the maximum points that Alice can get if both players are playing optimally.

Solution

Let $T_k$ denote the action by Bob of toggling a contiguous block of $k, k+1, k+2$, where $k \in [1, 98]$. If light $k+3$ is on and light $k$ is off, by performing $T_k + T_{k+1}$ he can turn off $k+3$ and turn on $k$. The net effect to the score is -1 so this move is beneficial to Bob. Therefore, he would keep doing it as long as there are lights on at $k > 3$. Furthermore, if there are 2 lights on $k > l$ such that $k \equiv l \mod 3$ then by repeating the operation above Bob can turn off both lights. The net effect to the score is $-k-l+2\frac{k-l}{3} < 0$. This means that it is not optimal for Alice to turn on two lights that have the same residue mod 3. So at most Alice should turn on 3 lights. But even then, if we ever arrive at the condition where lights $(1,2,3)$ are on, then Bob can perform $T_1$ to turn off all the lights. So Alice should turn on at most 2 lights.

The final condition that is most beneficial to Alice is either $(3)$ or $(1,2)$, both having the same value, and both are accessible from each other in phase 2. But obviously it's more beneficial for Alice to turn on only 1 light, and it should be the largest light divisible by 3, so that Bob has to spend a lot of moves moving it to the smaller number. So Alice should turn on $3\lfloor n/3 \rfloor$, and Bob will have to move it all the way to 3.

The total score is then $-1 + 2\lfloor n/3 \rfloor + 3 = 2\lfloor n/3 \rfloor +1$

Note: the number 3 can be replaced by a larger number $p$ but the principle is the same. Any light on above $p$ can be shifted down for a net gain for Bob. However, the final condition is tricky. Take $p=5$ for example. We don't want $(1,2,3,4,5)$ because then Bob can simply turn them all off in one fell swoop. We also don't want $(3,4,5)$ because Bob can still replace it by $(1,2)$ for a net gain. In fact, the optimal condition for Alice is $(3,5)$ because while Bob can replace it by $(1,2,4)$, it costs him 1 point to do so, so it's not a beneficial move for Bob. Likewise, for $p=6$, the best condition for Alice is $(5,6)$ because it's "just under" $(1+2+3+4+5+6)/2$. The number of lights that would be left on so that the sum is just under $n(n+1)/2$ is $\lfloor (n-1)/2 \rfloor$ which can be proved by induction. However, the exact configuration is harder to determine in closed form expression. This matters because in the course of shifting the lights down during phase 2, Bob may inadvertently have to perform the same $T_k$ twice in which case he would just not perform that action, so the calculation of final point count becomes more complicated.

Wednesday, March 2, 2022

Hyper-triangular numbers

Triangular number $T_n$ is defined as $T_n = 1 + 2 + \dots + n$.

Tetrahedral number $R_n$ is defined as $R_n = T_1 + T_2 + \dots + T_n$.

Let $T^k_n$ denote the $k$-th dimensional triangular numbers, with $T^1_n = 1+1+\dots+1 = n$, $T^2_n = T_n$, and $T^3_n = R_n$. Specifically, the higher dimensional triangular numbers are defined as: $$ T^{k+1}_n = T^k_1 + T^k_2 + \dots + T^k_n$$ Prove that: $$T^k_n.T^m_1 + T^k_{n-1}.T^m_2 + \dots + T^k_1.T^m_n = T^{k+m+1}_{n+1}$$

Tuesday, March 1, 2022

Number of contiguous blocks containing black balls over all permutations

$k$ black balls and $n-k$ white balls are arranged on a straight line, where $n \geq 1$, $0 \leq k \leq n$. The score of the said arrangement is the number of contiguous subsequences that contain at least one black ball. For example, the arrangement $W W B W B$ has two subsequences of length 1, and three subsequences of length 2 that contain at least one black ball. Of course there are subsequences of length 3 or higher as well, so the total score for this arrangement is 11.

What is the sum of the score of all $\binom{n}{k}$ arrangements? You may express this quantity in a recursive formula computable in $O(n^2)$ time, $O(n \log n)$ time, or $O(n)$ time.

Solution 1

We give a recursion formula computable in $O(n^2)$ time with DP.

More to come...

Solution 2A

We prove that the number is $\binom{n+2}{k+2} . \binom{k+1}{2}$ which is computable in $O(n)$ time simply by calculating the factorial table

First let $T_n$ be the $n$-th triangular number, $T_n = n(n+1)/2 = \binom{n+1}{2}$. And we also will use the following well-known identity a lot: $$\sum_{i=1}^{n} \binom{i+p-1}{p} = \binom{n+p}{p+1}, p \geq 0$$ It can be proven many ways, either with induction on $n$ keeping $p$ fixed, induction on $p$ keeping $n$ fixed, or telescoping sum, or using combinatorial arguments (choosing $p+1$ items, and condition on the first item chosen). For $p = 0$ it is a trivial sum, and for $p = 1$ it is the definition of triangular numbers.

Note that if all balls were black, then every single contiguous blocks would contribute to the score. There are $1 + 2 + \dots + n = T_n$ such blocks and that is the score. But if there are white balls, then we want to calculate how many scores are lost due to these pockets of white balls, over the course of all different arrangements.

Now given a particular arrangement of $k$ black balls and $n-k$ white balls, we come with an associated sequence of $k+1$ integers denoting the number of white balls in between black balls, including before the first black ball and after the last black ball. For example, the sequence WWBWWWBBBW corresponds to the sequence $(2, 3, 0, 0, 1)$. Each element in this sequence must be non-negative and they must add up to $n-k$, and there must be exactly $k+1$ integers.

Lemma

Suppose $A$ is the set of all sequences of non-negative integers with length $m \geq 2$ that sum up to $M$, that is $$ A = \{ (a_1, \dots, a_m) | a_i \geq 0, a_1 + \dots + a_m = M \}$$ then:

1. There are $|A| = \binom{M+m-1}{m-1}$ possible sequences.

2. If $m \geq 2$, the number $t \in [0,M]$ occurs $m \binom{M-t+m-2}{m-2}$ times in $A$, in any position.

We prove by induction. For $m=2$, the possible sequences are $A = \{(M,0), (M-1,1,), \dots, (0,M)\}$ so $|A| = M+1$ and there are two occurrences of each number.

Now suppose it holds for $m$, now for $m+1$, consider the first element $a_1 \in [0,M]$. Once its value is chosen, then we have $m-1$ numbers that need to sum up to $M - a_1$. So there are $\binom{M-a_1+m-2}{m-2}$ ways to do this, by induction hypothesis. The total number of ways is the sum of that expression when $a_1$ ranges from $0$ to $M$. $$\sum_{a_1 = 0}^M \binom{M-a_1+m-2}{m-2} = \sum_{i=m-2}^{M+m-2} \binom{i}{m-2} = \sum_{j=1}^{M+1} \binom{j+(m-2)-1}{m-2} = \binom{M+m-1}{m-1}$$ The first two equalities are change of variables, but the last one utilizes the identity above. We have proved the first assertion. For the second assertion, consider the case where the first element $a_1 = t$. The rest of the $m-1$ elements must sum up to $M-t$, so there are $\binom{M-t+m-2}{m-2}$ ways to complete the sequence. However, the number $t$ may appear in any of the other positions as well, so in total there are $m$ times that amount.

One might ask that sometimes the number $t$ itself my appear as a duplicate in multiple elements. For example for $m=4$ and $M=11$, we have have a sequence $(2,2,5,2)$ which should only be counted once. Indeed, when we consider $a_1=1$, we contributed one count towards the total number of "2" appearing. Likewise, when we consider $a_2=2,a_4=2$ we also added one count each time, but the sequence itself contributes three counts towards the appearance of "2." So the total amount is exact and correct, and there is no need to compensate for double counting. Thus the lemma is proven

Alternatively, one could also prove the first assertion by using a combinatorial argument. Consider $M+m-1$ spaces and we are to choose $m-1$ spaces to serve as separators. The spaces between the separators will be the numbers in the sequence.

Now observe that each arrangement corresponds one-to-one with a sequence like we described above. The process to convert from an arrangement to a sequence is invertible. Therefore, the total number of contiguous blocks in all arrangements is $$ T_n \binom{(n-k)+(k+1)-1}{(k+1)-1} = T_n \binom{n}{k} $$ But a lot of these blocks would contribute zero towards the total score. That is, for each sequence $(a_1, \dots, a_{k+1})$, the total loss of scores is the number of contiguous blocks that are contained fully within those pockets of white balls, that is: $$T_{a_1} + \dots + T_{a_{k+1}}$$ So we have to add these over all the possible sequences whose sum is $n-k$. This is where we utilize the lemma. Each time the number $t$ appears, it contributes $T_t$ towards the total loss of score. But thanks to the lemma, we know that the number $t$ appears exactly $$(k+1) \binom{(n-k)-t+k-1}{k-1} = (k+1) \binom{n-t-1}{k-1}$$ times. So the total loss of scores is the sum of this quantity as $t$ ranges from one to $n-k$. (Technically $t=0$ is a valid scenario but it incurs no loss of score because $T_0 = 0$ so we ignore it). $$\sum_{t=1}^{n-k} (k+1) \binom{n-t-1}{k-1} T_t $$ At this point, this sum can be computed in $O(n \log n)$ times using FFT technique, as it's a sum of terms expressed in $t$ and $n-t$, but we can simply the terms further to arrive at a closed form solution, by repeated use of the identity above. Let $B_i = \binom{i+k-2}{k-1}$ (where $k > 0$ is fixed), and for any $m > 0$: $$ B_1 + \dots + B_m = \sum_{i=1}^{m} \binom{i+k-2}{k-1} = \binom{m+k-1}{k}$$ by direct application. Then: $$ \sum_{i=1}^{m} (m+1-i). \binom{i+k-2}{k-1} = m.B_1 + (m-1).B_2 + \dots + 1.B_{m} = B_1 + (B_1+B_2) + \dots + (B_1 + \dots + B_m) = \sum_{i=1}^{m} \binom{i+k-1}{k} = \binom{m+k}{k+1}$$ One more time: $$ \sum_{i=1}^{m} T_{m+1-i}. \binom{i+k-2}{k-1} = T_m.B_1 + T_{m-1}.B_2 + \dots + 3.B_{m-1} + 1.B_{m} $$ $$ = [1+2+ \dots + m]B_1 + [1+2+ \dots + (m-1)]B_2 + \dots + [1+2]B_{m-1} + 1.B_m$$ $$ = 1.B_1 + (2.B_1 + 1.B_2) + (3B_1 + 2B_2 + B_3) + \dots + (m.B_1 + \dots + 1.B_m)$$ $$ =\sum_{i=1}^m \binom{i+k}{k+1} = \binom{m+k+1}{k+2}$$ Now, the total loss of scores becomes: $$ \sum_{t=1}^{n-k} (k+1) \binom{n-t-1}{k-1} T_t = (k+1) \sum_{i=1}^{n-k} T_{n-k+1-i} \binom{i+k-2}{k-1}$$ due to change of variable. Now we apply the latest identity above, with $m=n-k$: $$ = (k+1) \sum_{i=1}^{n-k} T_{n-k+1-i} B_i = (k+1) \binom{n+1}{k+2}$$

So the total score is then: $$ T_n \binom{n}{k} - (k+1) \binom{n+1}{k+2} = \frac{n(n+1) n!}{2. k!(n-k)!} - \frac{(k+1)(n+1)!}{(k+2)!(n-k-1)!} = \frac{(n+1)!}{k!(n-k-1)!} \left(\frac{n}{2(n-k)} - \frac{(k+1)}{(k+2)(k+1)} \frac{n-k}{n-k} \right)$$ $$ \frac{(n+1)!}{k!(n-k)!} \left(\frac{n}{2} - \frac{n-k}{k+2} \right) = \frac{(n+1)!}{k!(n-k)!} \frac{kn+2n-2n+2k}{2(k+2)} = \frac{(n+1)!}{k!(n-k)!} \frac{k(n+2)}{2(k+2)}.\frac{k+1}{k+1} = \frac{(n+2)!}{(k+2)!(n-k)!} \frac{k(k+1)}{2} = \binom{n+2}{k+2} . \binom{k+1}{2}$$

Solution 2B

We also prove that the number is $\binom{n+2}{k+2} . \binom{k+1}{2}$ but using a different (simpler) combinatorial argument.

Given $n+2$ tokens in row, mark $k+2$ of these as blue and $n-k$ as red. There are $\binom{n+2}{k+2}$ ways to choose. And now, among the blue tokens, further mark 2 tokens as "start" and "end", with the condition that "start" must come before "end", and there must be at least one blue token between them. There are $\binom{k+2}{2} - (k+1) = \binom{k+1}{2}$ ways to choose. So the end result is an arrangement of red and blue tokens, and two tokens marked start and end containing at least a blue token in between. We will show that this arrangement corresponds to exactly one score-producing contiguous block in a particular arrangement of black and white balls, and that the mapping is invertible and thus we obtain a bijection.

Arrange the balls according to the $n$ unmarked tokens, where all $n-k$ red tokens correspond to white balls, and $k$ unmarked blue tokens correspond to black balls. The contiguous block is represented by the tokens between start and end, including all red and blue tokens. Because the start and end must flank at least one blue token, then this contiguous block contributes one point towards the score.

On the reverse, given an arrangement of balls, create the corresponding arrangement of red and blue tokens. And then insert the start token to the space right before the first ball in the contiguous block, and the end token to the space right after the last ball. Thus we have a bijection, and the number of total score is $\binom{n+2}{k+2} . \binom{k+1}{2}$.

Solution 3

We present a different combinatorial argument, this time in the permutation space, not a combination space.

First we label all the balls from $1,\dots,n$ such that all the black balls are labeled $1,\dots,k$ and the white balls are labeled $k+1, \dots, n$. Consider any given permutation of the balls, and define the score of this permutation the same way as the problem statement: the number of contiguous blocks that contain at least one black balls. Then we also consider the total number of scores of all $n!$ permutations.

Note that each arrangement of unlabeled balls corresponds to $k! (n-k)!$ permutations of labeled balls, all having the same score. So the total number of scores of all $n!$ permutations is $k! (n-k)!$ times the total score of all arrangements. We will show that the total number of scores of all permutations is $\frac{(n+2)!}{2} \frac{k}{k+2}$.

First we arrange the items $1,\dots,n, X, Y$ in a row, with the condition that $X$ happens before $Y$. There are $\frac{(n+2)!}{2}$ ways to do so. This permutation corresponds to permutation of balls, and the contiguous block is represented by the items between $X$ and $Y$. There may be some permutations where $X$ and $Y$ are next to each other, which means the contiguous block is empty, but that's okay for now. Because we have conditioned that $X$ happens before $Y$, the mapping is injective, meaning no two item permutation map to the same (ball permutation, contiguous block) tuple.

However, not all of those permutations will produce a score. In order for it to produce a score, there must be at least one of $1,\dots,k$ between $X$ and $Y$. So now we consider the permutations of these $k+2$ items. Each of the $n+2$-item permutations has a unique corresponding $k+2$-item permutation, but every $(n-k)!$ of the large permutations produces the same smaller permutation.

There are $\frac{(k+2)!}{2}$ smaller permutations because they still all have $X$ before $Y$. We want to exclude the ones where $X$ and $Y$ are together in this permutation (even if in the original permutations there may be numbers larger than $k$ between them). There are $(k+1)!$ such permutations. So the remaining permutations are: $$\frac{(k+2)!}{2} - (k+1)! = \frac{(k+2 - 2}{2} (k+1)! = \frac{k}{2} (k+1)! = \frac{k}{k+2} \frac{(k+2)!}{2} $$ In other words, the good permutations are only $k/(k+2)$ of the total number of permutations, when we consider all small permutations. But since all large permutations map to the small permutations evenly ($(n-k)!$ to one), then the number of good large permutations is $\frac{(n+2)!}{2} \frac{k}{k+2}$. Then, we map it back to the space of ball arrangement, where each permutation corresponds to $k!(n-k)$ arrangements, so the total number of score of arrangements is: $$\frac{(n+2)!}{2} \frac{k}{k+2} . \frac{1}{k!(n-k)!} .\frac{k+1}{k+1} = \frac{(n+2)!}{(n-k)!(k+2)!} \frac{(k+1)k}{2} = \binom{n+2}{k+2} \binom{k+1}{2}$$

Thursday, February 24, 2022

Neighboring non coprime

Let $n > 1$. A sequence $A_n$ of integers greater than 1 having length $n$ is called nice if any two elements are not coprime. That is, $$\gcd(A_i, A_{i+1}) > 1 \forall i, 1 \leq i \leq n-1$$

Find the smallest real number $t$ such that, given any sequence of integers $A_n$ of integers greater than 1 having length $n$, there exists a sequence of positive integers $B_n$ of length $n$ such that:

1. $\max{B_i} \leq n \max {A_i}$

2. $B_n$ differs from $A_n$ in at most $\lceil tn \rceil$ elements.

Solution

Note that for $t=1$ we can just change every single element to a small number like 2. We can try to do better. Satisfying condition 2 is easy, because for $t = 1/2$ we can just change every other element to the the LCM of it's neighboring elements, but this would make it failr condition 1. For example, suppose the sequence consists of very large primes, then this strategy would cause every other element to be the product of the two large primes, failing condition 1.

We propose that $t = 2/3$ satisfies the condition. That is, if $$A_n = a_1, a_2, a_3,a_4,a_5,a_6,\dots,a_n$$ $$B_n = 2a_2, a_2, 2a_2, 2a_5, a_5, 2a_5, \dots$$

We can see that every two neighboring elements are not coprime, and that the maximum of $B_i$ is at most twice that of $A_i$. We show that there is no smaller $t$ that can satisfy, using a series of counter examples.

For $n=3$, consider the sequence $p_1,p_2,p_3$ of very large primes. There is no way to only change one element to be nice, while keeping the maximum element manageable. The only way to change one element to be nice is to change $p_2 \to p_1p_3$, which then would fail condition 1. So we must change at least 2 elements, which means $\lceil 3t \rceil \geq 2$, so $t > \frac{1}{3}$

For $n=5$ consider the sequence $p_1,p_2,p_3,p_4,p_5$. If we were to change only 2 elements, either we change $p_2,p_4$, or we leave two neighboring primes intact. But if we change $p_2,p_4$, this could mean we have to change $p_2$ to LCM of $p_1,p_3$ and so on, violating condition 1. So we must change at least 3 elements, which means $\lceil 5t \rceil \geq 3$ so $t \frac{2}{5}$

Thursday, February 10, 2022

Expected number of throws

$n$ fair coins are thrown all at once. Those that show Head are removed from the game, and the rest are thrown again. This process is repeated until there are no more coins left. What is the expected number of throws? Find a closed form formula, meaning that it may still be expressed as a sum but may not be expressed as a recurrence relation.

Solution Let $f(n)$ be the desired result. There is a $\binom{n}{k} / 2^n$ chance that $k$ of them will show heads, and the process is repeated with $n-k$ coins now. The rest of the game is expected to take $f(n-k)$ throws. If $k=0$ then we still have the same situation as before. If $k=n$, we have 0 throws left. In all of these situations, we do have to spend 1 turn doing the throw. So the recurrence relation is:

$$f(n) = 1 + \sum_{k=1}^{n-1} \frac{\binom{n}{k}}{2^n} f(k) + \frac{1}{2^n}f(n)$$ $$f(n) = \frac{2^n + \sum_{k=1}^{n-1} \binom{n}{k} f(k)}{2^n-1} $$

Given a large $n$, computing this would take $O(n^2)$ time as we have to calculate and store the previous $f(k)$ values, and each take $O(k)$ time. We can manipulate this expression further to come with a summation formula for $f(n)$ that would allow it to be computed in linear time.

First we claim and prove the following lemma. For $1 \leq m < n$

$$ \sum_{k=m}^{n} \binom{n}{k}\binom{k}{m} = \binom{n}{m}2^{n-m}$$

Proof: given $n$ white balls, we wish to pick $m$ of them and paint them black, and the rest may stay white or be painted gray. The RHS side is obvious, there are $\binom{n}{m}$ ways to choose black balls, and the rest may be painted white or gray.

To show the LHS, first we pick a number $k \in [m,n]$. We choose $k$ balls and paint them gray. Out of these $k$, we further choose $m$ to be painted black.

Alternatively we can prove the lemma by dividing both sides by $\binom{n}{m}$: $$ \sum_{k=m}^{n} \frac{n!}{k!(n-k)!} \frac{k!}{m!(k-m)!} \frac{m!(n-m)!}{n!} = 2^{n-m}$$ $$ \sum_{k=m}^{n} \frac{(n-m)!}{(n-k)!(k-m)!} = 2^{n-m}$$ $$ \sum_{i=0}^{n-m} \frac{(n-m)!}{(n-m-i)!i!} = 2^{n-m}$$

which is a well-known identity

Given the lemma, now we claim the following statement: let $a_n = \frac{2^n}{2^n-1}$ then: $$f(n) = \binom{n}{1}a_1 - \binom{n}{2}a_2 + \binom{n}{3}a_3 + \dots + (-1)^{n+1} \binom{n}{n}a_n$$ We will show that this formula matches our recurrence relation above by strong induction. Suppose they hold for $1,2,\dots,n-1$, then we first evaluate the following expression: $$\sum_{k=1}^{n-1} \binom{n}{k}f(k) = \binom{n}{1}f(1) + \binom{n}{2}f(2) + \dots + \binom{n}{n-1}f(n) $$ $$= \sum_{k=1}^{n-1} \binom{n}{k} \sum_{m=1}^{k} (-1)^{m+1} \binom{k}{m}a_m $$ we rearrange and collect each $a_m$ terms: $$= \sum_{m=1}^{n-1} (-1)^{m+1}a_m \sum_{k=m}^{n-1} \binom{n}{k} \binom{k}{m} $$ Apply the lemma: $$= \sum_{m=1}^{n-1} (-1)^{m+1}a_m \left(\binom{n}{m}2^{n-m} - \binom{n}{m} \right) = \sum_{m=1}^{n-1} (-1)^{m+1} \binom{n}{m} a_m \left(2^{n-m} - 1 \right) $$ We can plug this expression to our recurrence formula and compare against our claim (induction hypothesis). After multiplying both sides by $2^n-1$, we are left to show that: $$(2^n-1) a_n + \sum_{m=1}^{n-1} (-1)^{m+1} \binom{n}{m} a_m \left(2^{n-m} - 1 \right) = (2^n-1) \left( \sum_{m=1}^{n-1} (-1)^{m+1} \binom{n}{m}a_m + (-1)^{n+1}a_n \right)$$ Collect $a_n$ terms to the LHS, and the rest of the terms to RHS: $$(2^n-1)(1 + (-1)^n)a_n = \sum_{m=1}^{n-1}a_m(-1)^{m+1} c_m $$ where $$c_m = (2^n-1)\binom{n}{m} - \binom{n}{m}(2^{n-m}-1) = \binom{n}{m}(2^n - 2^{n-m}) = \binom{n}{m}2^{n-m}(2^m-1) = \binom{n}{m}2^{n-m} \frac{2^m}{a_m}$$ so what we need to show becomes: $$(2^n-1)(1 + (-1)^n)a_n = \sum_{m=1}^{n-1}a_m(-1)^{m+1} \binom{n}{m}2^{n-m} \frac{2^m}{a_m} $$ $$2^n(1 + (-1)^n) = \sum_{m=1}^{n-1}(-1)^{m+1} \binom{n}{m}2^{n} $$ $$1 + (-1)^n = \sum_{m=1}^{n-1}(-1)^{m+1} \binom{n}{m} $$ $$1 + \sum_{m=1}^{n-1}(-1)^{m} \binom{n}{m} + (-1)^n = 0$$ $$(1 -1)^n = 0$$

Friday, August 13, 2021

Evolving Polynomial

On the Cartesian field, each lattice point $(x,y)$ is initially assigned the number $x^2+y^2-1$.

At each step, if $A(x,y)$ represents the number on $(x,y)$, that number is increased by: $$\frac{(x-y) \left( A(x+1,y) + A(x,y-1) - A(x-1,y) - A(x,y+1) \right)}{4}$$

All the additions are done simultaneously.

1. Prove that the numbers at each point are always integers

2. Prove that, aside from the initial configuration, there is never a number that is divisible by 3

Solution

The recursion formula guarantees that $A(x,y)$ is always a polynomial in $x,y$, with real coefficients. In the initial configuration, $B(x,y) = A(x,y) + 1 = x^2+y^2$ is homogeneous in $x,y$ with degree 2. That is, $B(kx,ky) = k^2 A(x,y)$. We will show that this homogeneity is maintained by the recursion formula, and therefore will hold true at all times.

Suppose $A(x,y) = P.x^2 + Q.xy + R.y^2 - 1$ for some real numbers $P,Q,R$ then the recursion formula maintains it. This is because $A(x+1,y) - A(x-1,y)$ cancels out the $x^2,xy,y^2,1$ terms, so only $x,y$ terms are left. Similarly $A(x,y+1) - A(x,y-1)$ will also only preserve $x,y$ terms. So the second factor is homogenous with degree 1, but the factor $(x-y)$ is also homogenous with degree 1, so the added number is homogeneous with degree 2. Therefore, the final number is still of the form $A(x,y) = P'.x^2 + Q'.xy + R'.y^2 - 1$ (for some $P',Q',R'$ constants that may be different from the previous iteration).

Now we also notice that $A(x,y) = A(y,x)$ for all time. This property is preserved in the beginning, but also preserved by the recursion, so the numbers are symmetric with respect to $x,y$. Therefore $P = R$.

Next, we notice that for $x=y$, the additions are always zeros, so $A(x,x) = 2x^2-1$ for all time. Therefore $A(x,x) = (2P+Q)x^2-1 = 2x^2-1$ so $2P+Q = 2$.

This means that, because $Q = 2- 2P$, $A(x,y) = Px^2 + (2-2P)xy + Py^2 - 1= (x^2+y^2 - 1) + (P-1)(x-y)^2$ for some $P$ real (not necessarily integer) that depends on $t$. So we've shown that $A(x,y)$ has the form $(x^2+y^2-1) + K_t(x-y)^2$ for some $K_t$, where $K_0 = 0$.

Then, plugging in to the original recursion formula, we can see: $$(K_{t+1} - K_t)(x-y)^2 = \frac{x-y}{4} ( 4x - 4y +K_t(2(x-y+1)^2 -2(x-y-1)^2))$$ $$(K_{t+1} - K_t)(x-y)^2 = \frac{x-y}{4} ( 4x - 4y +8K_t(x-y))$$ $$K_{t+1} = 3K_t + 1$$ From there, it's a simple matter to see that $K_t = \frac{3^t-1}{2}$ because $K_0 = 0$, but we didn't need to solve the recursion. The fact that $K_0 = 0$ is enough to prove that $K_t$ is always an integer, and that, except for $t=0$, it's always $\equiv 1 \mod 3$.

Because $K_t$ is always an integer then $A(x,y)$ is also integral everywhere. And because $K_t \equiv 1 \mod 3$ then we can check that for any combinations of $x,y \mod 3$, $A(x,y)$ will never be $\equiv 0 \mod 3$.

Thursday, July 22, 2021

Positive-definite Polynomial Game

Given $n$ a positive even number. Alice and Bob are playing a game as follows. On the board initially there are $n+1$ unassigned numbers: $a_0, a_1, \dots, a_n$.

With Alice going first, each player alternatingly chooses an unassigned number and assigns a positive real value to it. Once all numbers have been assigned values, polynomial $P(x)$ is defined as:

$$P(x) = a_nx^n + \dots + a_1x +a_0$$

If $P(x) > 0$ for all $x \in R$ then Alice wins, otherwise Bob wins. Determine who has a winning strategy.

Variant 1: if the number $a_0$ is already fixed to 1, so there are only $n$ numbers on the board, who has a winning strategy?

Variant 2: if the winning condition is flipped: Alice wins if there exists an $x$ such that $P(x) < 0$.

Solution

The player who moves last has a winning strategy, regardless of winning condition. Variant 1 merely flips who moves last. If Variant 1 is in play and Alice moves first, then Bob moves last and Bob has a winning strategy. Note that $P(x)$ is positive definite iff $tP(x)$ for all $t$ positive numbers, so the magnitude of each number doesn't matter, only the relative magnitude of all coefficients. Therefore, the number "1" set by variant 1 is arbitrary and the variant merely ensures Bob's ability to win. For the rest of this solution, we assume that variant 1 is not in play and Alice goes first, and she should assign $a_0 = 1$. The rest of the proof can then be extensible to variant 1 while flipping the name Alice and Bob.

Lemma: polynomial $P(x)$ with positive coefficients are positive definite if and only if $P(1/x) > 0$ for all $x \neq 0$. This lemma is easy to see because $P(0) > 0$ anyways.

Part 1: proving that Alice can ensure positive definiteness.

Assume that $a_0 = 1$ has already been assigned. Now divide the remaining coefficients into pairs: $(a_1,a_2), (a_3,a_4), \dots, (a_{n-1},a_n)$. Whenever Bob makes a move and assigns a value to a coefficient, Alice assigns a value to its pair accordingly. We claim that Alice will be able to choose her value such that the resulting polynomial $Q_k(x) = a_{2k}.x^{2k} + a_{2k-1}.x^{2k-1} + 2/n$ is positive definite.

Proof: From the lemma, $Q_k$ is positive definite iff $R_k(x) = \frac{2}{n}x^{2k} + a_{2k-1}x + a_{2k}$ is positive definite.

If Bob chooses $a_{2k-1}$ then Alice can choose $a_{2k}$ large enough to make $R_k(x)$ positive definite. Whichever local minimum may exist due to Bob's choice, Alice can compensate it enough by adding a positive constant term to the whole polynomial.

If Bob chooses $a_{2k}$ then there exists an $a_{2k-1}$ small enough to make $R_k(x)$ positive definite. If $x \geq 0$ positive then $R_k(x) > 0$ because all coefficients are positive. But if $x < 0$ then by AM-GM:

$$ \frac{2}{n}x^{2k} + a_{2k} = \frac{2}{n}x^{2k} + \frac{a_{2k}}{2k-1} + \dots + \frac{a_{2k}}{2k-1} \geq 2k \sqrt[2k]{\frac{2}{n}.\left(\frac{a_{2k}}{2k-1}\right)^{2k-1}}.(-x) > -a_{2k-1}x$$

for small enough positive value of $a_{2k-1}$.

The final polynomial can be expressed as the sum:$P = Q_1 + \dots + Q_{n/2}$, and because at each step Alice can always ensure that the resulting $Q_k(x)$ is positive definite no matter what Bob chooses, then the final polynomial is also guaranteed to be positive definite.

Part 2: proving that Alice can ensure non-positive definiteness.

If $n=2$ then Alice can always ensure that the discriminant of the quadratic polynomial is positive, therefore the polynomial has two real roots. For $n > 2$, the general strategy is as follows: divide the coefficients into pairs as above, and Alice's assignment is always the pair of Bob's assignment as well. But this time the difference is that, after each of her move, Alice ensures that the TOTAL polynomial $P(x)$ is negative for some values of $x$ and maintains this invariant throughout the game.

First note that if Bob ever chooses an even coefficient $a_2,a_4,\dots$ then Alice's job is really easy. Take the current value of $P(-1)$ (after including Bob's addition), and by choosing her corresponding odd coefficient large enough, she can make $P(-1)$ negative because she's adding a multiple of $x^{2k-1}$ which is negative at $x=-1$.

Consider the first round. If Bob chooses $a_{2k}$ then Alice chooses large enough $a_{2k-1}$ as described above. But if Bob chooses $a_{2k-1}$, Alice can choose small enough $a_{2k}$ to ensure non-positive definiteness. The current resulting polynomial is $a_{2k-1}x^{2k-1}+1 < 0$ as $x \to -\infty$, so pick any $y$ such that $a_{2k-1}y^{2k-1}+1 < 0$. Then Alice chooses $a_{2k}$ small enough such that $0 < a_{2k} < \frac{-a_{2k-1}y^{2k-1}-1}{y^{2k}}$ so that $a_{2k}y^{2k}+a_{2k-1}y^{2k-1}+1 < 0$

So once the invariant is established after the first round, then Bob has no choice but to keep choosing even coefficients. If Bob chooses an odd coefficient, then whichever value of $x$ caused $P(x)$ to be negative at the end of last round will continue to be (even more) negative, so Alice simply chooses a very small value of the corresponding even coefficient as described above. But even if Bob chooses an even coefficient, Alice can counter by choosing a large enough odd coefficient. Therefore she maintains the invariant of $P$ being non-positive definite until the end of the game.

Wednesday, May 8, 2019

Questions in an exam

A test is taken by 2019 students. The test consists of $n$ questions (where $n > 0$ is even), where each question is a true/false problem worth 1 point. It is known that:

1. Each student answered exactly half of the questions correctly.

2. Given two students, their answers agreed on exactly half of the questions.

Find the smallest $n$ such that this situation is possible.

Solution

If $n = 2^k m$ where $m$ is odd, then there are at most $2^k - 1$ students. Therefore, with 2019 students, we need $2048$ questions for this situation to be possible. Proof:

Suppose $m=1$, we will give a configuration of $2^k-1$ students that satisfy both conditions. First of all, given a number $b$, let $f(b)$ denote the number of 1s in its binary representation, modulo 2. That is $f(b)=0$ if $b$ contains an even number of 1s in its binary representation, and $f(b) = 1$ otherwise.

Label the students $1$ to $2^k-1$ and consider their binary representation (from $0...01$ to $1...1$, all having exactly $k$ digits). Also label the problems $0$ to $2^k-1$ and consider their binary representation (from $0...0$ to $1...1$, all having exactly $k$ digits). We set student $s$ answered problem $p$ correctly if $f(p \wedge s) = f(s)$, where $\wedge$ denotes bitwise AND operation between $p$'s binary representation and $s$' binary representation. In other words, if the number of digits where $p$ and $s$ are both 1 in their binary representation is the same parity as the number of 1s in $s$' representation, then student $s$ answered problem $p$ correctly.

For example, student $5=0...101$ answered question $2=0...010$ correctly because $f(5 \wedge 2) = f(0...000) = 0 = f(5)$. But student $7 = 0...111$ answered question $3 = 0...011$ incorrectly because $f(7 \wedge 3) = f(111 \wedge 011) = f(011) = 0 \neq 1 = f(7)$.

From there, it's easy to see that condition 1 is satisfied. A student's correct answers depends only on the digits of $s$ that are 1, and there are $2^{f(s)}$ possible combinations of those digits. Out of those, there will be half that has even number of 1s and half that has odd number of 1s, so that student answers half the questions correctly.

To prove condition 2, consider student $s$ and $t$. Consider $r = s \oplus t$ where $\oplus$ denotes the bitwise XOR operation. In other words, $r$ is a number whose binary representation is 1 at the digits where $s$ and $t$ are different, and 0 at the digits where $s$ and $t$ are the same. The problems where $s$ and $t$'s answers agree are exactly the problems where student $r$ answered correctly. To prove that assertion, note that $f$ is distributive with respect to $\oplus$. That is $f(a \oplus b) = f(a) \oplus f(b)$. This is because if $a$ has $d_a$ number of 1s and $b$ has $d_b$ number of 1s then $a \oplus b$ has $d_a + d_b \mod 2$ number of 1s, because the digits that were both 1s and turned into zero always come in pairs.

So suppose both $s$ and $t$ get problem $p$ right, then $p \wedge r = p \wedge (s \oplus t) = (p \wedge s) \oplus (p \wedge t)$ so $f(p \wedge r) = f(p \wedge s) \oplus f(p \wedge t) = f(s) \oplus f(t) = f(s \oplus t) = f(r)$ and similarly if they both get the problem wrong. We can show that if $s$ gets problem $p$ right and $t$ gets it wrong, then $r$ gets problem $p$ wrong as well. That way, we showed that student $s$ and $t$'s answers agree exactly on the problems that student $r$ gets right, and by condition 1, this is exactly half of all the problems. So condition 2 is proven.

Now for $m > 1$, let $l = 2^k$ so $n = lm$, we simply assign student $s$ answering problem $p$ correctly if and only if student $s$ answers problem $(p \mod l)$ correctly. In essence, we are duplicating problems $0,\dots, l-1$'s answers (which were constructed above) $m$ times. Condition 1 and 2 are still satisfied.

The second part of the proof is to show that this arrangement is optimal. That is, with $n = 2^km$ there is at most $2^k-1$ students.

For $n$ to be even then $k \geq 1$. For $k = 1$ we show that there is at most 1 student. That is, condition 1 can be fulfilled easily, but condition 2 cannot be fulfilled. Indeed, WLOG we may assume that student $A$ answered questions $1,\dots,m$ correctly and $m+1,\dots,2m=n$ incorrectly. If there is a second student $B$, then suppose above questions $1,\dots,m$ he answered $t$ questions correctly, then he must answer $m-t$ questions among the second half correctly. However, that means the number of questions that $A$ and $B$ agreed on is $t + (m- (m-t)) = 2t \neq m$, contradiction. So there is at most $2^1 - 1 = 1$ student for $k = 1$.

Now we use induction on $k$. Suppose that $k > 1$ and let $h = n/2 = 2^{k-1}m$. Take student $A$, and WLOG assume that he answered questions $1, \dots, h$ correctly (i.e. the first half). For any other student $B$, suppose he answers $t$ questions correctly on the first half, so $h-t$ questions correctly from the second half. The number of questions that $A$ and $B$ agreed on is $t + (h-(h-t)) = 2t = h$, so student $B$ answered $h/2$ questions correctly on the first half. This means all students other than $A$ must answer $h/2$ questions correctly on the first half.

Also note that if we replace $B$ with $B'$ whose answers are completely opposite of $B$, then condition 1 and 2 are both still preserved. $B'$ still answered half the questions, and the questions that $B$ agreed with other students are just "flipped." However, $B$ and $B'$ cannot both coexist because obviously condition 2 would be violated.

So now suppose that there are two students $B,C$ distinct from $A$. It's possible that $B$ and $C$ agree completely on the first half (and disagree completely on the second half). We see this a lot in the construction above. In that case, we call $B$ and $C$ "friends", and we put them under one "group." Also, if $B$ and $C'$ would have been friends, we still call $B$ and $C$ friends (as in, if $B$ and $C$ disagree completely on the first half but agree completely on the second half, we still call $B,C$ friends). Note that because $C$ and $C'$ cannot both coexist, we are not claiming that $B$ can be friends with two existing students. Indeed we shall show that $B$ is friends with at most one other person.

If $B$ and $C$ are friends, and $B$ and $D$ are friends. WLOG we may assume that $B,C,D$ agree completely on the first half (otherwise replace $C$ by $C'$ or $D$ by $D'$ or both). Suppose :
1. $X$ is the set of problems that $A$ got right, $B$ got right
2. $Y$ the set of problems $A$ got right, $B$ got wrong
3. $Z$ the set of problems $A$ got wrong, $B$ got right
4. $W$ the set of problems $A$ got wrong, $B$ got wrong

So $X \cup Y$ is the first half, and $Z \cup W$ is the second half. Because $C$ agree with $B$ on the first half, he must disagree completely on the second half. That means $C$ got $X \cup W$ completely right, and $Y \cup Z$ completely wrong. But we my apply the same argument to $D$, therefore $D$ got $X \cup W$ completely right and $Y \cup Z$ completely wrong. This violates condition 2 because now $C,D$ agree everywhere. Contradiction. Therefore, each group of friendship contains at most 2 students. (Some students may not have friends, so they are in a group each by himself).

Next, suppose $B$ and $C$ are not friends. Consider the answers of $C$ in $X,Y,Z,W$ that agree with $B$. Suppose there are $t_X, t_Y, t_Z, t_W$ answers that agree with $B$ respectively. Now by condition 2, the total number of agreement between $B$ and $C$ must be $h$, so: $$t_X + t_Y + t_Z + t_W = h$$ By condition 1, the total number of answers that $C$ got right must be $h$, so: $$t_X + (|Y| - t_Y) + t_Z + (|W| - t_W) = h$$ And note that $|Y| + |W|=h$ because those are the questions that $B$ got wrong. So the second equation can be written as: $$t_X + t_Z = t_Y + t_W$$ That means $t_X + t_Z = t_Y + t_W = h/2$. But also, $C$ must agree with $A$ for $h$ questions, so: $$t_X + |Y| - t_Y + |Z| - t_Z + t_W = h/2$$ But $|Y| + |Z| = h/2$ because those are the questions that $B$ disagreed with $A$, so $t_X + t_W = t_Y + t_Z = h/2$ Solving the two equations, we have $t_X = t_Y$. Next, because $C$ must answer $h/2$ questions correctly on the first half, then $t_X + |Y|-t_Y = h/2$, so $|Y| = h/2$, which means $|X| = |Y| = |Z| = |W| = h/2$. we get $t_X = t_W = t_Z = t_Y = h/4$. Because $k>1$ and $h = 2^{k-1}m$ then $h/4$ is still an integer. Therefore $t_X + t_Y = h/2$. So the conclusion here is that if $B$ and $C$ are not friends, then $C$ agreed with $B$ on exactly $h/2$ on the first half, and $h/4$ on the second half.

Suppose there are $2^k$ students, and because $A$ is one of them, then there are $2^k-1$ "non-A" students. Because each group contains at most 2 students, then there are at least $\lceil (2^k-1)/2 \rceil = 2^{k-1}$ groups. Take any student from each group to be the "representative" of that group. Now, consider their answers only on the first half of the exam. These answers satisfy the condition for the exams with $n/2 = h$ questions. Indeed, condition 1 is satisfied because all students other than $A$ must answer $h/2$ questions correctly. Condition 2 is also satisfied because every two students who are not friends must agree exactly $h/2$ on the first half. Therefore, now we have at least $2^{k-1}$ students (excluding student $A$) with $h = 2^{k-1}m$ problems that satisfy conditions 1 and 2, violating our induction hypothesis. Contradiction. So there must be at most $2^k-1$ students in an exam with $2^km$ problems.

Finally, because $2^{10} < 2019 < 2^{11}$, then in order for this situation to happen with 2019 students, $k \geq 11$. That means the least number of problems is $2^{11}.1 = 2048$.

Thursday, March 28, 2019

Finite difference

Define sequences $x_i,y_i,i=1,2,\dots$ as follows: $$x_{n+1} = x_n^2 - 20$$ $$y_{n+1} = y_n^2 - 30$$ And define $d_i = x_i - y_i$. Find all possible starting pairs $(x_1,y_1)$ such that the set $\{d_1, d_2, \dots \}$ contains only a finite number of elements. Solution Just the outlines. If $x_1 = \pm 4 , \pm 5$ then $x_n$ is bounded, likewise if $y_1 = \pm 5, \pm 6$ it is bounded. It's easy to show that for other possibilities $x_n,y_n$ are both unbounded, and will be positive except for the first few terms.

If $x_n,y_n$ are bounded then they assume a finite number of values, therefore $d_i$ also assume a finite number of values, at most the combinatorial pairs of their images, but most likely much less. However, if one of them is unbounded, then say $x_n$ is unbounded, EVEN IF $y_n$ is bounded, then $x_n+y_n$ is unbounded. At this point it's easy to show that $x_n+y_n$ is monotonically increasing and unbounded (excxept for the first few terms) because once $x_n$ gets large enough, $y_n$'s fluctuation is not enough to make the sum decrease.

Now, if $x_n-y_n$ is unbounded, then $x_n^2 - y_n^2$ is unbounded. If $x_n - y_n$ is bounded then $x_n^2 - y_n^2$ is unbounded, EXCEPT if $x_n = y_n$ identically. But because they have different recursion formula, they can't always be identical. Meaning they're identical at most every other term. On the terms that they are not identical, $x_n-y_n$ is non-zero, and because $x_n+y_n$ is monotonically increasing and unbounded, then $x_n^2 - y_n^2$ is also unbounded. Therefore $d_n +10$ is also unbounded, so it assumes an infinite nunmber of values

Monday, March 18, 2019

Triangular equations

A triangular series of equations is a system of $k$ equations where the $k$-th row consists of $k+1$ terms on the LHS and $k$ terms on the RHS. For example: $$a + b = c$$ $$d + e + f = g + h$$ $$i + j + k + l + m = n + o + p$$ $$...$$ Given the numbers $1, 2, \dots, n^2$ and one number with the same parity as $n$ is removed, prove that the rest of the numbers can be arranged into a triangular series of equations.

For example, out of $1,2,\dots,9$, 3 is removed, so the rest can be written as: $$ 1+4 = 5$$ $$2 + 6 + 8 = 7 + 9$$ Another example, out of $1,2,\dots, 16$, 10 is removed, so the rest can be written as: $$1+3 = 4$$ $$2 + 5 + 8 = 6 + 9$$ $$7 + 11 + 12 + 14 = 13 + 15 + 16 $$

Solution (In Progress)

Suppose we color all the numbers with the same parity as $n$ with red, and color all the numbers with the opposite parity with black. Also, call the number that was removed, the missing number, $x$. A number is called "good" if, when missing, the rest of the numbers can be written as triangular system.

Note the triangular system below: $$1+2 = 3$$ $$4+5+6 = 7+8$$ $$9+10+11+12 = 13+14+15$$ $$...$$ $$k^2 + \dots + (k^2+k) = (k^2+k+1) + \dots + (k^2+2k)$$ $$...$$ $$(n-1)^2 + \dots + ((n-1)^2+n-1) = ((n-1)^2+(n-1)+1) + \dots + (n^2-1)$$ We call this system A. This system is missing $n^2$, and the system is triangular and correct. (The correctness of said system can be verified by simple arithmetic series on the $k$-th row).

So we know that $n^2$ is good. Furthermore, note that each row has the same number of odd numbers (that is, $k$-th row has $k$ odd numbers if $k$ is odd and $k-1$ odd numbers if $k$ is even). So if we increase each odd number by two, we'll still get a correct triangular system: $$3+2 = 5$$ $$4+7+6 = 9+8$$ $$11+10+13+12 = 15+14+17$$ $$...$$ So if $n$ is odd, 1 is good. Call this system B.

Similarly, the $k$-th row has $k$ even numbers in the LHS and $k-1$ even numbers in the RHS. We can increase the even numbers by two, but then the equation will be incorrect. Call the "weight" of an equation to be its RHS - LHS. Obviously, an equation is correct only if it has weight zero. If we increase all the even numbers by two, then the weight of the new equation is -2, for example: $$6+5+8 > 7+10,w=-2$$ But note that now $(k^2+k+2)$ is in the LHS while $k^2+k+1$ is still in the RHS. In other words, the largest number in the LHS is exactly one more than the smallest number in the RHS, so if we switch those two, we restore the weight back to zero: $$6+5+7 = 8+10$$ So we can form a new system this way: $$1+3=4$$ $$6+5+7 = 8+10$$ $$9+12+11+13 = 14+16+15$$ $$...$$ Next, note that out of the $n$ rows in the equation, we can take the first $k$ rows from system A, and the $n-k$ last rows from system B or C. For example: $$1+2 = 3$$ $$4+5+6 = 7+8$$ $$11+10+13+12 = 15+14+17$$ $$...$$ Now we are ready to prove the main assertion by induction. We will show the base cases later. For now, suppose it holds for $n=2,3$. Then, if $x \leq (n-2)^2$, there is a way to arrange $\{1, 2, \dots, (n-2)^2\} \ \{x\}$ in triangular form by induction hypothesis, and the last two rows can be taken from the last two rows of system B (if $n$ is even) or system C (if $n$ is odd). So then we consider cases where the missing number is $x > (n-2)^2$. In system A above, it would be in the last two rows. We will divide into cases depending on the position of $x$ in system A. Note that the missing number is always red.

Suppose $x$ is red on the last row RHS (meaning the missing number is in the interval $x \ in [(n-1)^2+(n-1)+1, n^2-2]$). Take out that number and replace it with $n^2$. Then now the last row has weight a positive even number in the interval $[2, n-1]$. We can switch a number $k$ from LHS and $l$ from the RHS, and the weight would decrease by $2(l-k)$. But the difference of the numbers in RHS and LHS ranges from 1 to $2n-2 > n-2$, and each side has consecutive numbers. So we know there are numbers that we can pick to switch so that the weight is reduced back to zero.

Suppose the missing number is red on the last row LHS, meaning the missing number is in the interval $x \in [(n-1)^2+1, (n-1)^2+(n-1)]$. Take out that number and replace it with $n^2$. Then the last row has weight a negative even number in the interval $[-2n+2, -n]$. Now, there exists a number in RHS $y$ such that $y-n^2$ is exactly half the weight of the last row, because the numbers in RHS is in the range $[(n-1)^2+(n-1)+1,n^2-1]$ so those numbers subtracted by $n^2$ is in the range $[-n+1, -1]$ which encompasses $\frac{1}{2} [-2n+2, -n]$. If we switch this number $y$ and $n^2$, the weight of the last row is restored.

Suppose the missing number is red on the second-to-last (STL) row LHS, meaning the missing number is in the interval $x \in [(n-2)^2, (n-2)^2+(n-2)]$. Take out that number and replace it with $(n-1)^2+1$, and then in the last row, put $n^2$ to where $(n-1)^2+1$ used to be. The STL row now has weight negative even number in the interval $[-2n+2,-n]$, whereas last row has some other even number weight. The last row could be fixed with the procedure described above (as if $(n-1)^2+1$ was the missing number). However the STL row can be fixed by switching $(n-1)^2+1$ with an appropriate number in the STL RHS, because the numbers in STL RHS ranges from $[n^2-3n+3,n^2-2n]$ so the difference ranges from $[-n+1, -2]$ which encompasses $\frac{1}{2}[-2n+2,-n]$

Suppose the missing number is red on the STL row RHS. Same as before, take out that number, replace it with $(n-1)^2+1$, and then in the last row, put $n^2$ to where it used to be. Same as above, the last row can be fixed using the previous strategy, whereas the STL row can be fixed by switching two numbers in the STL (similar to if the missing number is from RHS last row).

Now all that remains is to prove the base cases. For $n=2$, we have either $1+3=4$ or $1+2=3$. For $n=3$, the missing numbers could be $x=1,3,5,7,9$, but $x=9$ is already covered by system A above, $x=1$ covered by system B, and $x=3$ is shown in the example. For $x=5$: $$1+2=3$$ $$4+7+6 = 9+8$$ For $x=7$: $$1+3=4$$ $$2+5+8 = 6+9$$ (Really we're just applying the algorithm described above but we're including here for the sake of proof completeness).

Thursday, February 21, 2019

Given a circle $(O,R)$ and a point $P$ in its interior. For any two points $A,B$ on its perimeter, we define $f(A,B)$ to be the point $C$ such that $APBC$ is a parallelogram.
Determine the image of $f$ when $A,B$ vary over all possible pairs of points on the perimeter. That is, determine the set $S = \{f(A,B) | AO = BO = R\}$
Solution Let $O'$ be a point on the extension of $PO$ such that $OO' = 2PO$. We shall show that $S$ is a circle (including the interior) centered at $O'$ with radius $2R$.

Outline of proof:

Let $T$ to be the circle we claim. Note that $T$ is a 2x dilation of the original circle with center $P$. We show that the boundary of $S$ is boundary of $T$ as well, by letting $A=B$ in the opration

Next we show that any point in $T$ is an image of a specific application of $f$. Let $X' \in T$, then $X'$ is an image of a 2x dilation. Suppose $X$ is the original point. We claim that there exists $A,B$ such that $PX$ is a median of $PAB$. Indeed, if $OAB$ is a triangle such that $OX$ is its median, then $PX$ is median of $PAB$.

Then it is routine to show that $f(A,B) = X'$.

Note: this problem can be extended to any point $P$, and any convex shape $V$ in $R^n$. The sum of vectors $PA + PB$ where $A,B$ are any two points on its boundary is equivalent to the 2x dilation of $V$ with center $P$. However, $V$ must be bounded.

Challenge: prove this generalization. (Hint: use the connectedness of $S^{n-1}$ in $R^n$).

Challenge: give a counter example of this result of $V$ is unbounded

Monday, February 11, 2019

Game making expression positive definite

On the board there are six numbers $A,B,C,D,E,F$, all initially zero. Mary and Nancy are playing a game as follows. On Mary's turn, she increases one of $A,B,C$ by 1, and on Nancy's turn, she increases one of $D,E,F$ by 1. They take turns alternatingly until each has gone 2019 times. Each pair of turns is called a "set" (for example if Mary moves first, then 1 set consists of Mary's move followed by Nancy's move).

Winning condition: Mary wins if at any point at the end of a set the following inequality is true for all $x,y$ real numbers: $$Ax^2 + By^2 + C \geq Dxy + Ex + Fy$$ Determine who has the winning strategy if:

1. Mary goes first

2. Nancy goes first

Solution

If Mary goes first Nancy has a winning strategy.

Replace $x$ with $x/z$ and $y$ with $y/z$ to make the inequality homogeneous: $$Ax^2 + By^2 + Cz^2 \geq Dxy + Exz + Fyz$$ Note that the following form is always true if $u,v,w \geq 0$ $$u(x-y)^2 + v(x-z)^2 + w(y-z)^2 \geq 0$$ So if at any point after a set the inequality can be reduced to that form, then Mary wins. We claim the following two things:

1. That Nancy can always avoid that form, and

2. That if the form is not achieved then there exists a $x,y,z$ to make the inequality false

First to prove 1, note the following rearrangement: $$u(x-y)^2 + v(x-z)^2 + w(y-z)^2 \geq 0$$ $$(u+v) x^2 + (u+w)y^2 + (v+w)z^2 \geq 2u xy + 2v xz + 2w yz$$ Therefore if $D = (A+B-C), E = (A+C-B), F = (B+C-A)$ then that form is achieved. This is the unique solution to achieve that form, and that solution may be negative. If the solution to that form contains negative number then no matter what Nancy does, that form is not achieved. But even if it is a triple of non-negative integers, Nancy has 3 choices of moves to make, so she still has at least 2 moves that won't result in that form.

Now to prove 2, we show that we can find $x,y,z$ that violates the inequality.

First, if $A,B,C$ do not form a triangle, then $A>B+C$ (or its permutation). Note that if we assume (WLOG) that $A>B+C$ then $A+B>C,A+C>B$. Furthermore WLOG we may assume that $B \geq C$. $$Ax^2 + By^2 + Cz^2 \geq Dxy + Exz + Fyz$$ $$\iff (A+B-C)(x-y)^2 + (A+C-B)(y-z)^2 + (B+C-A)(x-z)^2 \geq -(2A+2B-2C-2D)xy - (2A+2C-2B-2E)yz - (2B+2C-2A-2F)xz$$ In that case we can choose the following variables. Let $S,R$ be large numbers. Let $x= 1/R, y = R + 1/R, z = SR + 1/R$. Then $$ (A+B-C)R^2 + (A+C-B)(S-1)^2R^2 \geq (A-B-C)S^2R^2 + ...$$ The "..." part in RHS consists of terms $SR^2$ or lower. As we let $S,R$ become large, the dominant terms are $(S-1)^2R^2$ versus $S^2R^2$. For large enough $S$, $(A+B-C)+(A+B-C)(S-1)^2 < (A-B-C)S^2$. At that point we just fix $S$ but let $R$ become larger. Since the coefficient of $R^2$ in the RHS is larger, then the RHS grows faster, invalidating the inequality.

Now if $A,B,C$ form a triangle, $$\iff (A+B-C)(x-y)^2 + (A+C-B)(y-z)^2 + (B+C-A)(x-z)^2 \geq (2A+2B-2C+2D)xy + (2A+2C-2B+2E)yz + (2B+2C-2A+2F)xz$$ Note that the sum of coefficients in RHS is zero, so the terms are not all positive. We shall divide into two cases: one positive two negatives or vice versa

Case 1: if the RHS is of the form $Uxy + Vxz - (U+V) yz$ with $U,V \geq 0$. Then $$RHS = Uy(x-z) + Vz(x-y)$$ Then we set $x = R+1/R, y = R, z= R$. The terms in LHS will be zero or $(1/R^2)$ whereas the terms in RHS will be $(U + V)$. By setting $R$ large enough we can make LHS < RHS.

Case 2: if the RHS is of the form $(U+V)xy - Uyz - Vxz$ with $U,V \geq 0$ Then $$RHS = Uy(x-z) + Vx(y-z)$$ Then we set $x = R+1/R, y = R+1/R, z= R$. The terms in LHS will be zero or $(1/R^2)$ whereas the terms in RHS will be $(U + V)(1+1/R)$. Again, by setting $R$ large enough we can make LHS < RHS.

Challenge Can you generalize this to third power and four variables? In other words, can the game be extended into the following inequality? $$Ax^3 + By^3 + Cz^3 + Dw^3 \geq Exyz + Fxyw + Gxzw + H yzw$$ Answer: yes. We make use of the following property: $f(a,b,c) = a^3 + b^3 + c^3 - 3abc = (a+b+c)((a-b)^2 + (b-c)^2 + (c-a)^2)/2 \geq 0$ If the inequality can be expressed as a positive sum of $f(x,y,z), f(x,y,w), f(x,z,w), f(y,zw)$ then the inequality holds. If not, then there are two cases:

1. One or more of the $f$ form occurs on the RHS, in which case we choose $x,y,z,w$ to maximize the growth of the ones in the RHS. For example, $x=y=1/R, z = R+1/R, w = SR + 1/R$ for large $S,R$.

2. The $f$ forms all occur on the LHS, so there are terms of $xyz$ etc on the RHS whose coefficients all sum to zero. We can pick $x,y,z,w$ whose differences are small but themselves are large, such as $x=R, Y = R+1/R, z = R+2/R, w = R+3/R$. That way, the values of $f$ will be small but values of $xyz$ will be big. By judiciously permuting those values depending on which coefficients are negative, we can make LHS to be < RHS.

Saturday, December 8, 2018

Elegant number limited

A number is called "elegant" if it is equal to the sum of its digits raised to the consecutive powers in decimal respresentation. In other words, if $S = a_1 a_2 \dots a_n$ is elegant then $S = a_1^1 + a_2^2 + \dots + a_n^n$

For example, $89 = 8^1 + 9^2$ is an elegant number. Also, $$2646798 = 2^1 + 6^2 + 4^3 + 6^4 + 7^5 + 9^6 + 8^7$$ is an elegant number

Prove or disprove: there exists an infinite number of elegant numbers

Solution

We shall prove that there exists only a finite number of elegant numbers because for large enough $N$, it is impossible for an $N$-digit elegant number to exist.

If $S = a_1\dots a_N$ is elegant then $S \geq 10^{N-1}$ because $S$ is an $N$ digit number. But at the same time: $$S = a_1^1 + \dots + a_N^N \leq 9^1 + \dots + 9^N = \frac{9^{N+1}-1}{8}$$ So we have: $$10^{N-1} \leq \frac{9^{N+1}-1}{8}$$ The function on the LHS grows faster than the RHS because the exponentiation base is larger. So this inequality ceases to be true for large enough $N$. In fact: $$\iff (10/9)^{N+1} \leq 12.5$$ $$\iff N \leq \frac{\log (12.5)}{\log (10/9)} -1 \sim 22.9$$ So for $N = 23$ we already find that there cannot exist a 23-digit elegant number

Friday, October 5, 2018

Prove square root is irrational

Prove that for any positive integer $n$, then $$\sqrt{\frac{n}{n+1}}$$ is irrational.

Solution

If $n+1$ is a square then we only need to show that \sqrt{n} is irrational, which amounts to showing that it's not a square. This follows the fact that if $n+1$ and $n$ are both squares then $n=0$, contradicting problem condition.

If $n+1$ is not a square, then it has prime factors with odd powers in $n$. Let $k$ be the largest of such factor and $a$ is its power. Meaning, $k^a | n+1$ but $k^{a+1}$ does not divide $n+1$.

Now suppose there exist $p,q$ relatively prime such that $$\sqrt{\frac{n}{n+1}}=\frac{p}{q}$$ $$(n+1)p^2 = nq^2$$ Because $k^a | LHS$ then $k^a | RHS$. If $k^a | n$ then $k | (n+1)-n = 1$, a contradiction (because $k$ is a prime).

And because $k$ is prime then $k^a | q^2$ which means $k^{a+1} | q^2$ (because $a$ is odd). This means that $k$ divides $p$, contradicting our assumption that $p,q$ are relatively prime.

Monday, October 1, 2018

Sum over hypercube

Let $n$ be a positive integer, and suppose $a = a_1, \dots, a_{2019}$ is a sequence of integers each ranging from $1,\dots,n$. Determine the sum of $$\sum_a \frac{a_1 - a_2 + a_3 + \dots -a_{2018} + a_{2019}}{a_1 + \dots + a_{2019}}$$ Where the sum is taken over all possible sequences in that range.

Friday, September 7, 2018

Cube sum of digits

Find all integers that is equal to the cube of sum of its digits.

Solution

Clearly 0 satisfies the problem statement, and negative numbers cannot satisfy. So now we may assume that the integer is positive.

Suppose $N = a_1 \dots a_d$ where each $a_i$ is a single digit, and $a_1 \neq 0$. Because $N \geq {10}^{d-1}$ and $N = (a_1 + \dots + a_d)^3 \leq (9d)^3$ so we must have: $$10^{d-1} \leq 9d^3 $$

For large $d$ this inequality fails to hold. In fact, it's only true for $d \leq 4$. So $N$ is a 4-digit number, which is also a cube. Therefore $N \leq 21^3$ because $22^3 > 10^5$.

Now consider modulo 9: we know that $N \equiv (a_1 + \dots + a_d) \mod 9$ so: $$ N = (a_1 + \dots + a_d)^3 \equiv N^3 \mod 9$$ Among all the residues modulo 9, only 0, 1, 8 satisfy $x \equiv x^3 \mod 9$. Therefore $N \equiv 0, 1, 8 \mod 9$.

So now our candidates are: $N = 1^3, 8^3, 10^3, 17^3, 18^3$. By inspection, only $N = 1^3 = 1, 8^3 = 512, 17^3 = 4913, 18^3 = 5832$ satisfy.

Saturday, July 14, 2018

Maximum point above triangle

In triangle $ABC$, $AD$ is an internal bisector. Choose point $X$ on $DA$'s extension, and let $Y,Z$ be on $XB$ and $XC$ so that $AY \perp XB$ and $AZ \perp XC$. Define $f(X)$ as: $$f(X) = \frac{AY}{XB} + \frac{AZ}{XC}$$ Find the point $X*$ along $DA$'s extension such that $f(X*)$ is maximum.

Solution

Let $\theta = \angle XAB = \angle XAC$. Easy to see that $\pi/2 < \theta < \pi$. Let $x = AX$.

Area of $\triangle ABX$ = $$\frac{1}{2}cx \sin \theta = \frac{1}{2} XB.AY$$ So: $$\frac{AY}{XB} = \frac{cx \sin \theta}{XB^2} = \frac{cx\sin \theta}{c^2+x^2-2cx \cos \theta}$$ And likewise: $$\frac{AZ}{XC} = \frac{bx\sin \theta}{b^2+x^2-2bx \cos \theta}$$ Now suppose WLOG $c > b$ and $c = tb$ (with $t > 1$). Then we need to maximize: $$\frac{cx}{c^2+x^2-2cx \cos \theta} + \frac{bx}{b^2+x^2-2bx \cos \theta}$$ $$ \frac{\frac{x}{bt}}{(\frac{x}{bt})^2 + 1 - 2 t\frac{x}{bt}\cos \theta }+\frac{\frac{x}{b}}{(\frac{x}{b})^2 + 1 - 2 \frac{x}{b}\cos \theta }$$ So if we let $y = x/b$, and $r = -2 \cos \theta$ (which means $0 < r < 2$), and $g(s) = s/(s^2+rs+1)$ then the problem is akin to finding the minimum of the following function for $y > 0$: $$h(y) = g(y) + g(\frac{y}{t})$$

Wednesday, May 16, 2018

Shifting matrix

An $n \times n$ matrix is filled with numbers, where there are $k$ number ones and the rest zero. The operation that is allowed on the matrix is to shift a single column down by one (so that each number in that column moves down by one, and the bottom most number goes to the top), or to shift a single row to the left by one.

Determine all $k$ such that, no matter how the initial condition is, through a series of operations, we can make it so that each column and each row has an even sum.