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.

  • $\begingroup$ math.stackexchange.com/questions/2773097/… $\endgroup$ – individ Dec 10 '18 at 13:14
  • $\begingroup$ This doesn't give all the solutions. $\endgroup$ – Asif Dec 11 '18 at 6:02
  • $\begingroup$ 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$$ $\endgroup$ – individ Dec 11 '18 at 6:41
  • $\begingroup$ 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. $\endgroup$ – Asif Dec 11 '18 at 16:22
  • $\begingroup$ 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. $\endgroup$ – individ Dec 11 '18 at 16:37

Above equation shown below has parametric solution:



For $k=4$ we get:



If we use Pythagorean triples we have:

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


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

Now we rearrange the equation as:


Comparing these relations means:




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:


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





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$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.