2
$\begingroup$

$\DeclareMathOperator\GF{GF}$Consider the following expression:

$$ \sqrt{a_1} \pm \sqrt{a_2} \pm \dots \pm \sqrt{a_n} = 0, $$

where $a_1, \dots, a_n$ are positive integers. We want to find the number of ways to change each $\pm$ into $+$ or $-$, so that the equation is true.

One way to approach this problem is to pick a sufficiently large random prime number $p$, then find all the square roots in $\GF(p^2)$ (they always exist), and then count the number of ways to satisfy the equation in $\GF(p^2)$.

With high probability, the answer in $\GF(p^2)$ will be the same as in $\mathbb R$. But at the same time, it seems much harder to actually recover such combinations in $\mathbb R$ if they're known in $\GF(p^2)$.

That being said, assume that you know for sure that a particular combination of square roots in $\GF(p^2)$ satisfies the equation. Is there any way to, using this information, recover any such combination that satisfies it in $\mathbb R$?

I guess, what I'm actually asking is, given $p$, I want to algorithmically map each number from $1$ to $p-1$ to one of its two square roots in $\GF(p^2)$ so that by substituting each $\sqrt{a_i}$ via this mapping in the expression above, I will be able to check with high probability that this specific way of changing $\pm$ to $+$ or $-$ is also valid in $\mathbb R$.

$\endgroup$
6
  • 3
    $\begingroup$ Just a note: the first question is NP-complete even if we know that all $a_k$ are squares (and it's not too hard to reduce the general case to this case). $\endgroup$ Commented Nov 23, 2023 at 14:55
  • $\begingroup$ Sure. Still, when $n$ is small, using this allows to solve the problem in $O(2^{n/2})$, even when the integers are very large. $\endgroup$ Commented Nov 23, 2023 at 15:18
  • $\begingroup$ I'm sorry, I might have misunderstood your comment. By the first question, you mean that even if we know a combination of square roots that gives $0$ modulo $p$, it is still an NP-complete problem to match them back to known integer square roots? Is there a simple proof for it? $\endgroup$ Commented Nov 23, 2023 at 15:34
  • $\begingroup$ No, I just meant the question of the count (or even existence) in the original problem (over $\mathbb{R}$). $\endgroup$ Commented Nov 23, 2023 at 16:07
  • 1
    $\begingroup$ Yes, of course, positive integers. Edited the question to reflect it more clearly. $\endgroup$ Commented Nov 24, 2023 at 0:41

2 Answers 2

2
$\begingroup$

I'm not sure why you emphasize linear combinations with coefficients $\pm 1$ to the exclusion of other possible rational coefficients.

In any case, the degree $d=[\mathbf Q(\sqrt{a_1},\ldots,\sqrt{a_n}):\mathbf Q]$ is the order of $\langle a_1,\ldots,a_n\rangle$ in $\mathbf Q^\times/(\mathbf Q^\times)^2$, so it is a power of $2$ that is basically counting how multiplicatively independent the $a_i$'s are modulo rational squares. An approach to proving that multiplicative independence of $a_i$'s mod squares implies their square roots are linearly independent over $\mathbf Q$ by using reduction mod $p$ for a large prime $p$ can be read here.

(Update) In the ring $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]$, each nonzero prime ideal $\mathfrak p$ gives us a quotient ring $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]/\mathfrak p$, which is a finite field whose characteristic $p$ is the prime number such that (i) $\mathfrak p \cap \mathbf Z = p\mathbf Z$ or (ii) $(p)\subset\mathfrak p$ as ideals (these are equivalent properties). That finite field is called the residue field at $\mathfrak p$. Because $\sqrt{a_i}^2 = a_i$ in the ring, we have $\sqrt{a_i}^2 \equiv a_i \bmod \mathfrak p$ in the residue field. The residue field at $\mathfrak p$ is generated as a ring by all $\sqrt{a_i} \bmod \mathfrak p$, so this field is either $\mathbf F_p$ or $\mathbf F_{p^2}$, and it is $\mathbf F_p$ if and only if all $a_i \bmod p$ are squares in $\mathbf F_p$. The density of primes $p$ such that all $a_i \bmod p$ are squares in $\mathbf F_p$ is $1/d$ where $d$ is the degree $[\mathbf Q(\sqrt{a_1},\ldots,\sqrt{a_n}):\mathbf Q]$ I mentioned earlier (a certain power of $2$).

Any $\mathbf Z$-linear relation $c_1\sqrt{a_1}+\ldots+c_n\sqrt{a_n}=0$ in the ring leads to an $\mathbf F_p$-linear relation $c_1\sqrt{a_1}+\ldots+c_n\sqrt{a_n} \equiv 0 \bmod \mathfrak p$ in the residue field at $\mathfrak p$. This is a good way to carry out the process of turning a relation in characteristic $0$ into a relation in characteristic $p$.

