Example 2 Find all solutions to the indeterminate equations
$$x^{2}-8 y^{2}=-1$$

and
$$x^{2}-8 y^{2}=1$$
From Example 4 in §3, we know that $\sqrt{8}=\langle 2, \overline{1,4}\rangle$. The period is 2. Therefore, by Theorem 1 and Theorem 3, the indeterminate equation (21) has no solution, and the smallest positive solution of the indeterminate equation (22) is $x=h_{1}, y=k_{1}$. It is easy to find that
$$h_{1} / k_{1}=\langle 2,1\rangle=3 / 1$$

Thus, by Corollary 4, the complete solution of the indeterminate equation (22) is
$$x+y \sqrt{8}= \pm(3 \pm \sqrt{8})^{j}, \quad j=0,1,2,3, \cdots$$

When $d$ is relatively small or a special number, we can find the smallest positive solution of
$$x^{2}-d y^{2}=-1 \quad \text { or } x^{2}-d y^{2}=1$$
by trying $y=1,2, \cdots$ one by one, instead of finding the periodic continued fraction of $\sqrt{d}$. From the above discussion, when the first solution found is the smallest positive solution of $x^{2}-d y^{2}=-1$, we can find all solutions of these two equations according to Corollary 4 (ii); when it is the smallest positive solution of $x^{2}-d y^{2}=1$, $x^{2}-d y^{2}=-1$ has no solution, and we can find all solutions of $x^{2}-d y^{2}=1$ according to Corollary 4 (i). For example, in the case of Example 2, when $y=1$, $x=3, y=1$ is a solution of the indeterminate equation (22), so the indeterminate equation (21) has no solution. This immediately gives us all solutions of the indeterminate equation (22). Here is another example.