# Pythagorean like Diophantine Equation

I am trying to solve this problem. http://www.javaist.com/rosecode/problem-527-1-2-3-type-Pythagorean-triangles-askyear-2018

Here we have to find all positive integral solution of $$a^2+2b^2=3c^2$$ where $$a+b+c\le N$$. In the question, $$N=25000000$$.

My first approach was to loop over $$a$$ and for fixed value of $$a$$ find the solutions of $$3c^2-2b^2=a^2$$ using LMM algorithm (https://thilinaatsympy.wordpress.com/2013/07/06/solving-the-generalized-pell-equation/). But this is very slow. I am unable to find a faster method. Any help will be appreciated.

• math.stackexchange.com/questions/2773097/… – individ Dec 10 '18 at 13:14
• This doesn't give all the solutions. – piepie Dec 11 '18 at 6:02
• Gives all solutions. It is necessary to accurately and attentively all to write down. Although you can write such a simple solution. $$a^2+2b^2=3c^2$$ $$a=p^2+6ps+3s^2$$ $$b=p^2-3s^2$$ $$c=p^2+2ps+3s^2$$ – individ Dec 11 '18 at 6:41
• I am not sure how you arrived at this parametric solution, but it certainly doesn't give all the solutions and also produces lots of negative integer solutions, which aren't necessary. – piepie Dec 11 '18 at 16:22
• Rewrite the negative into a positive solution. You want to get a solution what you like, not a solution to the problem. That's not how math works. We may not like the answer, but the solution is the solution. – individ Dec 11 '18 at 16:37

Above equation shown below has parametric solution:

$$a^2+2b^2=3c^2$$

$$(a,b,c)=((3k^2-6k-5),(3k^2+6k-1),(3k^2+2k+3))$$

For $$k=4$$ we get:

$$(a,b,c)=(5,13,11)$$

If we use Pythagorean triples we have:

$$(m^2-n^2)^2+(2 mn)^2=(m^2-n^2)^2$$

$$(m^2+n^2)^2-(m^2-n^2)^2=(2mn)^2=2(2m^2n^2)$$

Here $$a=m^2+n^2$$, $$c=m^2-n^2$$

Now we rearrange the equation as:

$$a^2-c^2=2(c^2-b^2)$$

Comparing these relations means:

$$c^2-b^2=2m^2n^2$$

$$2m^2n^2=(m^2-n^2)^2-b^2$$

$$b^2=m^4+n^4-4m^2n^2$$

For example with $$m=2$$ and $$n=1$$ we have:

$$a=2^2+1^2=5$$, $$c=2^2-1^2=3$$ and:

$$b^2=2^4+1^4-4\times2^2\times1^2=1$$ or $$b=1$$

and we have:

$$5^2+2\times1^2=3\times3^2$$

This is primitive solution and subsequent solutions can be found by multiplying both sides of this relation by a number like $$n^2$$:

$$(5n)^2+2(n)^2=(3n)^2$$

$$a+b+c<=25000000$$

$$5n+n+3n=9n<=25000000$$

$$n<=2777777$$

This gives a set of solutions. Also $$a=b=c=1$$ is a primitives solution which gives another set of solutions. It is not known if the parametric formula for $$b$$ gives more integer solutions for b; if it does there will be more primitive solutions and thereby more solutions.

$$(2 a^2 - 3 b^2)^2 + 2 (2 a^2 + 3 b^2 - 6 a b)^2 = 3 (2 a^2 + 3 b^2 - 4 a b)^2$$ $$(a^2 - 6 b^2)^2 + 2 (a^2 + 6 b^2 - 6 a b)^2 = 3 (a^2 + 6 b^2 - 4 a b)^2$$

I don't think there is a solution. I have solved many such problems for $$n$$ in terms of $$m$$ and sometimes other variables. Whenever I found an integer value for $$n$$, I had the $$m,n$$ for a Pythagorean triple. Caveat: Euclid's formula generates only primitives, doubles an square multiples of primitives without a multiplier $$k$$, so I could be missing something but here is my attempt.

$$A^2+2B^2=3C^2\implies m^2-n^2+2(2mn)^2=3(m^2+n^2)\implies m^2-n^2+8m^2n^2=3m^2+3n^2$$

$$8m^2n^2-4n^2-2m^2=4(2m^2-1)n^2+0n-2m^2=0$$ $$a=4(2m^2-1)\qquad b=0\qquad c=-2m^2$$

$$n=\frac{-b\pm \sqrt{b^2- 4ac}}{2a}=\frac{\pm \sqrt{-4(4(2m^2))(-2m^2)}}{2(4(2m^2-1))}=\frac{\pm\sqrt{64m^4}}{8(2m^q-1)}=\frac{m^2}{2m^2-1}$$

Putting this final formula into a spreadsheet, the values of $$n$$, $$m=1\rightarrow n=1$$ which is trivial triple but, for $$m=2$$ thru $$m=7635, n$$ steadily decreased from $$0.571428571428571$$ to $$0.500000004288663.$$

Do check my algebra but I don't think there a solution because, always, $$m\notin\mathbb{N}$$.

• You misinterpret the problem. (A,B,C) isn't necessarily a Pythagorean triplet. – piepie Sep 2 '19 at 5:28