How to find all rational solutions of $\ x^2 + 3y^2 = 7 $?
I knew that for $ x^2 + y^2 = 1$ the x and y can be expressed by introducing one more variable where $\ m=y/(x+1) $, then $\ x= 2m/(1+m^2) $ and $\ y= (1-m^2)/(1+m^2) $. What about $\ x^2 + 3y^2 = 7 $, should I divide the equation by 7 in order to get the 1 at the right hand side ? Then how to deal with the $\ 3y^2 $ ? Thank you!
The key here is to understand where the substitution $$m = \frac{y}{x + 1}$$ comes from. Geometrically, this variable represents the slope of the line between a point $(x, y)$ and the point $(-1, 0)$. What you are then doing is considering a rational slope $m$, taking the line $L$ through $(-1,0)$ of slope $m$, and solving for the second intersection point of this line with the conic $x^2+y^2=1$ (the first intersection point being $(-1,0)$).
This same approach works for any conic, as long as you have a single rational point on the conic to play the role of $(-1,0)$. In the case of $x^2+3y^2=7$, for instance, you could take $(2,1)$ as your initial point. So then you would define $$m = \frac{y - 1}{x - 2}$$ and solve for $(x,y)$ as the second point where the line $L$ through $(2,1)$ of slope $m$ intersects the conic $x^2+3y^2=7$.
Using the method of pg 7 of this paper on this related equation $$x^2+3y^2=7z^2 \quad \text{with initial solution} \quad (x,y,z)=(2,1,1)$$
A line $y=t(x-2)+1$, which will cut through the ellipse $x^2 + 3y^2 = 7$ at rational points if $t$ is rational.... when substituted into the ellipse yields:
$$\begin{align} x^2+3\left[t(x-2)+1\right]^2&=7 \\ x^2+3\left[t^2(x^2-4x+4)+2t(x-2)+1\right]&=7 \\ (1+3t^2)x^2+(-12t^2+6t)x+(12-12t+3-7)&=0 \\ \text{vieta: the two roots,} \quad x_1, x_2 \quad \text{are such that} \quad -(x_1+x_2)&=\frac{-12t^2+6t}{1+3t^2} \\ \text{since} \quad x_1=2, \quad \text{we have} \quad x_2(t)=\frac{12t^2-6t}{1+3t^2}-2 &=\frac{6t^2-6t-2}{1+3t^2} \\ \text{substituting this} \quad x(t) \quad \text {into the line:} \quad y&=t\left(\frac{6t^2-6t-2}{1+3t^2}-2\right)+1 \\ y(t)=t\left(\frac{-6t-4}{1+3t^2}\right) + \frac{1+3t^2}{1+3t^2}&=\frac{-3t^2-4t+1}{1+3t^2} \end{align}$$
Letting $y(t)\to |y(t)|$, Solution set with one parameter:
$$\begin{cases} x(t)&=\frac{6t^2-6t-2}{1+3t^2} \\ y(t)&=\frac{3t^2+4t-1}{1+3t^2} \end{cases}$$
$t$ was rational, so let $t=\frac{m}{n}$
Solution set now with two parameters: $$\begin{align} x(m,n)&=\frac{6m^2-6mn-2n^2}{n^2+3m^2} \\ y(m,n)&=\frac{3m^2+4mn-n^2}{n^2+3m^2} \end{align}$$
This is not (yet) an answer, but an extended comment, just to have some numerical solutions to crosscheck given analytic solutions in other answers and comments. I document only solutions here with $\gcd(x,y,z)=1$.
Here the third variable $z$ stems from rewriting
$ x^2+3 y^2 = 7 $ where $ (x,y) \in \mathbb Q$ by
$ (x/z)^2+3 (y/z)^2 = 7 $ and then
$$ x^2+3 y^2 = 7z^2 \qquad (x,y) \in\mathbb Z, z \in \mathbb N^+ \tag 1 $$
Let $M= \begin{bmatrix} 8&0&3\\0&1&0\\21&0&8 \end{bmatrix}$ a transfer-matrix to recurse from one solution to another with constant $y$.
$\qquad \\ \\$
Beginning at $A_{1,0}=[2,1,1]=[x,y,z]$ we get the infinite set of solutions
$A_{1,0} \cdot M^i =A_{1,i} \qquad \qquad $ for i=-5..5
i x y z
-------------------------------
... ... ... ...
-5 -331973 1 125474
-4 -20830 1 7873
-3 -1307 1 494
-2 -82 1 31
-1 -5 1 2
0 2 1 1
1 37 1 14
2 590 1 223
3 9403 1 3554
4 149858 1 56641
5 2388325 1 902702
... ... ... ...
Sidenote: as you might observe, we have also another recursion inside the columns of $x_i$ and $z_i$ : $$x_{2+i}=16 x_{1+i} - 1 x_i$$
Now let's define a second matrix $Q= \begin{bmatrix} 4&0&-1\\0&3&0\\-7&0&4 \end{bmatrix} $
Using this matrix allows to shift from the set of solutions $A_{k,i}$ to $A_{3k,i}$ So $A_{1,0} \cdot Q = A_{3,0}$ which is numerically $[2,1,1] \cdot Q = [1,3,2]$ and
$A_{3,0} \cdot M^i =A_{3,i} \qquad \qquad $ for i=-5..5
i x y z
-------------------------------
... ... ... ...
-5 -2206210 3 833869
-4 -138431 3 52322
-3 -8686 3 3283
-2 -545 3 206
-1 -34 3 13
0 1 3 2
1 50 3 19
2 799 3 302
3 12734 3 4813
4 202945 3 76706
5 3234386 3 1222483
This can analoguously be done with $y=9$ by ***$A_{3,0}\cdot Q=A_{9,0}$*** and the set of solutions $A_{9,i}=A_{9,i} \cdot M^i$ and so on to $y=3^m$. It might be nice to see a more complicate solution by one single matrix-equation: $$A_{81,3}= [2,1,1]\cdot Q^4 \cdot M^3 = [31627, 81, 11954]$$
I've not yet a method to get systematically all solutions; for instance there is a full tree of slutions with $y=19,3\cdot19,3^2\cdot19,3^3\cdot19,...$ beginning at $A_{19,0}=[10,19,13]$ using the same matrix-multiplications to define the full tree, then for $y=29 \cdot 3^k$ , $y=31 \cdot 3^k$ and so on.
General remark: because all $x,y,z$ occur as squares in the basic equation, we have always $\pm x$,$\pm y$ and $\pm z$ as valid solutions; however the matrix-formulae require meaningful attributing of signs.