Diophantine equations problem/exercise 3 Find all the pythagorean tripples (x,y,z) with x=40. Well I started with the known formulas for the pythagorean tripples but got me nowhere. Or I was not able continue the thought process required. I do not have a lot of experience on Diophantine equations so I'm asking for a little bit detail help.Thank you.
 A: The formula
$$
2mn, m^2 - n^2, m^2 + n^2
$$
where $m, n$ are relatively prime and of diferent parity,
and $m > n > 0$,
generates all primitive triples.
Thus, to get a triple including $x = 40$, we must solve for when
$2mn \; \mid 40$ or $m^2 - n^2 \; \mid \; 40$.

Case 1: $\boldsymbol{2mn \; \mid 40}$, i.e. $mn \; \mid \; 20$.
Since $m,n$ are relatively prime and not both odd and $m > n$, there are not too many cases
to consider.
$$
\begin{array}{|c|c|c|c|c|c|}
\hline
m & n & 2mn & m^2 - n^2 & m^2 + n^2 & \text{Triple} \\
\hline
20 & 1 & 40 & 399 & 401 & (40, 399, 401) \\
10 & 1 & 20 &  99 & 101 & (40, 198, 202) \\
5  & 2 & 20 &  21 &  29 & (40,  42,  58) \\
5  & 4 & 40 &   9 &  41 & (40,   9,  41) \\
4  & 1 &  8 &  15 &  17 & (40,  75,  85) \\
2  & 1 &  4 &   3 &   5 & (40,  30,  50) \\
\hline
\end{array}
$$

Case 2: $\boldsymbol{m^2 - n^2 \; \mid \; 40}$
Here we factor $(m+n)(m-n) \; | \; 40$.
But since $m+n$ and $m-n$ are odd (since $m,n$ are different parity),
we must have $(m+n)(m-n) \; | \; 5$.
Thus there is just once case, $m = 3$ and $n = 2$.
\begin{array}{|c|c|c|c|c|c|c|c|}
\hline
m+n & m-n & m & n & 2mn & m^2 - n^2 & m^2 + n^2 & \text{Triple} \\
\hline
5 & 1 & 3 & 2 & 12 & 5 & 13 & (96, 40, 104) \\
\hline
\end{array}

In summary, all the triples are
$$
\begin{array}{|c|c|c|}
\hline
x & y & z \\
\hline
40 &   9 &  41 \\
40 &  30 &  50 \\
40 &  42 &  58 \\
40 &  75 &  85 \\
40 &  96 & 104 \\
40 & 198 & 202 \\
40 & 399 & 401 \\
\hline
\end{array}
$$
A quick search on the internet finds a couple 
of sites
which show we didn't miss any.
A: We want to solve $z^2-y^2=40^2$. 
To find all solutions, let $uv=40^2$, where $u$ and $v$ have the same parity. 
For any such $u$ and $v$, we get a solution of the equation in integers by setting $z=\frac{u+v}{2}$ and $y=\frac{u-v}{2}$. 
Note that $40=2^3\cdot 5$, so the number of positive divisors of $40^2$ is $(7)(3)$, But since we want a Pythagorean triple, we want $u\gt v$. There are $10$ possibilities. But some give $u$ and $v$ of opposite parity, which is not allowed, since then $(u+v)/2$ and $(u-v)/2$ are not integers. 
Here are all the relevant values of $u$ and $v$: $v=2,u=40^2/2$;   $v=4, u=40^2/4$; $v=8, u=40^2/8$; $v=10, u=40^2/10$; $v=16, u=40^2/16$; $v=20, u=40^2/20$; $v=32, u=40^2/32$. Now you can compute the $y$ and $z$. 
Remark: We can also use the "formula" that generates Pythagorean triples. This is more unpleasant. And we must remember that the Pythagorean triples have form $(k(s^2-t^2), 2kst, k(s^2+t^2))$, so there are $3$ parameters involved.  
A: All primitive Pythagorean triples can be written in the form $$x^2 + y^2 = z^2$$ with $(x,y)=(x,z)=(y,z)=1$ and $x,y,z$ positive integers. Within this definition, it can be seen that, 
$$x = 2st$$
$$y=s^2-t^2$$
$$z=s^2+t^2$$
where $s,t$ are integers of opposite parity. By our question, 40 can only be the side we claim as x since clearly $y,z$ are odd per our definition. That is, we search for $s,t$ such that $40=2st$. Furthermore, 
$$20=st$$
Which then, we see that possible combinations of $(s,t)$ are $(20,1)$ and $(5,4)$. Finally, we return these values to our equations for $x,y,z$. That is, 
$$s=20,t=1 => x = 40, y=399, z=401$$
and we leave it to the reader to calculate the second primitive Pythagorean triple.
A: Starting with Euclid's formula:
$ \quad A=m^2-k^2\quad B=2mk \quad C=m^2+k^2\quad$
we can solve the $A$-function for $k$, and test a defined range of
$m$-values to see which if any yield integers. Here we assume that
$x=A$.
\begin{equation}
A=m^2-k^2\implies k=\sqrt{m^2-A}\\
\text{for}\qquad  \lfloor\sqrt{A+1}\rfloor \le m 
\le \left\lfloor\frac{A+1}{2}\right\rfloor
\end{equation}
The lower limit ensures $k\in\mathbb{N}$ and the upper limit ensures $m> k$.
$$A=40\implies \lfloor\sqrt{40+1}\rfloor=6\le m \le 
\left\lfloor\frac{40+1}{2}\right\rfloor = 20\\
\land\quad m\in\{7,11\}\implies k \in\{3,9\} $$
$$F(7,3)=(40,42,58)\qquad F(11,9)=(40,198,202) $$
A similar process works if we assume that $x=B.\quad$
Note that Euclid's formula generates only primitives, doubles, and single-or-double square multiples of primitives and that it will not show any other non-square multiples of primitives. To find these, we can use the procedure for all factors of $x$ and then multiply each primitive found by the respective cofactor of $x$.
