Where is my error in trying to find Pythagorean triples with matching areas?

I'm trying to craft a formula for finding matching areas in Pythagorean triples the way I have done with matching sides and matching perimeters and matching area:perimeter ratios. For example:

$f(10,3)=(91,60,109)$ and $f(14,1)=(195,28,197)$ have the same area $2730.$

I thought I had solved the $area$ equation using the $cubic$ formula but, when I plug in $m=10$, I do not get $3$ and, when I plug in $m=14$, I do not get $1$ in a spreadsheet or in Wolfram Alpha. Here is my attempt at solving the area equation for $n$ in terms of $D$ (the area), and $m$.

$$A=m^2-n^2\quad B=2mn\implies D(area)=\frac{AB}{2}=\frac {2m^3 n-2mn^3}{2}=m^3 n-mn^3$$

$$\text{In standard form }\\ mn^3+0n^2-m^3n+D=0\qquad a=m\quad b=0\quad c=-m^3\quad d=D$$

\begin{align*} n&=\sqrt[3]{\biggl(\frac{-b^3}{27a^3 }+\frac{bc}{6a^2}-\frac{d}{2a}\biggr)+\sqrt{\biggl(\frac{-b^3}{27a^3}+\frac{bc}{6a^2}-\frac{d}{2a}\biggr)^2+\biggl(\frac{c}{3a}-\frac{b^2}{9a^2}\biggr)^3}}\\ &+\sqrt[3]{\biggl(\frac{-b^3}{27a^3 }+\frac{bc}{6a^2}-\frac{d}{2a}\biggr)-\sqrt{\biggl(\frac{-b^3}{27a^3}+\frac{bc}{6a^2}-\frac{d}{2a}\biggr)^2+\biggl(\frac{c}{3a}-\frac{b^2}{9a^2}\biggr)^3}}\\ &-\frac{b}{3a} \end{align*}

$$=\sqrt[3]{\biggl(-\frac{d}{2a}\biggr)+\sqrt{\biggl(-\frac{d}{2a}\biggr)^2+\biggl(\frac{c}{3a}\biggr)^3}}\\+\sqrt[3]{\biggl(-\frac{d}{2a}\biggr)-\sqrt{\biggl(-\frac{d}{2a}\biggr)^2+\biggl(\frac{c}{3a}\biggr)^3}}$$

$$=\sqrt[3]{\biggl(-\frac{D}{2m}\biggr)+\sqrt{\biggl(-\frac{D}{2m}\biggr)^2+\biggl(\frac{-m^3}{3m}\biggr)^3}}\\ +\sqrt[3]{\biggl(-\frac{D}{2m}\biggr)-\sqrt{\biggl(-\frac{D}{2m}\biggr)^2+\biggl(\frac{-m^3}{3m}\biggr)^3}}$$

Oddly, inputs $2730,3\rightarrow -10$ and $2730,1\rightarrow -14$ as though I had solve for $m$ instead of $n$... and changing the sign of $D$ changed the sign of the result. I tried individual components in a spreadsheet and found negatives under the square roots.

Finally, I tried the simplest triple $f(2,1)=(3,4,5)$ and, as expected, when $D=\frac{3*4}{2}=6, m=1\rightarrow n=-2.$ I tried my hand at De Moivre's Theorem because of the real and imaginary components under the cube roots but I got lost.

Did I make a mistake in in my identification of $a,b,c,d$ or in my algebra? Or, can someone show me how to use De Moivre's Theorem to yield $n=1$ when $D=6$ and $m=2$?

Oddly, when I solved this for a more complex formula that I came up with to generate $sets$ that are, themselves, a subset of triples where $GCD(A,B,C)$ is an odd square (a subset that includes all primitives and reduces clutter), I got it to work except for the smallest triangles of sets $7$ and above where there were square roots of negatives. My generator uses $(n,k)$ as though they were $(2m-1+n,n)$. This formula generates a non-trivial triple for every $n,k\in\mathbb{N}$. For the above exercise: $f(1,1)=(3,4,5)\quad f(4,3)=(91,60,109)\quad f(7,1)=(195,28,197)$.

