# Is there a way to solve $\sqrt a + \sqrt b = \sqrt n$ analytically?

Often in (high school) math competitions, there are equations that look very simple, yet are non-trivial to solve. One such problem is

$$\sqrt a + \sqrt b = \sqrt n$$

where $a, b \in \mathbb{Z}$ and $n$ is usually an arbitrary value, like a year (e.g. $n = 2016$).

The problem then asks to find all possible values of $a$ and $b$.

Is there a way to solve this problem analytically, or is there a method that can be done by hand (or with a scientific, non-programmable calculator) that isn't just trial-and-error?

A basic fact that comes out of Galois theory is that the set $\{\sqrt{d_i}\}_{i \in I}$ is linearly independent over $\mathbb Q$, where $\{d_i\}_{i \in I}$ enumerates all square-free integers (including negative integers!). Since $\sqrt a + \sqrt b = \sqrt n$ expresses a linear dependence among three different square roots, it actually follows that the square free parts of $a, b, n$ must, in fact, all be the same.
So all you need to do is factor the largest square out of $n$ to get $n = k^2 m$ with $m$ square-free - in the case of $n=2016$, this is $2016 = 12^2 \cdot 14$ - and then find all ways of breaking up $k$ as a sum of two nonnegative integers, i.e., $s \sqrt m + t \sqrt m = k \sqrt m$ with $s+t=k$. Then you simply factor $s, t, k$ back inside their respective terms, to get $\sqrt{s^2 m} + \sqrt{ t^2 m} = \sqrt{k^2 m}$.
There are $k+1$ solutions to this equation, or $\left\lceil \frac{k+1}{2} \right\rceil$ solutions if you prefer to omit the ones that come from switching the two terms being added.
$$\sqrt{ 0 }+\sqrt{ 2016 }= \sqrt{2016}$$ $$\sqrt{ 14 }+\sqrt{ 1694 }= \sqrt{2016}$$ $$\sqrt{ 56 }+\sqrt{ 1400 }= \sqrt{2016}$$ $$\sqrt{ 126 }+\sqrt{ 1134 }= \sqrt{2016}$$ $$\sqrt{ 224 }+\sqrt{ 896 }= \sqrt{2016}$$ $$\sqrt{ 350 }+\sqrt{ 686 }= \sqrt{2016}$$ $$\sqrt{ 504 }+\sqrt{ 504 }= \sqrt{2016}$$ $$\sqrt{ 686 }+\sqrt{ 350 }= \sqrt{2016}$$ $$\sqrt{ 896 }+\sqrt{ 224 }= \sqrt{2016}$$ $$\sqrt{ 1134 }+\sqrt{ 126 }= \sqrt{2016}$$ $$\sqrt{ 1400 }+\sqrt{ 56 }= \sqrt{2016}$$ $$\sqrt{ 1694 }+\sqrt{ 14 }= \sqrt{2016}$$ $$\sqrt{ 2016 }+\sqrt{ 0 }= \sqrt{2016}$$