### Archive

Archive for the ‘Uncategorized’ Category

## IMO 2018 Problems – Day 1

Problem 1. Let ${\Gamma}$ be the circumcircle of acute triangle ${ABC}$. Points ${D}$ and ${E}$ are on segments ${AB}$ and ${AC}$ respectively such that ${AD = AE}$. The perpendicular bisectors of ${BD}$ and ${CE}$ intersect minor arcs ${AB}$ and ${AC}$ of ${\Gamma}$ at points ${F}$ and ${G}$ respectively. Prove that lines ${DE}$ and ${FG}$ are either parallel or they are the same line.

Problem 2. Find all integers ${n \geq 3}$ for which there exist real numbers ${a_1, a_2, \dots a_{n + 2}}$ satisfying ${a_{n + 1} = a_1}$, ${a_{n + 2} = a_2}$ and

$\displaystyle a_ia_{i + 1} + 1 = a_{i + 2}$

For ${i = 1, 2, \dots, n}$.

Problem 3. An anti-Pascal triangle is an equilateral triangular array of numbers such that, except for the numbers in the bottom row, each number is the absolute value of the difference of the two numbers immediately below it. For example, the following is an anti-Pascal triangle with four rows which contains every integer from ${1}$ to ${10}$

$\displaystyle 4$

$\displaystyle 2\quad 6$

$\displaystyle 5\quad 7 \quad 1$

$\displaystyle 8\quad 3 \quad 10 \quad 9$

Does there exist an anti-Pascal triangle with ${2018}$ rows which contains every integer from ${1}$ to ${1 + 2 + 3 + \dots + 2018}$?

Source: AoPS.

## Using parfor in Matlab

We all know that loops don’t behave well in Matlab. Whenever it is possible to vectorize the code (i.e. use vectors and matrices to do simultaneous operations, instead of one at a time) significant speed-up is possible. However, there are complex tasks which cannot be vectorized and loops cannot be avoided. I recently needed to compute eigenvalues for some 10 million domains. Since the computations are independent, they could be run in parallel. Fortunately Matlab offers a simple way to do this, using parfor.

There are some basic rules one need to respect to use parfor efficiently:

1. Don’t use parfor if vectorization is possible. If the task is not vectorizable and computations are independent, then parfor is the way to go.
2. Variables used in each computation should not overlap between processors. This is for obvious reasons: if two processors try to change the same variable using different values, the computations will be meaningless in the end.
3. You can use an array or cell to store the results given by each processor, with the restriction that processors should work on disjoint parts of the array, so there is no overlap.

The most restrictive requirement is the fact that one cannot use the same variables in the computations for different processors. In order to do this, the simplest way I found was to use a function for the body of the loop. When using a matlab function, all variables are local, so when running the same function in parallel, the variables won’t overlap, since they are local to each function.

So instead of doing something like

parfor i = 1:N
commands ...
array(i) = result
end


you can do the following:

parfor i=1:N
array(i) = func(i);
end

function res = func(i)
commands...


This should work very well and no conflict between variables will appear. Make sure to initialize the array before running the parfor, a classical Matlab speedup trick: array = zeros(1,N). Of course, you could have multiple outputs and the output array could be a matrix.

There is another trick to remember if the parpool cannot initialize. It seems that the parallel cluster doesn’t like all the things present in the path sometimes. Before running parfor try the commands

c = parcluster('local');
c.parpool


If you recieve an error, then run

restoredefaultpath
c = parcluster('local');
c.parpool


and add to path just the right folders for your code to work.

## Putnam 2017 A2 – Solution

Problem A2. We have the following recurrence relation

$\displaystyle Q_n = \frac{Q_{n-1}^2-1}{Q_{n-2}},$

for ${n \geq 2}$, given ${Q_0=1}$ and ${Q_1=x}$. In order to prove that ${Q_n}$ is always a polynomial with integer coefficients we should prove that ${Q_{n-2}}$ divides ${Q_{n-1}^2-1}$ somehow. Recurrence does not seem to work very well. Also, root based arguments might work, but you need to take good care in the computation.

A simpler idea, which is classic in this context, is to try and linearize the recurrence relation. In order to do this, let’s write two consecutive recurrence relations

$\displaystyle Q_nQ_{n-2} +1 = Q_{n-1}^2$

$\displaystyle Q_n^2 = Q_{n+1}Q_{n-1}+1$

We add them and we obtain the following relation

$\displaystyle \frac{Q_n}{Q_{n-1}} = \frac{Q_{n+1}+Q_{n-1}}{Q_n+Q_{n-2}},$

which leads straightforward to a telescoping argument. Finally, we are left with a simple linear recurrence with integer coefficient polynomials, and the result follows immediately.

