# Number which is simultaneously sum of 2 and 3 squares [closed]

Is there positive integer $m$ such $m=x_1^2+x_2^2$ and $m=y_1^2+y_2^2+y_3^2$ where $x_i, y_j$ are nonzero integers. I have tried by hand for the ten natural numbers but I was not able to find such $m$.

Would be thankful for help.

## closed as off-topic by user21820, Simply Beautiful Art, Jack, Dietrich Burde, user223391 Nov 27 '17 at 20:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – user21820, Simply Beautiful Art, Jack, Dietrich Burde, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

• repl.it/repls/FaithfulLazyAustraliankelpie – mathnoob123 Nov 25 '17 at 19:26
• @mathnoob123: This one is more efficient, I think. – Kevin Nov 25 '17 at 20:13
• Is there anything saying that all $x_i$ must be distinct from all $y_i$? – Todd Wilcox Nov 25 '17 at 23:23
• @apnorton The linked answer is not great, the itertools example doesn't construct a tuple in the loop body (this is done behind the scenes) and avoids two list look-ups. Here's a Python 3 example which shows that explicit loops are faster. In practice, it rarely matters either way because the loop body is usually more expensive than the iteration (which was the inspiration for the original comment, but I didn't notice that the first example re-checked combos). – Jared Goguen Nov 26 '17 at 17:35
• Pythagorean triples #1: (3,4,5) and #2 (5,12,13) have hypotenuse of the first as a side in the second, so 169 = 144 + 25 = 144 + 16 + 9. – Pieter Geerkens Nov 27 '17 at 5:50

Obviously, if there are any solutions to $a^2 =b^2 + c^2$, then you can add $x^2$ to both sides and get your $m$'s.

For example, $25 + x^2 = 9 + 16 + x^2$ for all natural numbers $x$.

You can even have $m$ be a perfect square AND a sum of two squares AND a sum of three squares (take $x=12$ above).

• The equivalent for Pythagorean triples would be to start with a solution to $a^2=0$ and add $x^2$ to both sides. This does answer the question, but it would be reasonable to require that no integer appears on both sides of the equation. – Jack M Nov 26 '17 at 17:37

There is a possibly famous identity: $$\Large 10^2+11^2+12^2=13^2+14^2$$ which meets your criteria.

Here $m$ is $365$.

Alternatively you could use a formula to generate examples; for example

$$m=\left(a^2+b^2+c^2\right)^2+\left(a^2-c^2\right)^2=\left(a^2+c^2\right)^2+\left(2cb\right)^2+\left(a^2+b^2-c^2\right)^2$$

originating from the identity $$\left(a^2+b^2+c^2\right)^2-\left(a^2+b^2-c^2\right)^2=\left(2ca\right)^2+\left(2cb\right)^2$$ and using $$\left(a^2+c^2\right)^2-\left(a^2-c^2\right)^2=\left(2ca\right)^2$$

to substitute for $\left(2ca\right)^2$

• Hmm looks elegant. How did you come up with? – ZFR Nov 25 '17 at 20:00
• @RTZ: Updated post – James Arathoon Nov 25 '17 at 20:09
• @RFZ It's a logical extension of an ancient parametrization for generating Pythagorean triads, $(u^2 - v^2)^2 + (2uv)^2 = (u^2 + v^2)^2$ – PM 2Ring Nov 26 '17 at 0:56

Combine the sequences A001481 and A000378. The positive integers appearing in both sequences are sum of two squares, and a sum of three squares, e.g., $$17=16+1=4+4+9$$

• The first sequence is for sums of two DISTINCT squares. There was nothing about "distinct" in the question. And the second sequence you linked to is for sums of FOUR squares. (Which is why 17, your example, does not even appear in the second sequence.) – mathguy Nov 25 '17 at 19:26
• Corrected. But distinct or not does not matter, because $17$ still is a valid example, and the OP just wanted "a sum" of two squares, resp. three squares. – Dietrich Burde Nov 25 '17 at 19:32
• Understood; my point was, suppose there were no overlaps between the two lists, that wouldn't answer the original question. You proved existence in even more restrictive conditions that the OP had. – mathguy Nov 25 '17 at 19:34
• Anyway, your first comment no longer applies. – Dietrich Burde Nov 25 '17 at 19:46

Here's a theoretical answer: any prime $p$ of the form $8k+1$ will work (this gives infinitely many examples, including the example of 17 in Dietrich's example).

Why is this true?

First, Fermat proved that any prime $p$ of the form $8k+1$ (in fact 1 mod 4) is of the form $x^2+y^2$. Being prime, it's not a square so both $x, y$ must be nonzero for $x^2+y^2=p$.

Second, Fermat also proved that any prime $p$ of the form $8k+1$ (in fact 1 or 3 mod 8) is of the form $x^2+2y^2$. Again, no prime can be of the form $x^2$ or $2y^2$, so we need both $x,y$ nonzero for $x^2+2y^2=p$. Then $p=x^2+y^2+z^2$ with $z=y$ and $x,y,z$ all nonzero.

• And Dirichlet proved that there are infinitely many such primes. – B. Mehta Nov 26 '17 at 21:44