For which values of $m$ and $n$ is the probability $P_{(A,A)} = 0.5$? Given are the classes $A$ and $B$.
Suppose there are $n$ instances from class $A$ and $m$ instances from class $B$.
Let $X$ be all instances. Thus, $X=\{~\{a\}_n, \{b\}_m~\}$.
I denote a pair $p$ as a combination of two instances $(i, j$) from $X$, for which $i \neq j$. Thus, pair $(i, j)$ is the same pair as $(j, i)$.
Let $P$ be all possible pairs $p$. Thus $|P| = \frac{|X|(|X|-1)}{2}$.
Let $P_{(A,B)}$ be the probability of a pair $p = (i, j)$ with $i$ of class $A$ and $j$ of class $B$ in $P$. (In other words, the number of pairs from class $A$ and $B$ over $|P|$.)
Question 1: For which values of $m$ and $n$ is the probability of $P_{(A,A)} =0.5$? A solution is $n=3, m=1$, but what is the next possible solution?
Question 2: What is a formula to compute all possible combinations?

Example 1:
Suppose you have three pingpong-balls. Two are orange (class $A$), one is white (class $B$).
Then $X = \{o_1, o_2, w_1\}$.
And $P = \{(o_1, o_2), (o_1, w_1), (o_2, w_1)\}$.
$P_{(A, A)} = \frac{|\{(o_1, o_2)\}|}{|P|} = \frac{1}{3}$.

Example 2:
Suppose you have four pingpong-balls. Three are orange (class $A$), one is white (class $B$).
Then $X = \{o_1, o_2, o_3, w_1\}$.
And $P = \{(o_1, o_2), (o_1, o_3), (o_1, w_1), (o_2, o_3), (o_2, w_1), (o_3, w_1)\}$.
$P_{(A, A)} = \frac{|\{(o_1, o_2), (o_1, o_3), (o_2, o_3)\}|}{|P|} = \frac{3}{6} = 0.5$.
 A: The question, in effect, asks for all possible positive integer pairs $(m, n)$ with$$
\frac{n(n - 1)}{(m + n)(m + n - 1)} = \frac{1}{2}. \tag{1}
$$
Denote $l = n - m$. After some manipulation, (1) becomes$$
(2l - 1)^2 - 8m^2 = 1. \tag{2}
$$
This is a Pell's equation. Because the fundamental solution of $x^2 - 8y^2 = 1$ is $(x_1, y_1) = (3, 1)$, by the theory of Pell's equation, solutions to $x^2 - 8y^2 = 1$ have the following recurrence relation:\begin{align*}
x_{k + 2} &= 6x_{k + 1} - x_k,\\
y_{k + 2} &= 6y_{k + 1} - y_k,
\end{align*}
and the initial conditions are $x_0 = 1$, $x_1 = 3$ and $y_0 = 0$, $y_1 = 1$. Thus the solutions to $x^2 - 8y^2 = 1$ are\begin{align*}
x_k &= \frac{1}{2} ((3 + 2\sqrt{2})^k + (3 - 2\sqrt{2})^k),\\
y_k &= \frac{1}{4\sqrt{2}} ((3 + 2\sqrt{2})^k - (3 - 2\sqrt{2})^k).
\end{align*}
Note that for every $k$, $x_k^2 = 8y_k^2 + 1$ is an odd integer, so $x_k$ is an odd integer. Therefore, all solutions to (1) are\begin{align*}
&\mathrel{\phantom{=}} (m, n) = \left(y_k, \frac{1}{2} (x_k + 1) + y_k\right)\\
&= \left(\frac{1}{4\sqrt{2}} ((3 + 2\sqrt{2})^k - (3 - 2\sqrt{2})^k), \frac{1 + \sqrt{2}}{4\sqrt{2}} (3 + 2\sqrt{2})^k - \frac{1 - \sqrt{2}}{4\sqrt{2}} (3 - 2\sqrt{2})^k + \frac{1}{2}\right)\\
&= \left(\frac{1}{4\sqrt{2}} ((1 + \sqrt{2})^{2k} - (1 - \sqrt{2})^{2k}), \frac{1}{4\sqrt{2}} ((1 + \sqrt{2})^{2k + 1} - (1 - \sqrt{2})^{2k + 1}) + \frac{1}{2}\right). \quad k \in \mathbb{N_+}
\end{align*}
A: The total number of pairs of objects from $A$ is $\frac{|A|(|A|-1)}{2} = \frac{n(n-1)}{2}$
The total number of pairs of objects is $\frac{|P|(|P|-1)}{2} = \frac{(n+m)(n+m-1)}{2}$
So for the probability that the pair is from $A$ to be $\frac{1}{2}$, we require $\frac{\frac{n(n-1)}{2}}{\frac{(n+m)(n+m-1)}{2}} = \frac{1}{2}$, i.e., $2n(n-1) = (n+m)(n+m-1)$
