TITLE: Let $k \geq 3$; prove $2^k$ can be written as $(2m+1)^2+7(2n+1)^2$
QUESTION [5 upvotes]: Prove: 
If $k \geq 3$, then $2^k$ can be written as $(2m+1)^2+7(2n+1)^2$, where $k, m, n \in \mathbb{N}$.

REPLY [3 votes]: You need to be careful about just one thing in the induction step. Note that the first case is $$  1^2 + 7 \cdot 1^2 = 8 = 2^3.  $$
The important thing is that 
$$ 1 \equiv 1 \pmod 4.   $$
So, we begin with $$   a^2 + 7 b^2 = 2^k   $$
with $k \geq 3$ AND
$$ a \equiv b \pmod 4,   $$ then we do the induction step.
What the formula of Brahmagupta does for you is to allow us to multiply the value $2^k$ by 8, as in
$$ (a - 7 b)^2 + 7 (a+b)^2 = 8 \cdot 2^k = 2^{k+3}.   $$
At this stage, both numbers $a-7b,a+b$  are even, which is bad. On the other hand,
$$  a - 7 b \equiv a+b \pmod 8.  $$ As a result, when we divide by 2, we get
$$ \frac{ a - 7 b}{2} \equiv \frac{a+b}{2} \pmod 4.  $$
Furthermore, as $ a \equiv b \pmod 4,   $ we know that $ a + b \equiv 2 \pmod 4,   $ so that $\frac{a+b}{2} $ is once again ODD. 
We have completed the induction step, as
$$ \left( \frac{ a - 7 b}{2} \right)^2 + 7 \left( \frac{a+b}{2} \right)^2 = 2 \cdot 2^k = 2^{k+1}, $$  with both numbers odd and the extra property we need to continue  the induction,$$ \frac{ a - 7 b}{2} \equiv \frac{a+b}{2} \pmod 4.  $$
It may be worth mentioning that we need to allow negative values for $(a,b)$ in order to keep the mod 4 thing going. So the pairs go
$$ (1,1), \; \; (-3,1), \; \; (-5,-1), \; \; (1,-3), \; \; (11,-1), \; \; (9,5),    $$
$$ (-13,7), \; \; (-31,-3), \; \; (-5,-17), \; \; (57,-11), \; \; (67,23), \; \; (-47,45),    $$
$$ (-181,-1), \; \; (-87,-91), \; \; (275,-89), \; \; (449,93), \; \; (-101,271), \; \; (-999,85), \ldots   $$