## Putnam 2017 – Problem A1

Problem A1. We have ${n^2 \in S \Rightarrow N \in S}$ and ${n \in S \Rightarrow (n+5)^2 \in S}$. Therefore ${n \in S \Rightarrow n+5 \in S}$.

Next, let’s note what elements cannot be in ${S}$. Note that taking square roots and squaring ${n+5}$ cannot change a non-zero remainder modulo ${5}$ into a zero remainder. Therefore, starting from ${2}$ one could never get a multiple of ${5}$ following the allowed operations. Thus we can safely say that multiples of ${5}$ are not in the minimal set ${S}$.

Furthermore, ${1}$ could only be obtained as a square root of itself with the allowed operations. Starting from ${2}$, one could never get below by performing square roots or ${n \mapsto (n+5)^2}$. Therefore, the minimal set ${S}$ does not contain ${1}$ and multiples of ${5}$.

Now, we show that it contains all the rest. The general idea is as follows: it is enough to find which is the smallest element in a class of remainders modulo ${5}$ to deduce that all larger elements are there (recall the operation ${n \in S \Rightarrow n+5\in S}$). Now in order to obtain small elements of ${S}$, one would need to take successive square roots. So if we prove that for some ${a}$ we have ${a^{2^n}\in S}$ for some ${n}$ then we get that ${a \in S}$.

Now let’s start from the beginning. We have ${2 \in S}$ so ${49 = (2+5)^2 \in S}$. Since ${49+5k}$ is in ${S}$ for every ${k}$, we get that all squares of the form ${5k+4}$ greater than ${49}$ are in ${S}$. Moreover, ${(49+5)^2 = 2916}$ so all numbers of the form ${5k+1}$ greater than ${2916}$ are in ${S}$. Since ${81^2 =6561}$ it follows that ${6561 \in S \Rightarrow 81 \in S \Rightarrow 9 \in S \Rightarrow 3 \in S}$. Moreover, ${6^{16}}$ ends in ${6}$ and is greater than ${2916}$ so ${6 \in S}$. Next, we have ${4^8 = 16^4}$ which ends in ${6}$ and is greater than ${2916}$ so it is also in ${S}$. Therefore ${4 \in S}$.

Finally, we have that ${n \in S \Rightarrow n+5 \in S}$, ${\{2,3,4,6\} \subset S}$ and ${1 \notin S}$, ${5k \notin S}$. This means that the minimal set ${S}$ is ${\Bbb{Z}_+^* \setminus\{1\} \setminus \{5k: k \in \Bbb{Z}_+\}}$.

Categories: Uncategorized

## Putnam 2017 – Problems

Source: Art of Problem Solving forum

Problem A1. Let ${S}$ be the smallest set of positive integers such that

• a) ${2}$ is in ${S,}$
• b) ${n}$ is in ${S}$ whenever ${n^2}$ is in ${S,}$ and
• c) ${(n+5)^2}$ is in ${S}$ whenever ${n}$ is in ${S.}$

Which positive integers are not in ${S?}$

(The set ${S}$ is “smallest” in the sense that ${S}$ is contained in any other such set.)

Problem A2. Let ${Q_0(x)=1}$, ${Q_1(x)=x,}$ and

$\displaystyle Q_n(x)=\frac{(Q_{n-1}(x))^2-1}{Q_{n-2}(x)}$

for all ${n\ge 2.}$ Show that, whenever ${n}$ is a positive integer, ${Q_n(x)}$ is equal to a polynomial with integer coefficients.

