Find the minimum $n$ such that $x^2+7=\sum_{k=1}^n f_k(x)^2$ where $f_k(x)\in \mathbb{Q}[x]$ Recently, I have found this problem:

Find the minimum $n \in N$ such that $x^2+7=f_1(x)^2+f_2(x)^2+\cdots+f_n(x)^2$ where $f_1(x),+f_2(x),+\cdots+f_n(x)$ are polynomials with rational coefficients. 

I have tried to solve this problem when $n=2$ using $f_1(x)=(a_1x+b_1)^2$ and $f_2(x)=-(a_2x+b_2)^2$, but I can't go on. Any idea?
 A: Assume you can do this with three polynomials. Then you can write $7$ as a sum of three rational squares. In other words, there are integers $a,b,c,d$ with no common divisor such that $7d^2=a^2+b^2+c^2$. 
Reducing mod $8$, we see a contradiction (squares are congruent to $0$, $1$ or $4$) since not all of $a,b,c,d$ can be even. 
So you need $n \geq 4$ to work. 
Now we show that you need actually $n \geq 5$. Denote as $a,b,c,d$ the leading coefficients of the polynomials. 
For the standard inner product, we notice that $e_1=(a,b,c,d),e_2=(-b,a,d,-c),e_3=(-d,c,-b,a),e_4=(-c,-d,a,b)$ is an orthonormal basis of $\mathbb{Q}^4$. 
So we can write the vector of the constant coefficients as an orthogonal linear combination of $e_2,e_3,e_4$. It follows that its squared norm is the sum of three rational squares so isn’t $7$. 
So $n=4$ does not work. 
It was already known that $n=5$ did.
Sorry for the not-elementary argument for an IMO Shortlist problem though.
A: Let's assume you can do with only two polynomials. Then we have:
$$
p = \sum_{i=1}^{k_1}{p_nx^n}
\\
q = \sum_{i=1}^{k_2}{q_nx^n}
$$
with
$$
p^2+q^2 =x^2 +7
$$
Therefore, if we can do it with only two polynomials, then there's a solution for
$$x^2+7 = (ax+b)^2 + (cx+d)^2 
\\
x^2+7 = (a^2+c^2)x^2+(2ab+2cd)x + (b^2+d^2)
$$
By equating coefficients and solving the equation system for $a,b,c$, we have 
$$a =\pm \frac d{\sqrt7}$$
And therefore either $a$ or $d$ is irrational.
A: You cannot go on this way, because even if you take a function negative, its square will be positive. Observe that degree of all of the polynomials is less than 2, because degree of LHS and RHS should match. It is easy to see that $n=1$ is not a solution. For $n=2$, we observe,
$$(ax+b)^2+(cx+d)^2=x^2+7$$
$$\Longrightarrow (a^2+c^2)x^2+2(ab+cd)x+(b^2+d^2)=x^2+7$$
$$\Longrightarrow a^2+c^2=1, ab+cd=0, b^2+d^2=7$$
Now, apply a trick. From second equation we get,
$$ab=-cd$$
$$\Longrightarrow \frac{a}{d}=\frac{-c}{b}$$
Apply ratio and proportion,
$$\Longrightarrow \frac{a}{d}=\frac{-c}{b}=\pm\sqrt{\frac{a^2+c^2}{d^2+b^2}}$$
The ratio on the RHS is irrational by first and third equations. Hence, $n=2$ is also not a solution.
For, $n=3$, we have the following solution.
$$f_1(x)=x$$
$$f_2(x)=\frac{21}{5}$$
$$f_3(x)=\frac{28}{5}$$
Hence, this is the required solution.
Hope it helps:)
A: The answer of @Mindlack contains a full solution to the problem. This thread just collects some partial results I got while studying the problem, using only the idea from @Mindlack that $7$ is not the sum of $3$ or less squares of rationals.
Partial results
Notice we can only use polynomials with degree at most $1$, since the coeficient of the leading term of $f_i(x)^2$ is always positive.
Easy upper bound. Taking $f_1(x) = x$ and using the idea on the comments that we can write $7 = 1^2 + 1^2 + 1^2 + 2^2$. This gives a way of using $5$ polynomials.
The argument of @Mindlack. Looking only at the constant coeficients modulo $8$, if we used only $3$ polynomials we would have $7d^2 = a^2 + b^2 + c^2$ with $a,b,c,d$ integers and $\mathrm{gcd}(a,b,c,d)=1$. Since squares modulo $8$ are only $0, 1, 4$, this is impossible. This shows that $n \geq 4$. Also, it will be used again on the arguments below.
Using only one linear polynomial.  Using $f_1(x) = ax + b$ implies that $f_1(x)^2 = a^2 x^2 + 2ab x + b^2$ and we need that $a^2 = 1$, $ab=0$, thus $a = \pm 1$ and $b=0$. Since the other $f_i$ are rationals, the argument of @Mindlack implies we need at least $4$ other polynomials in this case.
Using only two linear polynomials. Take $f_1(x) = a_1x + b_1$ and $f_2(x) = a_2x + b_2$, implying that
$$
f_1(x)^2 + f_2(x)^2 = (a_1^2 + a_2^2) x^2 + 2(a_1b_1 + a_2b_2)x + (b_1^2 + b_2^2).
$$
Since the coeficient of $x^2$ needs to be $1$, we should study the solutions of
$$
a_1^2 + a_2^2 = 1 \quad \text{for rational $a_i$}.
$$
Writing $a_i = \tfrac{p_i}{q_i}$ in lowest terms, we have that
$$
p_1^2 q_2^2 + p_2^2 q_1^2 = q_1^2 q_2^2
$$
Notice that in this case we must have $q_1 \mid q_2$, since $p_1$ and $q_1$ do not have common prime factors. Analogously, $q_2 \mid q_1$ and thus they are equal. Now, we are looking at integer solutions for
$$
p_1^2 + p_2^2 = q^2,
$$
that is, Pythagorean triples. Considering
$$
f_1(x) = \frac{p_1}{q} x + b_1 \quad \text{and} \quad f_2(x) = \frac{p_2}{q} x + b_2
$$
we have
$$
f_1(x)^2 + f_2(x)^2 = x^2 + \frac2q (p_1 b_1 + p_2 b_2) + b_1^2 + b_2^2.
$$
Since the term in $x$ should be zero, we have $b_2 = - b_1 \frac{p_1}{p_2}$ and then
$$
f_1(x)^2 + f_2(x)^2 = x^2 + b_1^2 (1 + \frac{p_1^2}{p_2^2}) = x^2 + b_1^2 \frac{q^2}{p_2^2}.
$$
Notice that the independent term is the square of a rational. Then, using the argument of @Mindlack once again, we cannot use only $4$ polynomials. Indeed, this would imply writing $7$ as a sum of $3$ rational squares.
Partial conclusion. If there is an example with only $4$ polynomials, it must used either $3$ or $4$ linear polynomials.
A: Answer. $n=5$.
Example for $n= 5$. Note that $x^2+7=x^2+1^2+1^2+1^2+2^2$. (See @Semiclassical's comment).
Proof for $n\ge 5$. Suppose that $x^2+7=f_1(x)^2+f_2(x)^2+f_3(x)^2+f_4(x)^2$ for some polynomials $f_i$ with rational coefficients. It can be shown that all $f_i$ are linear (or constant) polynomials, i.e. $f_i(x)=a_ix+b_i$ for $a_i,b_i\in\mathbb{Q}$.
We will use the following @Mindlack's observation: there are no rational numbers $a,b,c$ such that $a^2+b^2+c^2=7$.
Now, the crucial idea: without loss of generality we will suppose that $a_1\neq 1$ (otherwise consider $-f_1$ instead of $f_1$). Thus, there is a rational number $x_0$ such that $f_1(x_0)=x_0$. Hence,
$$
x_0^2+7=f_1(x_0)^2+f_2(x_0)^2+f_3(x_0)^2+f_4(x_0)^2,
$$
or
$$
f_2(x_0)^2+f_3(x_0)^2+f_4(x_0)^2=7.
$$
However, $f_i(x_0)$ are rational numbers and we got a contradiction. Therefore, $n\le 4$ is impossible.
