### Sum of all pairs find sum of all possible x+y where x and y are natural number solutions of the equation

 `` `` `` x^3 + y^3 = x^2 + y^2 + 42xy``

? In general this is a really hard problem (Diophantine equation)... I'm sure that if this is a real question from somewhere, there must be some trick to solving it, but I'm not sure what it is off the top of my head.

https://en.wikipedia.org/wiki/Diophantine_equation

I would start just by plotting the equation (iterate over x = -50 to 50, y = - 50 to 50 or something like that) and see if there's any sort of pattern. Of course, just graphical inspection doesn't prove that there isn't a really far-out number that also solves the equation.

It seems pretty chaotic to me, I don't see a clear pattern.
https://www.wolframalpha.com/input/?i=plot++round%28x%5E3+%2B+y%5E3+-+x%5E2+-+y%5E2+-+42+x+y%29+%3D+0+from+x+%3D+-40+to+40%2C+y+%3D+-40+to+40

EDIT: I didn't realize you said natural numbers. I was thinking all integers!

The equation looks clearly bounded by graphical inspection on the +x, +y quadrant.
https://www.wolframalpha.com/input/?i=plot++round%28x%5E3+%2B+y%5E3+-+x%5E2+-+y%5E2+-+42+x+y%29+%3D+0+from+x+%3D+0+to+50%2C+y+%3D+0+to+50

What I said still applies -- just graphical inspection doesn't prove it, but it looks pretty solid.

So all you need to do is iterate over a bounded range of positive {x, y} pairs, see which ones solve the equation.

__________________________________

Since we're just working with positives, it becomes clear after I stare at the equation for a bit that the x^3 + y^3 term will eventually beat the x^2 + y^2 + 42xy term, but initially the RHS is greater than the LHS due to the large constant factor (42). Still that's no where near a proof.
Last edited on 60

1<=x,y<=31 (strictly, sqrt(x^2+y^2)<=22.sqrt(2), and that's provable for the first quadrant, as here), so it's not many to search.
(1,7),(7,1),(22,22)
Last edited on But where did you calculate the 22 from?

Edit: To clarify, I understand that (22,22) happens to be the furthest point out radially in the 1st quadrant, but I can't think of an easy way to actually calculate that without knowing beforehand that that is the furthest point out.
Last edited on But where did you calculate the 22 from?

Use polar coordinates.

Substitute
x = r cos θ
y = r sin θ
into the equation.

Divide by r2 (which is not zero in the present circumstances) and you will get (after a minor trig identity) the polar equation of the curve
r = ( 1 + 21 sin(2θ) ) / ( cos3 θ + sin3 θ )

In the first quadrant the numerator has a maximum and the denominator has a minimum fortuitously at the same angle (π/4 radians, or 45 deg). At this point you get the maximum radius in the first quadrant:
r = 22*sqrt(2) = 31.something
(This actually corresponds to one solution, x=y=22).

So search for all integer points inside or on a sector of radius 31 (or, more conveniently, just all x and y less than or equal to 31.)

Last edited on I see, so that shows that the radius is bounded, and therefore you only have to search within the maximum of that polar function. That is such a nicer way than what I was trying to do. Thanks.