TITLE: Tiling a square with rectangles
QUESTION [22 upvotes]: Consider the set of all the rectangles with dimensions $2^a\times 2^b\,a,b\in \mathbb{Z}^{\ge 0}$. We want to tile an $n\times n$ square by rectangles from this set (you can use a rectangle several times). What is the minimum number of rectangles we need?
If $f(n)$ is the sum of digits of $n$ in base $2$, I think we need at most $f(n)^2$ rectangles. I have an example for this number: write $n=2^{a_1}+2^{a_2}+...2^{a_{f(n)}}$ and split each side to segments with length $2^{a_1},2^{a_2},...,2^{a_{f(n)}}$ and consider $f(n)^2$ rectangles obtained this way.
On the other hand, you need at least $f(n)$ rectangles to tile a raw (or column) so I think you need $f(n)^2$ rectangles, but I can't prove it.
Any ideas?

REPLY [3 votes]: For fixed $n$, you can solve this problem via integer linear programming as follows.  Let $R$ be the set of rectangles.  For $i\in\{1,\dots,n\}, j\in\{1,\dots,n\}$, let $R_{i,j}\subset R$ be the subset of rectangles that contain cell $(i,j)$.  Let binary decision variable $x_r$ indicate whether rectangle $r\in R$ is used.  The problem is to minimize $\sum_r x_r$ subject to:
\begin{align}
\sum_{r \in R_{i,j}} x_r &= 1 &&\text{for $i\in\{1,\dots,n\}, j\in\{1,\dots,n\}$} \\
x_r &\in \{0,1\} &&\text{for $r \in R$}
\end{align}
Here are several optimal values that differ from $f(n)^2$:
\begin{matrix}
n              &15 &23 &30 &31 &46 &47 &55 &59 &60 &61 &62 &63\\
\hline
f(n)^2         &16 &16 &16 &25 &16 &25 &25 &25 &16 &25 &25 &36\\
\text{optimal} &13 &15 &13 &17 &15 &19 &20 &20 &13 &20 &17 &21\\
\end{matrix}
For example, here is an optimal solution for $n=23$ with $15$ rectangles (shown here with hex values $0$ through $E$ for compactness):
\begin{matrix}
0&0&0&0&0&0&0&0&A&A&A&A&8&B&B&B&B&B&B&B&B&9&9\\
5&5&5&5&5&5&5&5&A&A&A&A&8&B&B&B&B&B&B&B&B&9&9\\
5&5&5&5&5&5&5&5&A&A&A&A&8&B&B&B&B&B&B&B&B&9&9\\
5&5&5&5&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