Diophantine equation in two variables. How do I find the integer solutions for $a,b$ in $$C=a+b+\sqrt{2ab+T}$$
where $C$ and $T$ are know values?
 A: I'll assume $C$ and $T$ are integers. Notice $$\begin{align}
& C = a + b + \sqrt{2ab+T}\tag{*1}\\
\implies & (C - (a+b))^2 = 2ab+T \tag{*2}\\
\iff & C^2 + a^2 + b^2 - 2C(a+b) = T\\
\iff & (a-C)^2 + (b-C)^2 = T+C^2
\end{align}$$
The problem is more or less equivalent to whether $T+C^2$ can be expressed as a sum of
two squares. It is known that this is possible if and only if in the factorization of $T+C^2$ into product of primes, those primes of the form $4k+3$ appear in pairs.
Let's say we have factorized $T + C^2$ as
$$2^\rho \prod_{\mu} p_\mu^{e_\mu} \prod_{\nu} q_\nu^{2f_\nu}$$
where $p_\mu$ are primes of the form $4k+1$ and $q_\nu$ are primes of the form $4k+3$.
Foreach $p_\mu$ of the from $4k+1$, we can always find integers $\alpha_\mu$, $\beta_\mu$ such that $p_\mu = \alpha_\mu^2 + \beta_\mu^2$. For any $0 \le g_\mu \le e_\mu$, if we defined $\tilde{a}$, $\tilde{b}$ by following relation:
$$\tilde{a} + \tilde{b}i = (1+i)^\rho \prod_{\mu} \left[
(\alpha_\mu + \beta_\mu i)^{g_\mu} 
(\alpha_\mu - \beta_\mu i)^{e_\mu-g_\mu} \right]
\prod_{\nu} q_\nu^{f_\nu}$$
We will have  $\tilde{a}^2 + \tilde{b}^2 = T+C^2$ and  hence
$(a,b) = (C \pm |\tilde{a}|, C \pm |\tilde{b}| )$ will be a solution of $(*2)$.
For any pairs of $(a,b)$ generated in this manner, if the pair also satisfy $C \ge a + b$, then the pair will be a solution for $(*1)$ too.
For more infos about the assertions appeared here. A good starting point are the wiki pages for Gaussian integer and the Proof of Fermat's theorem of sum of two squares.
