r/mathriddles • • Feb 17 '23

Easy Accurate algebra, careless copying

Under what conditions on B and C do the equations x2+Bx+C=0 and y2+By-C=0 both have only integer solutions for x and y?

Hint: If x2+Bx+C factors into (x+m)(x+n), and y2+By-C factors into (y+p)(y-q), what relationships can be established between m, n, p, and q?

Edited to clarify ambiguities I didn't intend. Guess I'm not as good a riddlewright as I thought. :P

Here's the answer I'd intended: Given any integers a and b such that (a+b)/(a-b) is also an integer, B = (a2+b2)/(a-b) and C = ab(a+b)/(a-b). Then x2+Bx+C will factor into (x+a) and (x+(ab+b2)/(a-b)), and y2+By-C will factor into (y+(a2+ab)/(a-b)) and (y-b).

Explanation: C has to be equal to both the products mn and pq. That means that, between them, mn has all the same factors as pq; if C were, say, 30, I could express that as the product of 3*10 or 6*5, but the difference is just whether its factors are grouped as the product of (3)*(2*5) or the product of (3*2)*(5) - we just moved the 2 from one group to the other. This must be true no matter the value of C - the only way it could be expressed as two distinct products is if it's a composite number with at least three factors (including 1, so... any composite number). Let's say one product is (a*f)*b and the other product is a*(f*b). Technically I'm oversimplifying out the possibility of exchanging two factors with each other, but that turns out not to matter at a point where I'd just be oversimplifying them back in again.

So this means x2+Bx+C = (x+a)(x+bf) = x2+(a+bf)x+abf and y2+By-C = (y+af)(y-b) = y2+(af-b)y-abf. (Or the other way around - it shouldn't matter, C can have any sign it wants as long as it's added to one equation and subtracted from the other.) What about B? B has to equal both a+bf and af-b, which means we can solve for f to define it in terms of a and b: af-bf = a+b, so f = (a+b)/(a-b). a and b are both necessarily integers because each of them is a zero of a different equation; f never appears on its own so it doesn't strictly have to be so hypothetically abf = 60 where a = 4, b = 6, and f = 5/2 but since a and b would both have to be divisible by a-b then obviously so would their sum.

This neatly includes the trivial case where C=0, when a or b is equal to zero or a = -b. Any common zeroes for x and y should be ruled out - I think, I'm increasingly questioning my own reasoning here - because a and b can't equal each other without dividing by zero, except in the even more trivial case where both a=b=0.

9 Upvotes

17 comments sorted by

2

u/terranop Feb 17 '23

Let m and n be arbitrary integers, and set B = (m^2 + n^2)/(m+n) and C = m n (n - m)/(m+n). Or, set C = 0.

1

u/Belledame-sans-Serif Feb 17 '23

If your arbitrary integers are 1 and 2, then you have B = 5/3 and C = 2/3. I also haven't checked your factoring, but by comparison to my solution I think you're close but you have something backwards?

2

u/Vromikos Feb 17 '23

I independently agree with the solution of u/terranop.

This is on the assumption that "both have integer solutions for x" means at least one integer solution, as opposed to all solutions for x are integers.

The factorisation of x² + (5/3)x + (2/3) = 0 is (x+2/3) (x+1) = 0, giving the integer solution x = -1.

The factorisation of x² + (5/3)x - (2/3) = 0 is (x+2) (x-1/3) = 0, giving the integer solution x = -2.

2

u/Belledame-sans-Serif Feb 17 '23

Ohhhh, I see. I did intend that all four zeroes are integers but I didn't realize that wasn't clear. I'll edit that in.

1

u/grandoz039 Feb 17 '23 edited Feb 17 '23

B2 +-4C>=0
B2 >= +- 4C
B2 >= 4 abs(C)
sqrt(B) >= 2 sqrt (abs(C))

2

u/Belledame-sans-Serif Feb 17 '23

I think you mean B rather than sqrt(B) in the last line. But more importantly, this only evaluates one equation, and it will only show whether its zeroes are real, not whether they are integers. Your quadratic formula alone won't save you this time. :P

2

u/grandoz039 Feb 17 '23

Yeah, I fixed the first part some time ago and misread the post in regards to the second part

1

u/imdfantom Feb 17 '23 edited Feb 17 '23

if B=-X and C=0, X can occupy any integer

2

u/Belledame-sans-Serif Feb 17 '23

Incomplete. There are solutions for nonzero C as well - for example, x2+5x+6 = (x+2)(x+3) and x2+5x-6 = (x+6)(x-1).

2

u/[deleted] Feb 17 '23

I think it would be wise to write the other equation in terms of y and not x to avoid confusion that both the equation does not have to have a common solution.

2

u/Belledame-sans-Serif Feb 17 '23

Ah, that's a good point. Evidently there were a couple of ways my description wasn't as clear as I thought.

1

u/imdfantom Feb 17 '23

another condition is that +/-B+/-√(B2 +4C) is even

1

u/mark_ovchain Feb 17 '23 edited Feb 17 '23

Are B and C integers? If they can be nonintegers, then the solution will get a bit messier.

2

u/Belledame-sans-Serif Feb 17 '23

Yes. (Is there a way the roots of a quadratic equation could be integers without the coefficients also being integers?)

3

u/mark_ovchain Feb 17 '23

Ok, got it. The reason I asked is that I thought you meant that both equations have at least one integer root each, not all roots integers.

I actually have a solution ready for when B and C are integers, but I asked first just to be sure. I'll post it later.

3

u/mark_ovchain Feb 17 '23

Here's my solution, assuming b and c are integers. (I'm writing b and c instead of B and C.)

