When does the function $f(y) = 1 + y + y^2$ show mainly the units in a quadratic number ring? Is a corresponding equation solvable in integers? Motivated by a strange coincidence in polynomial geometry I decided to learn some elementary algebraic number theory recently and armed with "Quadratische Zahlkörper", a recent german introductory text by Franz Lemmermeyer, I tried to understand the following phenomenon, which I had found empirically:
Let $f(y) = 1 + y + y^2$, $x = a + \sqrt{m} \, b$ be an element of the maximal order in $\mathbb{Q(\sqrt{m})}$, so $m \in \mathbb{Z\backslash\{0,1}\}$ is squarefree, $N(x) = a^2 - m b^2$ is the algebraic norm of $x$ and $D(x) = 4mb^2$ the discriminant of $x$, while there are the usual restrictions on $a$ and $b$ according to the residue class of $m \mod 4$.Then:
Assertion:
$N(f(x^2))$ is a square integer, if and only if $x$ is a unit of the maximal order or if $ab = 0$.
This result is certainly useless, if one wants to find units, but I (with no clue in number theory or algebraic geometry) found it so peculiar, that I started to call it "disuseful" for fun. Before giving the things I managed to find/prove, I will ask the things, which would be helpful to me:

*

*Perspective: This/similar phenomena will have been discovered before and I would appreciate appropriate references, preferably textbooks to point me to other investigations of this type.

*Help to discuss the solutions to
$$ K^2 = (4mb^2 - 1)^2 + l(a^2 - mb^2 + 1)$$
in integers only, see the end of the question; doing so will give a necessary condition to find valid solutions of $N(f(x^2)) = K^2$, if there are any more.

Results:
An elementary computation shows $$N(f(x^2)) = N(f(x))N(f(-x)) = (f(N(x)) + D(x))^2 - D(x)(N(x) - 1)^2 \, ,$$
from which one infers or directly computes:
$$a = 0 \ \Rightarrow \ N(f(x^2)) = (f(-N(x)))^2 \, ,$$
$$ b = 0 \ \Rightarrow \ N(f(x^2)) = (f(N(x)))^2 \, ,$$
$$N(x) = 1 \ \Rightarrow \ N(f(x^2)) = (D(x) + 3)^2 \, ,$$
$$N(x) = -1 \ \Rightarrow \ N(f(x^2)) = (D(x) - 1)^2 \, .$$
Looking at a number of examples corresponding to the above and not corresponding to them for positive as well as negative values of $m$ and various residue classes, the observations were always confirmed, but I did not try a systematic brute force search up to now. Indeed, everything up to this point is elementary algebraic manipulation only.
Proof idea:
Let $K$ be a hypothetical strictly positive integer fulfilling
$$K^2 \ = \ (f(N(x)) + D(x))^2 - D(x)(N(x) - 1)^2 \, ,$$
then the case $f(N(x)) + D(x) = 0$ leads to squares if and only if $m \, = \, -1$. For $a \, \neq \, 0; \, m \, = \, -1$ we obtain the equation
$$(2b^2 - 1)^2 \ = \ n^2 + (n+1)^2 \quad (\star) $$ from this. Applying the general parametrization for Pythagorean Triples
$$ (c(u^2 - v^2)^2 \, + \, (2cuv)^2 \ = \ (c(u^2 + v^2))^2 \, ,$$
where $c,u,v$ are nonvanishing integers, and $u, v$ can be chosen with opposite parity, we obtain the Pell equation $s^2 - 2t^2 \ = \ \pm 1$ in integers from the right hand side of $(\star)$, showing $c \, = \, 1$, which implies, that $b$ cannot be even, as $2b^2 - 1$ must then equal $u^2 + v^2$. Therefore $(\star)$ leads to
$$ 2*b^2(b^2 - 1) \ = \ n(n + 1) \, ,$$
which has the integer solution $n \, = \, b^2 \, = \, 3$, but $b$ is then no integer, and further developments show there is no integer solution for any odd integer $b$.
To approach the general case, we use the geometric sum formular on $f(N(x))$ and some hopefully correct manipulations to arrive at
$$(N(x) - 1)^2 \left( K^2 - (D(x) - 1)^2 - D(x)(N(x) + 1)(N(x) + 3) \right) \ = \ N(x) \ \left( (N(x)^5 - 2N(x)^2) - (N(x) - 2) \right) \, ( \star \star).$$
As $x$ is not a unit, we can divide by $(N(x) - 1)^2$ to get
$$ K^2 - (D(x) - 1)^2 - D(x)(N(x) + 1)(N(x) + 3) \ = \ N(x)(N(x) + 1)(N(x)^2 + N(x) + 2)\, ,$$
which shows, that $N(x) + 1$ must divide $K^2 - (D(x) - 1)^2$. This leads to the equation in the beginning, where $l$ is an integer, which constitutes a necessary condition for solutions different from those already found to exist. If the discriminant were allowed to be one, $l$ could be chosen to be a square multiple of $(N(x) + 1)$. This not being the case, I tried to investigate, whether the parametrization of the Pythagorean triples allows a solution; this seems impossible, because $m$ is squarefree and $u^2 + 1$ is not a square, but at the moment I am stuck.
I have already checked, whether the sides of the equation $(\star \star)$ agree as polynomials, given an appropriate choice of $K^2$, they do not, but as far as I am aware, this would constitute only a sufficient, not a necessary condition for an integer solution, and some might still be hiding there.
 A: There are at least some counterexamples, see equation $(\circ \circ)$ at the bottom and the following discussion.
First I will adress the diophantine equation of the question, though it turned out not to be necessary for the solution of the general problem proposed below, because it is an interesting variant of the solution of the equation for Pythagorean tripels.
I managed to find one particular solution relevant to the original problem and an abundance of solutions for the diophantine equation as such in the case $m \ = \ -1$. In this particular case only, $(4mb^2 - 1)^2$ may be regarded as the square of a sum of an even and an odd square, so it can be expressed as the side of the well-known parametrization equation of Pythagorean triples, which contains only one square. By this Pythagorean parametrization, we can then regard it as the sum of two new squares and write down a solution for the diophantine equation as such:
$$ (u + v)^2 = u^2 + v^2 + 2uv \, ,$$
where $u$, $v$ are integers, where one, say $u$, is even and the other, therefore $v$, is odd and $u,v$ may be multiplied each by another arbitrary integer to obtain yet more solutions. To solve our original problem, we have to account for our special circumstances, which forces the following choices, where we integrate $m = -1$ from the start:
$$ u^2 + v^2 = (1 + 4b^2) \, , \ v = (a^2 + b^2 + 1)^2 \, , \ l = 2u \, ,$$
which in turn lead to a consistency condition for $u$ expressible as the following equation:
$$u^2 \ = \ -a^4 - 2a^2 - (2a^2 - 6)b^2 + 15b^4 \, .$$
The particular solution I found to this one is $a = b = 1$, leading to $u = 4$, which gives $49 = 25 + 24$ as solution to our diophantine equation according to the given parametrization. This solution does not solve our original equation though, so it does not lead to $N(f(x^2))$ being a square. After all, the condition was indeed only necessary, not sufficient. I left the matter there to look for a different approach, which follows.
From now on $N(x) \, = \, N$ and $D(x) \, = \, D$ will be used, because there is no ambiguity in their use below and it improves readability in the long equations.
If we add $(N + 1)(N + 3)$ to the last equation in the question and rearrange, converting some of the terms along the way and putting everything except for $K^2$ on the right hand side, we get:
$$K^2 \ = \ (D-1)^2 \, + \, (N + 3)(D - 1)(N + 1) \, + \, (N^2 + 3)(N + 1)^2 \, . $$
The right hand side is now a not quite quadratic form in $D - 1$ and $N + 1$, which shows how to proceed. We use $N + 3 \, = \, N + 1 + 2$ and $N^2 + 3 = N^2 + 2 + 1$ to rearrange again and obtain
$$K^2 \ = \ (D+N)^2 \, + \, (N^2 + D + 1)(N + 1)^2 \, . $$
We can now turn the right hand side into a square by adding $(D + 4N)(N + 1)^2$, giving
$$K^2 \, + \, (D + 4N)(N + 1)^2 \ = \ (D + N + (N + 1)^2)^2 \, . \ (\circ)$$
At this point, it is expedient to introduce the trace $T(x) \, = \, T \, = \, 2a$ of the algebraic number, as this shows, that we have two squares on the left and shows the special position of the conditions leading to squares from the question. We have $T^2 \, = \, D + 4N$ by the general definitions of norm, trace and discriminant of numbers from a quadratic field, so we get
$$K^2 \, + \, T^2(N + 1)^2 \ = \ (D + (T^2 - D)/4 + (N + 1)^2)^2 \, . \ (\circ \circ) $$
If $T \, = \, 0 \, = \, a$ or $N \, = \, -1$, we obviously always get a true equation in integers, and the case $D \, = \, 0 \, = \, b$ is dealt with affirmatively by putting $c \, = \, 1$, $u \, = \, T/2$ and $v \, = \, N + 1$ in the parametrization of the Pythagorean Triples.
When fitting the case $N \, = \, 1$ into the Pythagorean framework, I found a very small amount of counterexamples, but there may be more under other circumstances:
For $N \, = \, 1$ the choice of $c \, = \, 1, \ u \, = \, a(N + 1), \ v \, = \, 1$ is appropriate to fulfill equation $(\circ \circ)$, in this case the following equation has to be true:
$$ 1 \, + \, a^2 (N+1)^2 \ = \ 3mb^2 \, + \, a^2 \, + \, (N+1)^2 \, , $$
where the right hand side is just one of many ways to write the right hand side of $(\circ \circ)$. Using $mb^2 \, = \, a^2 - N$, we can show, that this is equivalent to
$$ (a^2 - 1)(N+3)(N-1) \ = \ -3(N-1) \, .$$
Here it is obvious, that the equation is always fulfilled for $N \, = \, 1$, but there are some additional solutions:  Dividing by $N-1$, we find $N \, = \, -4$ and $a^2 \, = \, 4$ for possible integer solutions, which leads to $8 \, = \, mb^2$. As $m$ is squarefree, this equation has the solutions $m \, = \, 2 \, = \, |b|$.
We therefore find, that $m \, = \, |a| \, = \, |b| \, = \, 2$ leads to the solution $K \, = \, 35$ of our original problem, corresponding to the Pythagorean Triple $35^2 + 12^2 \, = \, 37^2$.
As there is potentially more flexibility in the choice of $c, u, v$, there may still be more counterexamples. Anyway, I have found a sufficiently satisfactory answer for my original question.
