1

I'm hoping this is the last question I have to ask for this particular Project Euler problem. I'm not sure this is the place to ask this question so I apologize in advance if it isn't.

I had finally decided I was not going to get the answer that I needed by hand and decided to let the computer do the work instead. My plan involved generating Pythagorean quadruples using a parameterization on Wikipedia:

$$a=m^2+n^2-p^2-q^2,b=2(mq+np),c=2(nq-mp),d=m^2+n^2+p^2+q^2$$ with the condition that $m,n,p$, and $q$ are non-negative integers with $\gcd(m,n,p,q)=1$ and $m+n+p+q$ is odd. Supposedly, this can generate all primitive quadruples. However, I've noticed some problems. Can I work around them or do I just have to deal with it?

First of all, I haven't been able to figure out a way to generate 4 integers with greatest common divisor of 1. Do I just need to generate and test each set of numbers?

Second, if possible, I'd like to avoid repeats and values that aren't positive and I'm not sure what the best way would be. If I'm not mistaken, I can avoid 0's by only including 1 value of 0 among $m,n,p,$ and $q$. Avoiding negatives is a little trickier. When trying to do it on paper, I'd partition the set of 4 numbers into pairs. Whichever one had the greater sum of squares would be $m$ and $n$. Then I'd need to test the possible pairings to ensure that $nq>mp$. The repeats question is a bit trickier still, but I imagine it's something to do with $d^2-a^2=4(m^2+n^2)(p^2+q^2)$?

Finally, I've noticed that making sure that $m,n,p$ and $q$ do not share a common factor is not enough to ensure that the quadruple is actually primitive. For example, one of the cases I tested by hand was $(m,n,p,q)=(1,7,3,4)$ which generates the quadruple $25^2+50^2+50^2=75^2$. Is there any way to prevent this from occurring? I'm starting to think maybe the parameterization that involves factoring isn't looking so bad after all...

Mike
  • 13,643
  • Though you're hoping this is the last question you have to ask, I'd be glad to grasp the problem. Please, what is the PE number so perhaps I may get a picture with different wording. – m-stgt Sep 01 '24 at 17:07
  • @m-stgt Bear in mind, by the time I come here to ask on a problem, I've already done quite a bit of work. If it were to look anything like the original problem, I'd consider it cheating. I ask here for help with one specific part of the task, not to spoil the problem for myself and others. I will say it is one of the first 200 problems with a difficulty of 45%. If it's really important, maybe I can add it later in a comment in spoiler tags if I can figure out how to do so. – Mike Sep 01 '24 at 20:17
  • No zest for solving partial problems. HTH – m-stgt Sep 02 '24 at 02:56

1 Answers1

1

"OP" has considered only one Identity. For his research he can consider the below identities.

$n^2 + (n+1)^2 + (n^2+n)^2 = (n^2+n+1)^2$

$(a^2-b^2-c^2+d^2)^2 + (2ab-2cd)^2 + (2ac+2bd)^2 = (a^2+b^2+c^2+d^2)^2$

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

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

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

$((a^2+c^2)(b^2-c^2))^2 + (2bc(a^2-c^2))^2 + (4abc^2)^2 = ((a^2+c^2)(b^2+c^2))^2$

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

$(a^4-b^4)^2 + (4a^2b^2)^2 + (2ab(a^2-b^2))^2 = (a^4+2a^2b^2+b^4)^2$

Above Identities are from the book by Tito Piezas. The book can be found at the below mentioned link.

https://web.archive.org/web/20230326021830/http://sites.google.com/site/tpiezas

David
  • 235
  • Can any of these produce all possible primitive quadruples? If not, there's a chance I miss the one I need to solve the original problem. Maybe I get lucky, maybe I don't. – Mike Sep 01 '24 at 20:23
  • @Mike. As far as I am aware there is yet no general solution to the (2-1-3) equation. One of the above Identities could be a general solution. But then maybe not. You could try reading chapter seven of Dickson book volume 2. – David Sep 02 '24 at 13:42