In fact, all ways of picking a square root of each $a_i \bmod p$ in $\mathbf F_{p^2}$ that are consistent with all relations among the numbers $\sqrt{a_1},\ldots,\sqrt{a_n}$ arise from some choice of prime ideal $\mathfrak p$ where $(p) \subset \mathfrak p$. There is a unique ring homomorphism $$ \mathbf Z[x_1,\ldots,x_n]\to \mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}] $$ where $x_i\mapsto \sqrt{a_i}$ for all $i$. Let $I$ be its kernel, an ideal, so we get an induced ring isomorphism $$ \mathbf Z[x_1,\ldots,x_n]/I \to \mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]. $$

The ideal $I$ contains $x_i^2-a_i$ for all $i$, so $I$ contains $(x_1^2-a_1,\ldots,x_n^2-a_n)$, and $I$ could be bigger. Two examples: $\mathbf Z[\sqrt{2},\sqrt{3}] \cong \mathbf Z[x,y]/(x^2-2,y^2-3)$ and $\mathbf Z[\sqrt{2},\sqrt{8}] \cong \mathbf Z[x,y]/(x^2-2,y^2-8,2x-y)$.) The polynomials in $I$ are all polynomials in $x_1,\ldots,x_n$ that vanish when we set $x_i = \sqrt{a_i}$ for all $i$, so $I$ tells us all the algebraic relations among $\sqrt{a_1},\ldots,\sqrt{a_n}$. A set of generators of $I$ is a set of relations among those square roots that explain all other relations among those square roots. In the ideal (ha-ha) situation that $a_1,\ldots,a_n$ are independent modulo squares, $I = (x_1^2-a_1,\ldots,x_n^2-a_n)$ by a counting argument whose details I omit.

Now let's try to work out what the ring homomorphisms $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}] \to \mathbf F_{p^2}$ are. A subtlety is that we may not be able to send each $\sqrt{a_i}$ to either square root of $a_i \bmod p$ in $\mathbf F_{p^2}$ independently because relations among the numbers $\sqrt{a_i}$ might not be preserved among their images. As an example, say we're trying to build a ring homomorphism $\mathbf Z[\sqrt{2},\sqrt{8}] \to\mathbf F_{p^2}$. Since $\sqrt{8} = 2\sqrt{2}$, we have to make sure that the square roots of $2$ and $8$ that we use as target values in $\mathbf F_{p^2}$ have the same relation "$\beta = 2\alpha$". Being careless about which square roots we use $\mathbf F_{p^2}$ might not have this relation hold (perhaps $\beta = -2\alpha$).

This is why it is convenient to use the ring isomorphism $$ \mathbf Z[x_1,\ldots,x_n]/I \to \mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]. $$ The ring homomorphisms $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}] \to \mathbf F_{p^2}$ can be viewed as the ring homomorphisms $\mathbf Z[x_1,\ldots,x_n]/I \to \mathbf F_{p^2}$, which are the same thing as the ring homomorphisms $\varphi : \mathbf Z[x_1,\ldots,x_n] \to \mathbf F_{p^2}$ that are $0$ on $I$. Every ideal in $\mathbf Z[x_1,\ldots,x_n]$ is finitely generated, and when $I = (f_1,\ldots,f_r)$, having $\varphi = 0$ on all of $I$ is the same thing as having $\varphi(f_j) = 0$ for $j = 1,\ldots,r$.

Using generators of the ideal $I$, we can say exactly which choices of square roots of $a_i$ in the finite field $\mathbf F_{p^2}$ occur as images of $\sqrt{a_i}$.

Theorem. Let $I = (f_1,\ldots,f_r)$. Then for each choice of $\alpha_i \in \mathbf F_{p^2}$ such that $\alpha_i^2 = a_i$, there is a ring homomorphism $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}] \to \mathbf F_{p^2}$ such that $\sqrt{a_i} \mapsto \alpha_i$ if and only if $f_j(\alpha_i,\ldots,\alpha_n) = 0$ in $\mathbf F_{p^2}$ for $j=1,\ldots,r$.

Example. When $a_1,\ldots,a_n$ are independent modulo squares, so $I = (x_1^2-a_1,\ldots,x_n^2-a_n)$, every choice of $\alpha_i$ in $\mathbf F_{p^2}$ such that $\alpha_i^2 = a_i$ can be used to define a ring homomorphism $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}] \to \mathbf F_{p^2}$.

