$x^2+7y^2=2^n$ and sums of four squares

Lagrange's four square theorem states that each $$m\in\mathbb N=\{0,1,2,\ldots\}$$ can be written as a sum of four squares.

Recently, I found that the diophantine equation $$x^2+7y^2=2^n$$ has certain surprising connnection with the four-square theorem. Namely, I have the following conjecture.

Conjecture. Let $$a,b\in\mathbb N$$ with $$a\in\{2,4,6,\ldots\}$$ or $$2\mid b$$. Then $$m=2^a(2b+1)$$ can be written as $$x^2+y^2+z^2+w^2$$ $$(x,y,z,w\in\mathbb N)$$ with $$x^2+7y^2=2^n$$ for some $$n\in\mathbb N$$.

I have verified this for all $$m=1,\ldots,4\times 10^8$$. For example, $$4\times3+1=2^2+0^2+0^2+3^2\ \ \text{with}\ 2^2+7\times0^2=2^2,$$ and $$4\times3+1=2^2+2^2+2^2+1^2\ \ \text{with}\ 2^2+7\times2^2=2^5.$$

QUESTION. What nontrivial things can we say about the diophantine equation $$x^2+7y^2=2^n$$? Why this equation is connected with the four-square theorem in the conjecture manner? Any ideas to solve the above conjecture?

• $4\times 3+1=2^a(2b+1)?$ – Toni Mhax Oct 15 at 5:48
• I don't understand the relation with sum of four squares, and your comments in the answer are confusing. If you can deterministically express $n$ as sum of 4 squares, this will be new result (probabilistic solution is possible). – joro Oct 15 at 7:55
• @Toni $4\times3+1=2^0(2b+1)$ with $b=6$ even. – Zhi-Wei Sun Oct 15 at 9:27
• This is a typical conjecture of OP's: one that has an obvious probabilistic justification, but with little hope of saying a second sentence beyond that. The values allowed for $x^2+y^2$ form a set with about $(\log n)^2$ elements (note that $x$ and $y$ need not be coprime), and one wants $n-x^2 -y^2$ to be a sum of two squares, which happens with probability about $1/\sqrt{\log n}$. So one fails with probability $(1-c/\sqrt{\log n})^{d (\log n)^2} = \exp(-C (\log n)^{\frac 32})$. Since this is very small, "Borel--Cantelli" would indicate that there are at most finitely many exceptions. – Lucia Oct 15 at 16:10
• In my 2017 JNT paper I proved that any positive integer can be written as $x^2+(2xy)^2 +(xz)^2+w^2$ with $y,z,w\in\mathbb N$ and $x$ a power of two. – Zhi-Wei Sun Oct 15 at 18:18

The Diophantine equation $$x^2 + 7y^2 = 2^n$$ is "trivial" in the sense that its solutions can be described in a very simple way (see boxed formula near the end for solutions in odd numbers when $$n \geq 3$$), so I am suspicious that there is anything nontrivial connecting it to the four-square theorem.

Let's take $$n \geq 1$$. Then $$n \geq 2$$ since $$x^2 + 7y^2 = 2$$ has no integral solutions. Reducing both sides of $$x^2 + 7y^2 = 2^n$$ modulo 2, we get $$x + y \equiv 0 \bmod 2$$, so a necessary condition on a solution is that $$x \equiv y \bmod 2$$. That congruence condition is nicely compatible with the fact that the ring of integers of the number field $$K := \mathbf Q(\sqrt{-7})$$ is $$\mathcal O_K := \mathbf Z\left[\frac{1 + \sqrt{-7}}{2}\right] = \left\{\frac{x + y\sqrt{-7}}{2} : x, y \in \mathbf Z, x \equiv y \bmod 2\right\}.$$ This ring is a UFD since it is a PID: $$K$$ is an imaginary quadratic field with class number $$1$$, or you can look at the recent arXiv post by Paul Pollack and Noah Snyder at https://arxiv.org/abs/2010.05033 for a proof that $$\mathcal O_K$$ is a UFD that doesn't rely on algebraic number theory. A factorization of $$2$$ into primes in $$\mathcal O_K$$ is $$2 = \frac{1+\sqrt{-7}}{2} \frac{1 - \sqrt{-7}}{2} = \pi\overline{\pi},$$ where $$\pi = (1 + \sqrt{-7})/2$$ and $$\overline{\pi} = (1 - \sqrt{-7})/2$$ are both prime (their norms are both 2).

