What fields between the rationals and the reals allow to define the usual 2D distance?

Consider a field $K$, let's say $K \subseteq \mathbb R$. We can consider the 'plane' $K \times K$. I am wondering in which cases the distance function $d: K \times K \to \mathbb R$, defined as is normal by $d(x, y) = \sqrt{x^2 + y^2}$, takes values in $K$.

Certainly this is not true for $\mathbb Q$: we have $d(1, 1) = \sqrt{2} \notin \mathbb Q$. If we take any $K$ which is closed under taking square roots of non-negative numbers, then certainly $d$ will take values in $K$.

However, a priori it might still be true that $a \in K$ positive has no square root, yet this does not provide an obstruction because there is no way to write $a = x^2 + y^2$. Thus I am wondering:

Are there fields $K \subseteq \mathbb R$ which do not have all square roots of positive numbers, yet are closed under $d$?


Consider the tower of fields

$K_0:=\mathbb{Q}$,

$K_{i+1}:=K_i(\sqrt{x^2+y^2}| x,y\in K_i)$,

$K:=\bigcup_i K_i$.

Then $K$ is closed under $d$ and contains $1+\sqrt 5$ but not $\sqrt{1+\sqrt 5}$, as I have found by following the Pythagorean fields Wikipedia link given by @Dirk in his answer: If $\sqrt{1+\sqrt 5}$ were in $K$ then $1+\sqrt 5$ would be a sum of two squares in some extension $K_i$, and then it would be so in an extension of $\mathbb{Q}(\sqrt 5)$, which implies that it is a sum of squares in $\mathbb{Q}(\sqrt 5)$, which is impossible because that would entail that $1-\sqrt 5$, which is negative, is also a sum of squares in $\mathbb{Q}(\sqrt 5)$.

The details can be found in Chapter 5 of the book Geometric constructions by Martin. The relevant results are Theorems 5.10-5.15.

Similarly, $\sqrt 2\in K$ but $\sqrt[4]2\not\in K$, and more in general, this is true for any positive number which is not a sum of squares in the first extension in which it appears.

Geometrically, numbers in $K$ correspond to constructible points by ruler and dividers. Hence $\sqrt[4]2$ is constructible by rule and compass but not by rule and dividers.


edit: Look what I found: Wiki


The field $$\mathbb{Q}(\sqrt{p} \mid p \in \mathbb{P})$$ might be a good candidate.
At least, all fields closed under $d$ must contain this field.