Example. We have $\mathbf Z[\sqrt{2},\sqrt{8}]\cong \mathbf Z[x,y]/(x^2-2,y^2-8,2x-y)$, so a choice of $\alpha$ and $\beta$ in $\mathbf F_{p^2}$ such that $\alpha^2 = 2$ and $\beta^2 = 8$ can be used to define a ring homomorphism $\mathbf Z[\sqrt{2},\sqrt{8}] \to \mathbf F_{p^2}$ if and only if $2\alpha = \beta$.

In the general case, once we have a ring homomorphism $$ \mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]\to \mathbf F_{p^2} $$ where $\sqrt{a_i} \mapsto \alpha_i$ for all $i$, its kernel has to be a nonzero prime ideal, say $\mathfrak p$, so we get an induced ring embedding $$ \mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]/\mathfrak p \hookrightarrow \mathbf F_{p^2} $$ with image $\mathbf F_p$ or $\mathbf F_{p^2}$ in which $\sqrt{a_i} \bmod \mathfrak p$ is mapped to $\alpha_i$ for all $i$. This does not just preserve additive relations among all $\sqrt{a_i}$ when going from characteristic zero to characteristic $p$, but all multiplicative relations as well (it is a ring homomorphism).

$\endgroup$
18
  • $\begingroup$ Thanks, but I don't think it answers the question? What I'm asking is, to find a mapping from $\{\sqrt{a_1},\dots,\sqrt{a_n}\}$ into $\operatorname{GF}(p^2)$ such that it preserves certain identities (e.g. if original linear combination is zero, so must be the one after the mapping is applied). Unfortunately the stuff that you mention doesn't seem to be constructive (i.e. it proves that there is some equivalence, but doesn't seem to give it explicitly). $\endgroup$ Commented Nov 24, 2023 at 12:16
  • $\begingroup$ See the three paragraphs I added at the end. Every mapping of the square roots $\sqrt{a_i}$ to $\mathbf F_{p^2}$ that preserves all additive and multiplicative relations among the square roots comes from a choice of prime ideal $\mathfrak p$ containing $p$ in the ring $\mathbf Z[\sqrt{a_1},\ldots,\sqrt{a_n}]$. This is not as concrete as you may wish, but it is a very useful to think about how all the mappings that interest you arise. $\endgroup$
    – KConrad
    Commented Nov 24, 2023 at 15:58
  • $\begingroup$ Thanks for the clarification! Let's say that $p=3$. Consider $a_1 = 2, a_2 =8, a_3 = 18$. Then, $\sqrt{a_1} + \sqrt{a_2}-\sqrt{a_3} = 0$. Now, let's say that $\mathbb F_{9}$ is represented as $\mathbb F_3 / (x^2-2)$. Consider $\alpha_1 = \alpha_2 = x$ and $\alpha_3 = 0$, then $\alpha_k^2 = a_k$ for all $k$, but $\alpha_1 + \alpha_2 - \alpha_3 = 2x \neq 0$ in $\mathbb F_{9}$. Thus, we can't just use any $\alpha_k$ to construct the homomorphism. Is there any way to decide between $\alpha_k$ and $-\alpha_k$ for each $k$, so that the result is, in fact, a homomorphism? $\endgroup$ Commented Nov 24, 2023 at 22:38
  • $\begingroup$ You meant $\mathbf F_3[x]/(x^2-2)$, not $\mathbf F_3/(x^2-2)$. Anyway, reread what I wrote: I did not pick a linear relation first. I picked $\alpha_i$ where $\alpha_i^2 = a_i$ for all $i$ and then got a ring hom $\mathbf Z[\sqrt{2},\sqrt{8},\sqrt{18}] \to \mathbf F_9$ where $\sqrt{a_i} \mapsto \alpha_i$ first. If you want certain relations among $\alpha_i$ to occur, then you have to hunt around for a suitable choice of ring homomorphism. $\endgroup$
    – KConrad
    Commented Nov 24, 2023 at 23:12
  • $\begingroup$ Yes, $\mathbb F_3[x]$, sorry. What I mean is, ring homomorphism should preserve additive relations, right? That is, $f(\sqrt{2}+\sqrt{8}-\sqrt{18}) = f(\sqrt{2})+f(\sqrt{8})-f(\sqrt{18})$. But here we have $\sqrt{2}+\sqrt{8}-\sqrt{18}=0$, while $f(a)+f(b)-f(c)=\alpha_1+\alpha_2-\alpha_3=2x \neq 0$. So, when we map to $\alpha_i$ chosen this way, the resulting map is, in fact, not a homomorphism, it seems? Because it doesn't map $0$ to $0$. I probably missed something, but I can't see what. $\endgroup$ Commented Nov 24, 2023 at 23:20
0
$\begingroup$

@KConrad provided a lot of useful details in his answer that also helped me better understand what's going on here and what I want from the problem exactly. I'd like to use a separate answer to summarize what I find most relevant to this specific question, and also provide a bit more details on the algorithmic part.