Since $$n \geq 2$$, the Diophantine equation $$x^2 + 2y^2 = 2^n$$ can be rewritten as $${\rm N}((x + y\sqrt{-7})/2) = 2^{n-2}$$, where $${\rm N}$$ is the norm function on $$\mathcal O_K$$. A prime element of $$\mathcal O_K$$ has norm equal to the power of a prime number, so the prime factors of $$(x+y\sqrt{-7})/2$$ must be prime factors of $$2$$. The only prime factors of 2 in $$\mathcal O_K$$ up to sign (the units of $$\mathcal O_K$$ are $$\pm 1$$) are $$\pi$$ and $$\overline{\pi}$$, so $${\rm N}\left(\frac{x + y\sqrt{-7}}{2}\right) = 2^{n-2} \Longleftrightarrow \frac{x+y\sqrt{-7}}{2} = \pm \pi^k\overline{\pi}^\ell$$ where $$k$$ and $$\ell$$ are nonnegative integers such that $$k + \ell = n-2$$.

If $$k$$ and $$\ell$$ are both positive then $$\pi^k\overline{\pi}^\ell$$ is divisible in $$\mathcal O_K$$ by $$\pi\overline{\pi} = 2$$, which makes $$x$$ and $$y$$ both even: $$\pi^{k-1}\overline{\pi}^{\ell - 1} = (a + b\sqrt{-7})/2$$ for some integers $$a$$ and $$b$$, so $$\frac{x+y\sqrt{-7}}{2} = \pm 2\frac{a+b\sqrt{-7}}{2} \Longrightarrow x = \pm 2a, y = \pm 2b.$$ Solutions of $$x^2 +7y^2 = 2^n$$ with even $$x$$ and $$y$$ and $$n \geq 2$$ can be divided through by $$4$$ in every term of the equation, so the "interesting" integral solutions of $$x^2 + 7y^2 = 2^n$$ are the ones where $$x$$ or $$y$$ is odd, which means in fact that both $$x$$ and $$y$$ are odd, since $$x \equiv y \bmod 2$$. That forces $$k = 0$$ or $$\ell = 0$$: $$x^2 + 7y^2 = 2^n \ {\sf with } \ x, y \ {\sf odd} \Longleftrightarrow \frac{x+y\sqrt{-7}}{2} = \pm \pi^{n-2} \ {\sf or } \ \pm \overline{\pi}^{n-2}.$$ Changing signs on $$x$$ and $$y$$ is an easy adjustment, so for $$n \geq 2$$ the only integral solution of $$x^2 + 7y^2 = 2^n$$ in odd $$x$$ and $$y$$, up to sign, is the coefficients in
$$\boxed{\frac{x+y\sqrt{-7}}{2} = \pi^{n-2} = \left(\frac{1+\sqrt{-7}}{2}\right)^{n-2}.}$$

When $$n = 2$$, $$(x + y\sqrt{-7})/2 = \pi^0 = 1$$, so $$x = 2$$ and $$y = 0$$, which are not odd (this is just saying $$x^2 + 7y^2 = 4$$ only when $$(x,y) = (\pm 2,0)$$). For $$n \geq 3$$, $$x$$ and $$y$$ are odd (a proof is below). For example, the only solution of $$x^2 + 7y^2 = 2^9$$ in odd numbers comes from coefficients of $$\frac{x+y\sqrt{-7}}{2} = \pi^7 = \frac{-13 + 7\sqrt{-7}}{2},$$ so $$(x,y) = (13,7)$$ up to sign. The unique solution of $$x^2 + 7y^2 = 2^n$$ in positive odd numbers for $$n = 3, 4, 5, 6, 7, 8$$ are $$(1,1)$$, $$(3,1)$$, $$(5,1)$$, $$(1,3)$$, $$(11,1)$$, and $$(9,5)$$.

