# Form of solutions Pell's equation

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.

1. 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.

2. 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.

The equation $$Y + X\sqrt D = (y + x\sqrt D)(y_n - x_n\sqrt D)$$ is used to define $X$ and $Y$. As you showed, $Y$ is the real part of the right side after you multiply it out, and $X$ is the coefficient of $\sqrt D$.
Now, take the conjugate (or inverse) of both sides of that equation to get $$Y - X\sqrt D = (y - x\sqrt D)(y_n + x_n\sqrt D)$$ Next, multiply those two equations, and use the fact that $x,y$ and $x_n,y_n$ are solutions to Pell's equation to get \begin{align} Y^2 - DX^2 & = (y^2 - Dx^2)(y_n^2 - Dx_n^2)\\ & = (1)(1)\\ & = 1. \end{align} Your method is another, but more tedious, way to get the same result. Your expression for $Y^2 - DX^2$ should factor as $(y^2 - Dx^2)(y_n^2 - Dx_n^2)$. Then you can proceed as above.