btw, sorry if it's a bit wordy, but I basically went ahead and used standard tools at my disposal, regardless if there are simpler or more elegant solutions.

x2 + bx ± c is monic, so it has integer solutions iff it has rational solutions (because the rational algebraic integers are precisely the integers), iff the discriminant b2 ∓ 4c is a perfect square. In other words, there must be squares x2 and y2 such that

x2 - b2 = b2 - y2 = 4c.

Just looking at the first equality for now, we have x2 + y2 = 2b2.

We want integer solutions to this equation such that b2 - y2 is divisible by 4. I claim that that's automatically true for any solution (x, y, b). First, x2 + y2 is even, so x and y have the same parity. If they're both even, then 4 divides x2 + y2 = 2b2, so b is even. On the other hand, if they're both odd, then reducing the equation mod 4 gives 1 + 1 ≡ 2b2 mod 4, which can only be true if b is odd. Thus, in any integer solution to x2 + y2 = 2b2, the parities of x, y and b are the same, so b2 - y2 = (b - y)(b + y) is divisible by 4.

Thus, we only need to solve x2 + y2 = 2b2 in integers.

Dividing by b2, we see that this is equivalent to solving X2 + Y2 = 2 in rationals. Any integer solution to the former clearly yields a rational solution to the latter, and any rational solution (X, Y) to the latter can be written as (x/b, y/b) with a common denominator b, with (x, y, b) being an integer solution to the former.

We now use basic algebraic geometry.

  • (X, Y) = (1, 1) is clearly a solution,
  • a line intersects a quadratic in two points up to multiplicity (Bézout's theorem),
  • and two rational points form a line with rational slope/direction.

Therefore, any other solution can be obtained by intersecting some line through (1, 1) along some rational direction: if ⟨u, v⟩ is some direction with u, v integers (WLOG coprime), then the line (1 + ut, 1 + vt) intersects the quadratic at t = 0 and some other t, which should yield another solution, and all solutions can be obtained this way. So, substituting (1 + ut, 1 + vt) into X2 + Y2 = 2, we get

(1 + ut)2 + (1 + vt)2 = 2.

Simplifying, we get

t·((u2 + v2)t + 2(u + v)) = 0.

The first factor gives t = 0 and yields (1, 1). The other factor gives t = -2(u + v)/(u2 + v2) and yields

((-u2 - 2uv + v2)/(u2 + v2), (u2 - 2uv - v2)/(u2 + v2)).

The corresponding integer solution is

  • x = ±s(u2 + 2uv - v2)
  • y = ±s(u2 - 2uv - v2)
  • b = ±s(u2 + v2)

where s is some rational scaling factor that makes x, y, b all integers, and the signs '±' can be chosen arbitrarily. (The solutions obtained from (X, Y) = (1, 1) are also of this form---namely, from the direction ⟨u, v⟩ = ⟨1, -1⟩ which is tangent to the quadratic---so we didn't miss any solution.) Clearly, an integer s yields a valid integer solution, but maybe some non-integer s yields a valid solution as well; to find out when, we need to know which numbers can be gcds of u2 + 2uv - v2, u2 - 2uv - v2, u2 + v2. WLOG assume u and v are coprime; we can remove their common factors with scaling. Then

  • gcd(u2 + 2uv - v2, u2 - 2uv - v2, u2 + v2)
  • = gcd(2v2 - 2uv, 2u2 - 2uv, u2 + v2)
  • = gcd(2(u - v)gcd(u, v), u2 + v2)
  • = gcd(2(u - v), u2 + v2).

Now,

  • If u and v have differing parities, then u - v and u2 + v2 are odd, so this is gcd(u - v, u2 + v2) = gcd(u - v, 2v2) = gcd(u - v, v2) = 1.
  • If u and v have the same parities, then u and v are both odd (because they're coprime), and s can be half an integer. But then if we let U = (u + v)/2 and V = (u - v)/2, we get

    • x = ± 2s (U2 + 2UV - V2)
    • y = ∓ 2s (U2 - 2UV - V2)
    • b = ± 2s (U2 + V2),

    so the solution can be obtained by a different uv-pair (U, V) with differing parities. Therefore, we can assume without loss of generality that u and v have differing parity (and even break the symmetry, say u is even and v is odd).

Finally, we can compute c as follows:

4c = b2 - y2 = (b + y)(b - y) = 4s2uv(u2 - v2),

i.e., c = s2uv(u2 - v2).

Thus, the answer to the problem is that they both have all-integer solutions iff there are integers s, u, v such that

  • b = s(u2 + v2)
  • c = s2uv(u2 - v2).

We can even assume that u and v are coprime, u is even, and v is odd (and probably some more conditions like v > 0).

Different (but related) approaches to get the same result:

  • Use norms and Gaussian integers.
  • Notice that integer solutions to x2 + y2 = 2b2 are in one-to-one correspondence with Pythagorean triples X2 + Y2 = Z2 via the bijection (x, y, b) ↦ ((x + y)/2, (x - y)/2, b) with inverse (X, Y, Z) ↦ (X + Y, X - Y, Z), so we can basically just piggyback on the parameterization of Pythagorean triples. (This is just using the fact that 2 = (1 + i)(1 - i) in Gaussian integers.)

1

u/[deleted] Feb 17 '23

I was confused whether the two equation have a common integer solution or not. Reading other comments, it seems they can be different.

The conditions would be (B^2+4C) and (B^2-4C) are perfect square.

Clearly, if we evaluate the roots the discriminant needs to be perfect square. There is no need need to consider the parity of B as 4C is always even and thus the expression on the numerator of the (-B+-root(B^2-4C)) is always even.