TITLE: For a recursion based on $x+y+z+2\sqrt{xy+yz+zx},$ does what happens in $\mathbb Z\left[\sqrt n\right]$ stay in $\mathbb Z\left[\sqrt n\right]$?
QUESTION [7 upvotes]: This problem has a geometric origin which I'll outline below, but I believe the concepts and explanation are algebraic.
Given a function on triples
$$K((x,y,z))=x+y+z+2\sqrt{xy+yz+zx}$$
we build a general recursion as follows.

Start with an integer triple $X=(a,b,c)$, and a set $S=\{a,b,c\}$.

Compute $k=K(X)$ and add $k$ to $S$.  Writing $X$ as $(X_0,X_1,X_2)$, repeat step 2 for the triples $X=(k,X_1,X_2),(X_0,k,X_2),(X_0,X_1,k)$ respectively.


In general, the members of $S$ will contain nested radicals.  For example, if we start with the triple $(1,2,3)$ and use a restricted recursion  $x_{n+1}=K((1,2,x_n)),x_1=3$ we get
$$
S'=\left\{3,6+2 \sqrt{11},9+2 \sqrt{11}+2 \sqrt{2+3 \left(6+2 \sqrt{11}\right)},\\12+2
   \sqrt{11}+2 \sqrt{2+3 \left(6+2 \sqrt{11}\right)}+2 \sqrt{2+3 \left(9+2
   \sqrt{11}+2 \sqrt{2+3 \left(6+2 \sqrt{11}\right)}\right)},\dots \right\} 
$$
However, Mathematica is able to denest these to
$$
S'=\left\{3,6+2 \sqrt{11},15+4 \sqrt{11},30+6 \sqrt{11},\dots\right\} 
$$
suggesting the conjectures that

starting with initial triple $(1,2,3)$,  $S'\subset S\subset\mathbb Z[\sqrt {11}]$
starting with integer triple $(a,b,c)$, $S\subset \mathbb Z[\sqrt n]$, where $n=ab+bc+ca.$


Question: is the latter conjecture $S\subset \mathbb Z[\sqrt n]$ true, and if so why?
Bonus question: is there some characterization or invariant of the triples generated in the general recursion?

I've done some hand and computer calculations to understand why the radicals denest in particular cases, but I'm guessing that if the conjecture is true it will be "obvious" to someone more versed in this area.
Some background and observations:

This problem originates in playing with the construction of Apollonian gaskets and the function $K()$ comes from a theorem of Descartes concerning the curvatures of 4 mutually tangent circles.
In the case that $n=ab+bc+ca$ is a square, then all the numbers generated will be integers. And this leads to integral Apollonian circle packings.  But I have not seen any discussions of the case when curvatures are in some $\mathbb Z[\sqrt n]$.
see also this demo

REPLY [2 votes]: this is "Vieta Jumping" when using the original four variables.
If you have a quadruple $(x,y,z,w) $  in a quadratic number field that satisfies
$$ x^2 + y^2 + z^2 + w^2 - 2(xy+xz+xw +yz+yw+zw) = 0, $$
a revised quadruple can be found merely by jumping one of the entries, as
$$ (2y+2z+2w-x, y, z,w), $$ or
$$ (x, 2x+2z+2w -y, z,w), $$ or
$$ (x, y,2x+2y+2w -z,w), $$ or
$$ (x, y, z, 2x+2y+2z-w). $$
Note that the jumps do not expand the ring at all.
To work out the four jumps from a quadruple $(x,y,z,w),$  it saves space and time to write $s = 2(x+y+z+w)$ so that the four neighbors are $(s-3x,y,z,w)\; \; , \; \; $ $(x,s-3y,z,w)\; \; , \; \; $ $(s,y,s-3z,w)\; \; , \; \; $ $(s,y,z,s-3w)\; \; , \; \; $
You start with $$  (1,2,3, 6 + 2 \sqrt{11}  )$$
gives my $s= 24+4 \sqrt{11}.$
The four neighbors are  $  (21 + 4\sqrt{11},2,3, 6 + 2 \sqrt{11}  ) \; , \; \; \; $ $  (1,18 + 4 \sqrt{11},3, 6 + 2 \sqrt{11}  ) \; , \; \; \;$
$  (1,2,15+4 \sqrt{11}, 6 + 2 \sqrt{11}  ) \; \; , \; \; $ $  (1,2,3, 6 - 2 \sqrt{11}  )$
Let's see, an indefinite quadratic form has an infinite automorphism group, unless very restricted (binary, square discriminant). It is just when the coefficient of every $x_j^2$ is exactly $1$ that we get the very simple jumping behavior, which allows changing one coordinate at a time.