$$A=(2n-1)^2+2(2n-1)k\\ B=2(2n-1)k+2k^2\\ C=(2n-1)^2+2(2n-1)k+2k^2$$ and the formula that usually works ($6,1\rightarrow 1\quad 2730,4\rightarrow 3\quad 2730,7\rightarrow $#NUM) is:

$$k=\sqrt[3]{(\frac{D}{8(2n-1)}+\sqrt{\frac{D^2}{64(2n-1)^2 }-\frac{(2n-1)^6}{1728}}}\\ +\sqrt[3]{(\frac{D}{8(2n-1)}-\sqrt{\frac{D^2}{64(2n-1)^2 }-\frac{(2n-1)^6}{1728}}}-\frac{(2n-1)}{2}$$

I suppose, what I'm looking for is 1) my error, 2)how to use de Moivre's $n^{th}$ root theorem to deal with imaginaries in this context, or 3) how to find the limits of the search (as I have done with my other formulae) when I input $n$ instead of $m$.


I notice that the equation is of the following form (I replaced $n$ by $x$):

$x^3 - m^2 x + \frac{D}{m} = 0$

Please see the following reference for the trigonometric solution. This is applicable to your case since the coefficient of $x$ is negative. This means your equation has three real roots.

Trigonometric solution for three real roots

In summary:

Let

$p = -m^2$

$q = \frac{D}{m}$

$a = \frac{-p}{3}$

$b = \frac{q}{2}$

$C(p, q) = 2 \sqrt{a} \cos\left(\frac{1}{3} \arccos \left(\frac{-b}{a} \sqrt{\frac{1}{a}}\right)\right)$

Then the three roots are given by

$t_0 = C(p, q)$

$t_1 = C(p, -q) - C(p, q)$

$t_2 = -C(p, -q)$

I checked that the method works for both of your examples.

Let me include the output of a program I wrote:

For (6, 2)

p:-4.0

q:3.0

Answer:

$t_0$: 1.3027756377319946

$t_1$: 1.0000000000000002

$t_2$: -2.302775637731995

For (2730, 10)

p:-100.0

q:273.0

Answer:

$t_0$: 8.156603957913985

$t_1$: 2.9999999999999982

$t_2$: -11.156603957913983

For (2730, 14)

p:-196.0

q:195.0

Answer:

$t_0$: 13.47318861248212

$t_1$: 1.0

$t_2$: -14.47318861248212


Pythagorean triples can in fact be generated by the formula $f(m,n) = (m^2-n^2,2mn,m^2+n^2)$. Note that is essential that $m > n > 0$. The area is $D = D_{m,n} = \dfrac{(m^2-n^2)2mn}{2} = m^3n - mn^3$.

What you do is to express $n$ in terms of $m$ and $D$ as a (real) solution of the cubic equation $$x^3 - m^2x = -\frac{D}{m}$$ for which a solution formula is well-known (see for example my answer to Is there really analytic solution to cubic equation?). Here the discriminant is $R= (-\frac{D}{m})^2/4 + (-m^2)^3/27 = D^2/4m^2 - m^6/27$.

Only if $R > 0$ you get a unique real solution which is given in the last line of your computation (plus two non-real complex conjugate solutions).

For $R < 0$ you get three distinct solutions of the cubic equation, but these involve complex numbers and the last line of your computation is not well-defined unless you specify which of the three possible cubic roots has to be taken in each of the two summands. See once more Is there really analytic solution to cubic equation? where you will find that the three real solutions $x_i$ are given as $2\text{Re}(w_i)$ where the $w_i$ are the three complex cubic roots of $-\frac{D}{2m}+ \sqrt{R}$.

Unfortunately, you do not apply this correctly because you mix up $m$ and $n$. For example, consider $f(10,3) = (61,60,109)$. Here you have $m = 10$ and $n=3$. Now insert $m=10$ and $D = 2730$ and you will see that $R < 0$. By the way, the cubic equation is based on the assumption that $m > n > 0$, thus inserting $m=3$ and $D = 2730$ has anyway nothing to do with your problem. But formally $f(3,-10) = (-91,-60,109)$ which explains why you get $n = -10$ by the cubic equation. More generally, if $m > n > 0$ and $f(m,n) = (a,b,c)$, then $f(n,-m) = (-a,-b,c)$ and $D_{m,n} = D_{n,-m}$.

Therefore I would recommend to express $m$ via $n$ and $D$ which leads to $$x^3 -n^2x = \frac{D}{n} $$ Here you have $R = (\frac{D}{n})^2/4 + (-n^2)^3/27 = D^2/4n^2 - n^6/27$ which is certainly bigger than $D^2/4m^2 - m^6/27$ (recall $m > n > 0$) and gives you a better chance to get $R > 0$.

In fact, if you insert $n=3$ and $D = 2730$, then you will see that $R > 0$. Here your formula produces the solution $x = 10$. However, if you use your solution formula you have to do something additional to show that the solution is exactly $10$. A calculator produces the value $10$, but it could be a non-integer real number very close to $10$. Thus you must insert $x = 10$ into the cubic equation to verify.

An example for $R < 0$ is $f(8,7) = (15, 112,113)$ with $D = 840$. We get $$x^3 - 49x = 120$$ Solutions are $x = 8, -3,-5$.

When does $R < 0$ occur? We know that $m$ is a solution of $x^3 - n^2x - D/n = 0$. Dividing the degree $3$ polynomial by $x-m$ produces $x^2 + mx + (m^2-n^2)$ and the other two solutions of the cubic equation must be solutions of the quadratic equation $$x^2 + mx + (m^2-n^2) = 0$$ i.e. are $$x_{1,2} = -\frac{m}{2} \pm \sqrt{\frac{m^2}{4} - (m^2-n^2)} = -\frac{m}{2} \pm \sqrt{n^2 -\frac{3}{4}m^2}$$ Thus, precisely when $n > \sqrt{\frac{3}{4}}m$ we get three distinct real solutions of our cubic equation (note also that then $x_{1,2} < 0$) which is equivalent to $R < 0$. You will easily see that precisely when $m \ge 8$ there are integers $n$ such that $m > n > \sqrt{\frac{3}{4}}m$.

By the way, this also shows that $R = 0$ cannot occur. This is equivalent to $n = \sqrt{\frac{3}{4}}m$ which impossible for integers $m,n$.

Edited:

Although the above considerations contain all relevant informations, I focused on the case that we are given $D, n$. The reason was that this gives a better chance for $R > 0$. Now let us focus on the case that $D, m$ are given.

We know that $n$ can be determined as a solution of $x^3 - m^2x = -\frac{D}{m}$ which has $R = D^2/4m^2 - m^6/27$.

When does $R < 0$ occur? We know that $n$ is a solution of $x^3 - m^2x + D/m = 0$. Dividing the degree $3$ polynomial by $x-n$ produces $x^2 + mx + (n^2-m^2)$ and the other two solutions of the cubic equation must be solutions of the quadratic equation $$x^2 + mx + (n^2-m^2) = 0$$ i.e. are $$x_{1,2} = -\frac{m}{2} \pm \sqrt{\frac{m^2}{4} - (n^2-m^2)} = -\frac{m}{2} \pm \sqrt{\frac{5}{4}m^2 - n^2}$$ Since $m > n > 0$, we always get three distinct real solutions $\xi_i$ of our cubic equation which is equivalent to $R < 0$. Not knowing $n$, these can best be expressed as $\xi_i = 2\text{Re}(w_i)$ where the $w_i$ are the three complex cubic roots of the non-real complex number $-\frac{D}{2m}+ \sqrt{R} = -\frac{D}{2m}+ i\sqrt{-R}$.

You also see that $-\frac{m}{2} - \sqrt{\frac{5}{4}m^2 - n^2} < 0 < -\frac{m}{2} + \sqrt{\frac{5}{4}m^2 - n^2} < m$, that is, the only geometrically relevant solution is the biggest of $\xi_1,\xi_2,\xi_3$.