Generating all Pythagorean triplets for given Hypotenuse

Euclid's formula generates all primitive triples, and this can be modified to give all triples: set $a = k\cdot(m^2 - n^2) ,\ \, b = k\cdot(2mn) ,\ \, c = k\cdot(m^2 + n^2)$, where $m, n$, and $k$ are positive integers with $m > n, m − n$ odd, and with $m$ and $n$ coprime. Then $a^2+b^2=c^2$, and $c$ is the given hypotenuse.


You can use equations I created for a paper I am writing. To find a triplet with a matching $sideC$ for any odd number ($C_1$), set $$k_c=\frac{-(2n-1)+\sqrt{2C_1-(2n-1)^2}}{2}$$

Now try values of $n$ from $1$ up to $(m-1)$ where $4m^2+1>C_1$. Then, for any value of $n$ that yields a positive integer for $k$, you have a triplet with a matching $sideC$. If you do not find such an integer for $k$ using values of $n$ between $1$ and $(m-1)$, then there is no matching side.

If you do find a positive integer for $k$ for some value of $n$, then you can find the triplet sides A,B,C using the following functions:

$$A(n,k)=(2n-1)^2+2(2n-1)k$$ $$B(n,k)=2(2n-1)k+2k^2$$ $$C(n,k)=(2n-1)^2+2(2n-1)k+2k^2$$

Examples: If you want to find a triplet where $C_1=125$, you will find for $k(n)$ that $k(3)=5$ and $k(5)=2$ and that means that plugging $(3,5)$ and $(5,2)$ into the A.B.C equations will yield triplets with $sideC=125$, i.e. $75,100,125$ and $117,44,125$, respectively. Here are more examples I found in the spreadsheet I used for my study of matching values of $C$ where $f(n,k)$ is the triplet generated using the functions above: $$f(1,11)=(23,264,265), f(7,3)=(247,96,265) $$ $$f(1,13)=(21,220,221), f(5,5)=(171,140,221) $$ $$f(1,21)=(43,924,925), f(7,14)=(533,756,925) $$ $$f(1,28)=(57,1624,1625), f(8,20)=(825,1400,1625)$$ $$f(2,19)=(123,836,845), f(7,13)=(507,676,845) $$ $$f(2,26)=(165,1508,1517), f(8,19)=(795,1292,1517)$$ $$f(3,16=(185,672,697), F(7,11)=(455,528,697) $$ $$f(3,23)=(255,1288,1313), F(8,17)=(735,1088,1313)$$ $$f(4,19)=(315,988,1037), f(8,14)=(645,812,1037)$$ $$f(5,14)=(333,644,725), f(8,10)=(525,500,725)$$ If you go into the higher sets you will find more and more matching triplets in the lower sets $$f(1,23)=(47,1105,1105), f(10,12)=(817,744,1105) , f(15,4)=(1073,264,1105)$$ $$f(1,36)=(73,2664,2665), f(9,27)=(1207,2376,2665), f(15,19)=(1943,1824,2665)$$ $$f(7,23)=(767,1656,1825), f(13,15)=(1375,1200,1825), f(15,12)=(1537,904,1825)$$