Let's show the coefficients $$x$$ and $$y$$ in the boxed formula above are odd when $$n \geq 3$$: setting $$((1+\sqrt{-7})/2)^m = (a_m + b_m\sqrt{-7})/2$$, when $$m \geq 1$$ the integers $$a_m$$ and $$b_m$$ are odd. Since $$a_m^2 + 7b_m^2 = 2^{m+2} \equiv 0 \bmod 2$$, we have $$a_m \equiv b_m \bmod 2$$, so it suffices to show $$a_m$$ is odd. By considering the conjugate formula $$((1-\sqrt{-7})/2)^m = (a_m - b_m\sqrt{-7})/2$$, $$a_m = \left(\frac{1+\sqrt{-7}}{2}\right)^m + \left(\frac{1-\sqrt{-7}}{2}\right)^m.$$ To check how divisible the integer $$a_m$$ is by $$2$$, view the formula for it in the $$2$$-adic integers, which contains two square roots of $$-7$$: $$1 + 2 + 2^3 + 2^6 + \ldots, \ \ \ 1 + 2^2 + 2^4 + 2^5 \cdots$$ Embed $$\mathbf Q(\sqrt{-7})$$ into $$\mathbf Q_2$$ by letting $$\sqrt{-7}$$ be the first $$2$$-adic expansion above. Then the other expansion is $$-\sqrt{-7}$$, so in $$\mathbf Z_2$$ $$\frac{1 + \sqrt{-7}}{2} = 2 + 2^2 + 2^5 + \cdots, \ \ \ \frac{1 - \sqrt{-7}}{2} = 1 + 2 + 2^3 + 2^4 + \cdots, \ \ \$$ Thus $$(1+\sqrt{-7})/2 \equiv 0 \bmod 2\mathbf Z_2$$ and $$(1 - \sqrt{-7})/2 \equiv 1 \bmod 2\mathbf Z_2$$, so for $$m \geq 1$$ we have $$((1+\sqrt{-7})/2)^m \equiv 0 \bmod 2\mathbf Z_2$$ (not if $$m$$ is zero!) and $$((1 - \sqrt{-7})/2)^m \equiv 1 \bmod 2\mathbf Z_2$$. Therefore $$a_m \equiv 0 + 1 \equiv 1 \bmod 2\mathbf Z_2$$ for $$m \geq 1$$, so $$a_m$$ is odd.

• Thanks. But this does not imply the conjecture. – Zhi-Wei Sun Oct 15 at 4:16
• So do you want me to delete my answer because of that? I am just showing that solutions in odd numbers to $x^2 + 7y^2 = 2^n$ (for $n \geq 3$) can be very easily described. Solutions in even numbers (for varying $n$) must come from multiplying an odd solution by powers of 2, so there is nothing deep about the integral solutions to this Diophantine equation. – KConrad Oct 15 at 4:18
• @Zhi-WeiSun: this looks to me like a pretty exhaustive answer to your actual question "What nontrivial things can we say about the diophantine equation $x^2+7y^2=2^n$. – Alex B. Oct 15 at 11:05
• @Alex My feeling is that the OP uses this site as a place to advertise his "conjectures", many of which are just experimental results without much thought. See all his other posts. – WhatsUp Oct 15 at 23:27
• @WhatsUp yes, and on NMBRTHRY for years and years and years listserv.nodak.edu/cgi-bin/wa.exe?A0=NMBRTHRY archives – Will Jagy Oct 16 at 14:37