Integer solutions of $3a^2 - 2a - 1 = n^2$ I've got an equation $3a^2 - 2a - 1 = n^2$, where $a,n \in \mathbb{N}$.
I put it in Wolfram Alpha and besides everything else it gives integer solution: see here.
For another equation (say, $3a^2 - 2a - 2 = n^2$, where $a,n \in \mathbb{N}$) Wolfram Alpha does not provide integer solutions: here.
Could you please tell me:


*

*How does Wolfram Alpha determine existence of the integer solutions?

*How does it find them?

*What should I learn to be able to do the same with a pencil and a piece of paper (if possible)?


Thanks in advance!

Lagrange showed how to reduce a general binary quadratic Diophatine equation to Pell form.
$$\rm a\ x^2 + b\ xy + c\ y^2 + d\ x + e\ y + f\ =\ 0 $$
reduces to a Pell equation as follows: put $\rm\ D = b^2-4ac,\ E = bd-2ae,\ F = d^2-4af\:.\ $ Then
$$\rm  D\ Y^2\ =\ (D\ y + E)^2 + D\ F - E^2,\quad\quad Y\ =\ 2ax + by + d $$
Therefore if we put $\rm\quad\ \ X\: =\: D\ y + E,\quad\ \ N\: =\: E^2 - D\ F\quad\ \ $ we obtain the Pell equation
$$\rm X^2 - D\ Y^2\ =\ N $$
Now you can apply standard techniques for solving Pell equations. They are a bit too complex to describe here. However, you can obtain complete step-by-step descriptions of the solution to any Pell equation using Dario Alpern's Quadratic two integer variable equation solver.  For some  recent optimizations of Lagrange's algorithm see this paper H. C. Williams et al. A new look at an old equation.