In essence, what I was looking for boils down to finding a non-trivial homomorphism $$ f: \mathbb Z\sqrt{a_1}+ \dots+ \mathbb Z\sqrt{a_n} \to \mathbb F_{p^2}. $$ The original question only bothers about preservation of additive expressions (so, like a module homomorphism), so to simplify the answer I won't consider preservation of multiplicative properties here.

It simplifies the situation somewhat, because the rank of $\mathbb Z\sqrt{a_1}+ \dots+ \mathbb Z\sqrt{a_n}$ as a $\mathbb Z$-module is equal to the number of distinct square-free cores of $a_1, \dots, a_n$. In terms of $\mathbb Q^\times / (\mathbb Q^\times)^2$, as I understand, it would mean the size of $\{a_1,\dots, a_n\}$ rather than $\langle a_1, \dots, a_n \rangle$.

In any case, one way to construct such a homomorphism is, for each distinct square-free core $x$ of $a_i$, to pick one of at most $2$ its possible square roots in $\mathbb F_{p^2}$ (any choice should do), and then for each $a_i = y^2 x$ to define $f(\sqrt{a_i}) = y f(\sqrt x)$, then it's possible to define $f$ on other arguments naturally.

Finally, for the algorithmic part of the process, it's worthwhile to note that we do not need to actually find the square-free cores, and thus we do not need to factorize input numbers. This is because $a_i$ and $a_j$ have the same square-free core if and only if $a_i a_j$ is the full square. Then, in each group of $a_i$ that has the same square-free core, we can choose any square root for one element, and then define $$ f(\sqrt{a_j}) = \sqrt{\frac{a_j}{a_i}} f(\sqrt{a_i}), $$ which will be well-defined because $\sqrt{\frac{a_i}{a_j}}$ is rational if $a_i$ and $a_j$ have the same core.

$\endgroup$
7
  • 1
    $\begingroup$ Be careful: consider $\mathbf Z[\sqrt{6},\sqrt{10},\sqrt{15}]$. The numbers 6, 10, and 15 are all squarefree and distinct, but this ring does not have rank $3$ as $\mathbf Z$-module: it is a subring of finite index in the integers of the field $\mathbf Q(\sqrt{6},\sqrt{10},\sqrt{15})$, which is $\mathbf Q(\sqrt{6},\sqrt{10})$ since $6 \cdot 10 = 4 \cdot 15$. This is a field of degree $4$, not $8$, over $\mathbf Q$, and this implies $\mathbf Z[\sqrt{6},\sqrt{10},\sqrt{15}]$ has rank $4$ over $\mathbf Z$ (a $\mathbf Z$-basis is $\{1,\sqrt{6},\sqrt{10},\sqrt{15}\}$). $\endgroup$
    – KConrad
    Commented Nov 25, 2023 at 3:43
  • $\begingroup$ Sorry, I'm not very proficient with the notation. What I meant is literally the module composed of vectors $a \sqrt{6} + b\sqrt{10} + c\sqrt{15}$. I suppose $\mathbb Z[\sqrt{6}, \sqrt{10}, \sqrt{15}]$ is a different object which also has multiplication, but I want to only bother with addition here. Is there some concise notation and name for it? $\endgroup$ Commented Nov 25, 2023 at 10:43
  • $\begingroup$ The brackets $[,]$ denote "ring". So $\mathbf Z[x,y,z]$ is the ring of polynomials in $x,y,z$ with integer coefficients, and the same notation applies with numbers in place of $x,y,z$, e.g., $\mathbf Z[\sqrt{6},\sqrt{10},\sqrt{15}]$ is all polynomial expressions in $\sqrt{6},\sqrt{10},\sqrt{15}$ with integer coefficients. Because they square to integers, we don't need powers of any square root above the 1st power. The $\mathbf Z$-span of $x,y,z$ is ${\mathbf Z}x + {\mathbf Z}y + {\mathbf Z}z$, and likewise with ${\mathbf Z}\sqrt{6} + {\mathbf Z}\sqrt{10} + {\mathbf Z}\sqrt{15}$. $\endgroup$
    – KConrad
    Commented Nov 25, 2023 at 16:43
  • $\begingroup$ As an example, $\mathbf Z[\sqrt{2},\sqrt{3}] = \mathbf Z + \mathbf Z\sqrt{2} + \mathbf Z\sqrt{3} + \mathbf Z\sqrt{6}$ while $\mathbf Z\sqrt{2} + \mathbf Z\sqrt{3}$ is smaller. $\endgroup$
    – KConrad
    Commented Nov 25, 2023 at 16:45
  • $\begingroup$ Ok, thanks! I meant the span in the answer. Amended it to reflect this. $\endgroup$ Commented Nov 25, 2023 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .