I'm studying a proof regarding Pell's equation. It has the form $y^2 - Dx^2 = 1$ with $D \in \mathbb{N}$. Namely that it has an infinite number of solutions if $D$ is not a perfect square. I already know the part where they deduce that there are an infinite number of solutions. Let $(x,y) = (U,T)$ be a solution, where $U>0$, $T>0$, and $U$ is the smallest possible value of $x$. I have a couple of questions about this.
The text says that every solution $(x_n,y_n) \in \mathbb{Z}^2$ is given by $$ y_n + x_n \sqrt{D} = (T+U\sqrt{D})^n,\qquad y_n - x_n \sqrt{D} = (T_U\sqrt{d})^N. $$ Supposes that there is a solution $(x,y) \in \mathbb{Z}^2$ that is not of this form. Then it says there exist a positive integer $n$ such that $$(T+U\sqrt{D})^n < y + x\sqrt{D} < (T+U\sqrt{D})^N.$$ Then by multiplying everything with $y_n - x_n\sqrt{D}$ we get $$ 1 < (y+x\sqrt{D})(y_n - x_n\sqrt{D}) < T + U\sqrt{D}. $$ The proof now says that we can write $$ (y + x\sqrt{D})(y_n-x_n\sqrt{D}) = Y + X\sqrt{D}. $$ This is where I'm confused. He says that $Y^2 - DX^2 = 1$ How does he define $X$ and $Y$? If I multply everything I get $$ (y + x\sqrt{D})(y_n-x_n\sqrt{D}) = y\cdot y_n - y\cdot x_n\sqrt{D} + x\sqrt{D}\cdot y_n - x\cdot x_n D= (y\cdot y_n - x\cdot x_n D) + \sqrt{D}(x\cdot y_n - y\cdot x_n), $$ but if I try $X = y\cdot y_n - x\cdot x_n D$ and $Y = x\cdot y_n - y\cdot x_n$ as a solution, I get stuck (omitting the details): $$ Y^2 - DX^2 = (...) = D[Dx^2x_n^2 + x_n^2Y^2 + x^2y_n^2]. $$ I don't see how I can simplify this even further, because it's suppose to equal $1$. I'm not sure if this is the right way of defining $X$ and $Y$, but it seems to me that this is the only logical definition. If I take the $x\cdot x_n D$ term to the definition of $Y$, I get a non-integer solution.
Has Pell's equation been of any use in other field of mathematics, or in real life? I can't seem to find something where it was useful, except maybe for the solution of Archimedes' cattle problem. Which by the way, was already solved at that time without Pell's equation.