Problem A3. Let ${a}$ and ${b}$ be real numbers with ${a and let ${f}$ and ${g}$ be continuous functions from ${[a,b]}$ to ${(0,\infty)}$ such that ${\int_a^b f(x)\,dx=\int_a^b g(x)\,dx}$ but ${f\ne g.}$ For every positive integer ${n,}$ define

$\displaystyle I_n=\int_a^b\frac{(f(x))^{n+1}}{(g(x))^n}\,dx.$

Show that ${I_1,I_2,I_3,\dots}$ is an increasing sequence with ${\displaystyle\lim_{n\rightarrow\infty}I_n=\infty.}$

Problem A4. A class with ${2N}$ students took a quiz, on which the possible scores were ${0,1,\dots,10.}$ Each of these scores occurred at least once, and the average score was exactly ${7.4.}$ Show that the class can be divided into two groups of ${N}$ students in such a way that the average score for each group was exactly ${7.4.}$

Problem A5. Each of the integers from ${1}$ to ${n}$ is written on a separate card, and then the cards are combined into a deck and shuffled. Three players, ${A,B,}$ and ${C,}$ take turns in the order ${A,B,C,A,\dots}$ choosing one card at random from the deck. (Each card in the deck is equally likely to be chosen.) After a card is chosen, that card and all higher-numbered cards are removed from the deck, and the remaining cards are reshuffled before the next turn. Play continues until one of the three players wins the game by drawing the card numbered ${1.}$

Show that for each of the three players, there are arbitrarily large values of ${n}$ for which that player has the highest probability among the three players of winning the game.

Problem A6. The ${30}$ edges of a regular icosahedron are distinguished by labeling them ${1,2,\dots,30.}$ How many different ways are there to paint each edge red, white, or blue such that each of the 20 triangular faces of the icosahedron has two edges of the same color and a third edge of a different color?

Problem B1. Let ${L_1}$ and ${L_2}$ be distinct lines in the plane. Prove that ${L_1}$ and ${L_2}$ intersect if and only if, for every real number ${\lambda\ne 0}$ and every point ${P}$ not on ${L_1}$ or ${L_2,}$ there exist points ${A_1}$ on ${L_1}$ and ${A_2}$ on ${L_2}$ such that ${\overrightarrow{PA_2}=\lambda\overrightarrow{PA_1}.}$

Problem B2. Suppose that a positive integer ${N}$ can be expressed as the sum of ${k}$ consecutive positive integers

$\displaystyle N=a+(a+1)+(a+2)+\cdots+(a+k-1)$

for ${k=2017}$ but for no other values of ${k>1.}$ Considering all positive integers ${N}$ with this property, what is the smallest positive integer ${a}$ that occurs in any of these expressions?

Problem B3. Suppose that

$\displaystyle f(x) = \sum_{i=0}^\infty c_ix^i$

is a power series for which each coefficient ${c_i}$ is ${0}$ or ${1}$. Show that if ${f(2/3) = 3/2}$, then ${f(1/2)}$ must be irrational.

Problem B4. Evaluate the sum

$\displaystyle \sum_{k=0}^{\infty}\left(3\cdot\frac{\ln(4k+2)}{4k+2}-\frac{\ln(4k+3)}{4k+3}-\frac{\ln(4k+4)}{4k+4}-\frac{\ln(4k+5)}{4k+5}\right)$

$\displaystyle =3\cdot\frac{\ln 2}2-\frac{\ln 3}3-\frac{\ln 4}4-\frac{\ln 5}5+3\cdot\frac{\ln 6}6-\frac{\ln 7}7-\frac{\ln 8}8-\frac{\ln 9}9+3\cdot\frac{\ln 10}{10}-\cdots.$

(As usual, ${\ln x}$ denotes the natural logarithm of ${x.}$)

Problem B5. A line in the plane of a triangle ${T}$ is called an equalizer if it divides ${T}$ into two regions having equal area and equal perimeter. Find positive integers ${a>b>c,}$ with ${a}$ as small as possible, such that there exists a triangle with side lengths ${a,b,c}$ that has exactly two distinct equalizers.

Problem B6. Find the number of ordered ${64}$-tuples ${\{x_0,x_1,\dots,x_{63}\}}$ such that ${x_0,x_1,\dots,x_{63}}$ are distinct elements of ${\{1,2,\dots,2017\}}$ and

$\displaystyle x_0+x_1+2x_2+3x_3+\cdots+63x_{63}$

is divisible by ${2017.}$

Categories: Uncategorized

## A hint for Project Euler Pb 613

The text for Problem 613 can be found here. The hint is the following picture 🙂

## IMC 2017 – Day 2 – Solutions

See the previous post for the statements of the problems.

Problem 6. We have that

$\displaystyle \int_0^1 f(nx) dx = \frac{1}{n} \int_0^n f(x)dx$

Suppose ${f(x) \geq L}$ for ${x > M}$. Then for ${n \gg M}$ we have

$\displaystyle \frac{1}{n} \int_0^n f(x) = \frac{1}{n} \int_0^M f(x) dx + \frac{1}{n}\int_M^n f(x) dx \geq \frac{1}{n} \int_0^M f(x)dx + \frac{n-M}{n}L.$

This shows that ${\displaystyle \liminf\limits_{n \rightarrow \infty} \frac{1}{n} \int_0^n f(x) dx \geq L}$. In the same way, having ${f(x) \leq L}$ for ${x>M}$ leads to ${\displaystyle \limsup_{n \rightarrow \infty} \frac{1}{n} \int_0^n f(x)dx \leq L}$.

Now all we need to do is to apply the above procedure to inequalities of the form ${f(x) \leq L+\delta}$ for ${x>M}$ and ${f(x) \geq L-\delta}$ for ${x>M}$, which come from the definition of the limit when ${x \rightarrow \infty}$. The case ${L}$ infinite is similar.

Problem 7. If all roots of ${q_n}$ are real then the sum of their square is non-negative. Suppose ${p}$ is a polynomial of degree ${d>0}$. If we denote ${w_1,...,w_{n+d}}$ are the roots of ${q_n}$ then

$\displaystyle 0 \leq \sum w_i^2 = \left(\sum w_i\right)^2-2\sum_{i

If ${q_n(x) = ax^{n+d}+bx^{n+d-1}+cx^{n+d-2}+...}$ then the previous inequality translates to

$\displaystyle 0 \leq \sum w_i^2 = \left( \frac{b}{a}\right)^2 - 2 \frac{c}{a},$

which is equivalent to ${b^2 - 2ac \geq 0}$. Now if we compute the coefficients ${a,b,c}$ for ${q_n}$ we find something which for ${n \rightarrow \infty}$ contradicts the previous inequality.

Problem 8. We start by observing that the eigenvalues of ${A_1}$ are ${1}$ and ${-1}$. Next, using the properties of block matrix determinants, we have the following equalities

$\displaystyle \det(A_{n+1}-\lambda I) = \det\begin{pmatrix} A_n-\lambda I & I \\ I & A_n-\lambda I \end{pmatrix} = \det((A_n-\lambda I)^2-I)$

$\displaystyle = \det(A_n-(\lambda+1)I)\det(A_n-(\lambda-1)I)$

The block determinant formula holds if ${(A_n-\lambda I)}$ is invertible. This happens for all but finitely many values of ${\lambda}$ (the eigenvalues of ${A_n)}$). Moreover, since the above equalities are polynomial equalities, this implies equality for every ${\lambda}$. Therefore, for each eigenvalue ${\lambda}$ of ${A_n}$ (multiplicity accounted) we have ${\lambda+1}$ and ${\lambda-1}$ as eigenvalues for ${A_{n+1}}$.

Therefore the eigenvalues of ${A_n}$ are

• ${A_2: \ \{-2,0,0,2\}}$
• ${A_3: \ \{-3,-1,-1,-1,1,1,1,3 \}}$
• ${A_4: \ \{-4,-2,-2,-2,-2,0,0,0,0,0,0,2,2,2,2,4\}}$

Note that a phenomenon similar to the Pascal triangle appears, which makes that adjacent eigenvalues of ${A_n}$ (which have a difference equal to ${2}$) with multiplicities ${{n\choose k}}$ and ${{n\choose k+1}}$ generate an eigenvalue of ${A_{n+1}}$ with multiplicity ${{n\choose k}+{n\choose k+1}={n+1 \choose k+1}}$

Problem 9. Elementary techniques in ODE show that ${\displaystyle f_{n+1}(x) = \exp(\int_0^x f_n(t)dt)}$. We note that ${f_1 = 1}$ and ${f_2(x) = e^x}$. Therefore ${f_1\leq f_2}$ on ${[0,1]}$. This implies, using a recurrence argument, that ${f_n(x) \leq f_{n+1}(x)}$. This shows that ${\lim_{n \rightarrow \infty} f_n(x)}$ exists for ${x\in [0,1]}$, but, for now, might be infinite.

In order to find an upper bound we may look what is the equation satisfied by an eventual limit ${F}$ of ${f_n}$ as ${n \rightarrow \infty}$. We arrive at the ODE ${F' = F^2,\ F(0)=1}$. It is immediate to see that ${F(x) = \frac{1}{1-x}}$. Now we would like to prove that ${f_n \leq F}$ on ${[0,1)}$, and for this we define ${g_n = f_n-F}$. Using ${f_n \leq f_{n+1}}$ and the hypothesis we get ${f_{n+1}' \leq f_{n+1}^2}$. Using this we have

$\displaystyle g_n' = f_n'-F' \leq f_n^2 - F^2=g_n(f_n+F)$

and ${g_n(0)=0}$. This implies that

$\displaystyle \left( g_n \exp(-\int_0^x (f_n+F)) \right)'\leq 0$

This implies easily that ${g_n \leq 0}$ on ${[0,1)}$, which means that ${f_n \leq F}$ on ${[0,1)}$. Thus the pointwise limit of ${f_n}$ exists. Let’s denote it by ${G}$. Since ${f_n \leq f_{n+1}}$ using the monotone convergence theorem we have the convergence of integrals ${\int_0^x f_n(t)dt = \int_0^x G(t)dt}$. Thus the limit satisfies

$\displaystyle G(x) = \exp\left(\int_0^x G(t)dt\right).$

Therefore ${G}$ satisfies ${G'=G^2}$ and ${G(0)=1}$ which means that the limit is indeed ${G(x) = 1/(1-x)}$ for ${x \in [0,1)}$.

Categories: Uncategorized