TT8–TT10 - Diophantine and Pell's equations

TT8–TT10 - Diophantine and Pell's equations

Construct Pythagorean triples and related power identities. Solve Pell equations, translate their solutions back into practical integer problems, and use given identities, exact searches and modular obstructions for other Diophantine equations.

Build integer right triangles

Which square greater than 11 is also a triangular number, and how could we find the next one without checking every integer?

Integer equations often reward a change of viewpoint. We begin with a familiar one: whole-number sides of a right triangle.

You already know

A Diophantine equation asks for integer solutions. The previous lesson used congruences to limit possible residues, and the programming lesson used loops with exact integer arithmetic. Complex multiplication and expansion were taught in Core Pure.

An integer solution to the right-triangle equation has its own familiar name.

Pythagorean and primitive triples

A Pythagorean triple consists of positive integers a,b,ca,b,c satisfying a2+b2=c2a^2+b^2=c^2. It is primitive if gcd⁡(a,b,c)=1\gcd(a,b,c)=1. Multiplying all three entries by the same positive integer produces another triple.

The difference-of-squares identity supplies a systematic construction.

Constructing triples

For integers m>n>0m>n>0,

a=m2−n2,b=2mn,c=m2+n2.a=m^2-n^2,\qquad b=2mn,\qquad c=m^2+n^2.

The triple is primitive when m,nm,n are co-prime and have opposite parity. Every primitive positive triple has this form, allowing the legs to be interchanged; every positive triple is a positive integer multiple of a primitive one.

Not in the formula booklet: learn it.

The identity follows directly:

(m2−n2)2+(2mn)2=m4+2m2n2+n4=(m2+n2)2.(m^2-n^2)^2+(2mn)^2=m^4+2m^2n^2+n^4=(m^2+n^2)^2.

Worked example 1: one parameter pair

Question. Construct the triple from m=3,n=2m=3,n=2, and decide whether it is primitive.

Plan. Substitute, then check the conditions on the parameters and the resulting sides.

a=32−22=5difference of squaresb=2(3)(2)=12product termc=32+22=13hypotenusegcd⁡(3,2)=1,3 odd, 2 evenprimitive conditions\begin{aligned} a&=3^2-2^2=5 && \text{difference of squares}\\ b&=2(3)(2)=12 && \text{product term}\\ c&=3^2+2^2=13 && \text{hypotenuse}\\ \gcd(3,2)&=1,\quad3\text{ odd},\ 2\text{ even} && \text{primitive conditions} \end{aligned}

Why this step? The formula guarantees a triple; the extra conditions guarantee primitiveness.

Answer. (5,12,13)(5,12,13), primitive.

Check. 25+144=16925+144=169, and the three sides have no common factor greater than 11.

Keep n=2n=2 and change only mm to 55.

Worked example 2: another primitive triple

Question. Construct the triple for m=5,n=2m=5,n=2.

Plan. Use the same three expressions and check the new parameter pair.

a=25−4=21first legb=2(5)(2)=20second legc=25+4=29hypotenusegcd⁡(5,2)=1opposite parity also holds\begin{aligned} a&=25-4=21 && \text{first leg}\\ b&=2(5)(2)=20 && \text{second leg}\\ c&=25+4=29 && \text{hypotenuse}\\ \gcd(5,2)&=1 && \text{opposite parity also holds} \end{aligned}

Why this step? The first leg need not be the shorter leg; the equation is symmetric in the legs.

Answer. (21,20,29)(21,20,29), primitive.

Check. 441+400=841=292441+400=841=29^2.

With m=3,n=1m=3,n=1, the parameters are both odd and give (8,6,10)(8,6,10), which is not primitive. With m=4,n=2m=4,n=2, a common parameter factor also produces a non-primitive triple.

Watch out

Wrong: every parameter pair gives a primitive triple. Right: the identity always gives a triple, but primitiveness needs co-prime parameters of opposite parity.

Change mm once more.

A different exponent can still have a construction

The equation x2+y2=z3x^2+y^2=z^3 is not the Pythagorean equation. A triple cannot simply be relabelled, but complex multiplication gives a useful family of solutions.

Expand (a+bi)3(a+bi)^3. Its real and imaginary parts are a3−3ab2a^3-3ab^2 and 3a2b−b33a^2b-b^3; the squared modulus is (a2+b2)3(a^2+b^2)^3.

A family for a cubic right side

For integers a,ba,b, set

x=a(a2−3b2),y=b(3a2−b2),z=a2+b2.x=a(a^2-3b^2),\quad y=b(3a^2-b^2),\quad z=a^2+b^2.

Then x2+y2=z3x^2+y^2=z^3. Absolute values may be used if positive x,yx,y are required. This constructs solutions; it does not assert that every solution has this form.

Not in the formula booklet: learn it.

Check the actual exponents after construction. The right-hand variable is a cube base, not a hypotenuse.

Worked example 3: a cubic construction

Question. Use a=2,b=1a=2,b=1 to obtain a positive solution of x2+y2=z3x^2+y^2=z^3.

Plan. Calculate the real and imaginary parts of the cube and use its norm.

x=2(4−3)=2real party=1(12−1)=11imaginary partz=4+1=5squared base modulusx2+y2=4+121=125=53verify the target equation\begin{aligned} x&=2(4-3)=2 && \text{real part}\\ y&=1(12-1)=11 && \text{imaginary part}\\ z&=4+1=5 && \text{squared base modulus}\\ x^2+y^2&=4+121=125=5^3 && \text{verify the target equation} \end{aligned}

Why this step? The norm of a cube is the cube of the norm; that is what produces exponent 33 on the right.

Answer. (x,y,z)=(2,11,5)(x,y,z)=(2,11,5).

Check. (2+i)3=2+11i(2+i)^3=2+11i, agreeing with both coordinates.

Keep b=1b=1 and change only aa from 22 to 33.

Worked example 4: no primitive requirement

Question. Construct another solution with a=3,b=1a=3,b=1.

Plan. Apply the same identity, retaining the correct cube base.

x=3(9−3)=18real componenty=1(27−1)=26imaginary componentz=9+1=10cube basex2+y2=324+676=1000=103check\begin{aligned} x&=3(9-3)=18 && \text{real component}\\ y&=1(27-1)=26 && \text{imaginary component}\\ z&=9+1=10 && \text{cube base}\\ x^2+y^2&=324+676=1000=10^3 && \text{check} \end{aligned}

Why this step? There is no primitive-triple condition in this equation; a common factor in the two square bases does not invalidate the solution.

Answer. (18,26,10)(18,26,10).

Check. (3+i)3=18+26i(3+i)^3=18+26i.

Other index patterns can need different constructions. For instance, scaling (3,4,5)(3,4,5) by 55 gives 152+202=252=5415^2+20^2=25^2=5^4, a solution to x2+y2=z4x^2+y^2=z^4. Always substitute into the equation actually asked.

Watch out

Wrong: use (3,4,5)(3,4,5) unchanged for x2+y2=z3x^2+y^2=z^3. Right: 25≠12525\ne125; construct or search for the required powers, then verify them.

Change the same parameter again.

One Pell solution can generate infinitely many

Pell's equation asks for integer points on a hyperbola. An exact search can find the first positive solution; multiplication can then generate further ones without searching every pair.

Pell's equation

For a positive non-square integer DD, Pell's equation is

x2−Dy2=1.x^2-Dy^2=1.

The fundamental positive solution (u,v)(u,v) has the least x>1x>1, with y>0y>0. The pair (1,0)(1,0) is a trivial solution. If unrestricted integer signs are wanted, sign changes of positive solutions also satisfy the equation.

For a small DD, search positive yy in increasing order and test whether 1+Dy21+Dy^2 is a square. Python's isqrt returns the exact integer floor of a square root; test x * x == value rather than trusting a rounded decimal root.

Generating Pell solutions

If (u,v)(u,v) is the fundamental positive solution, the positive solutions are given by

xk+ykD=(u+vD)k,k=1,2,….x_k+y_k\sqrt D=(u+v\sqrt D)^k,\qquad k=1,2,\ldots.

Starting from (x0,y0)=(1,0)(x_0,y_0)=(1,0), use

xk+1=uxk+Dvyk,yk+1=vxk+uyk.x_{k+1}=ux_k+Dvy_k,\qquad y_{k+1}=vx_k+uy_k.

Both right sides use the old pair.

Not in the formula booklet: learn it.

Multiplying by the conjugate shows why each new pair satisfies the equation: (u+vD)(u−vD)=1(u+v\sqrt D)(u-v\sqrt D)=1, so every power also has norm 11. The standard Pell result that a fundamental solution generates every positive solution is used here without developing a continued-fraction algorithm.

Worked example 5: \(D=2\)

Question. Find the fundamental solution of x2−2y2=1x^2-2y^2=1, then the next two positive solutions.

Plan. Check small positive yy, then iterate the fundamental pair.

y=1: x2=3not a squarey=2: x2=9  ⟹  (x,y)=(3,2)first positive solutionx′=3x+4y,y′=2x+3ygeneration rule(3,2)⟼(9+8, 6+6)=(17,12)(17,12)⟼(51+48, 34+36)=(99,70)\begin{aligned} y=1&:\ x^2=3 && \text{not a square}\\ y=2&:\ x^2=9\implies(x,y)=(3,2) && \text{first positive solution}\\ x'&=3x+4y,\quad y'=2x+3y && \text{generation rule}\\ (3,2)&\longmapsto(9+8,\ 6+6)=(17,12)\\ (17,12)&\longmapsto(51+48,\ 34+36)=(99,70) \end{aligned}

Why this step? Searching yy in increasing order also increases x=1+2y2x=\sqrt{1+2y^2}, so the first hit is fundamental.

Answer. (3,2),(17,12),(99,70)(3,2),(17,12),(99,70).

Check. 289−2(144)=1289-2(144)=1, and 9801−2(4900)=19801-2(4900)=1.

Change only the equation parameter from D=2D=2 to D=3D=3. Its fundamental unit and iteration coefficients must change with it.

Worked example 6: \(D=3\)

Question. Find the first three positive solutions of x2−3y2=1x^2-3y^2=1.

Plan. Find the new fundamental pair, then multiply by that same unit repeatedly.

y=1: x2=4  ⟹  (u,v)=(2,1)fundamentalx′=2x+3y,y′=x+2ynew recurrence(2,1)⟼(4+3, 2+2)=(7,4)(7,4)⟼(14+12, 7+8)=(26,15)\begin{aligned} y=1&:\ x^2=4\implies(u,v)=(2,1) && \text{fundamental}\\ x'&=2x+3y,\quad y'=x+2y && \text{new recurrence}\\ (2,1)&\longmapsto(4+3,\ 2+2)=(7,4)\\ (7,4)&\longmapsto(14+12,\ 7+8)=(26,15) \end{aligned}

Why this step? Reusing (3,2)(3,2) from the preceding example would not preserve this new Pell equation.

Answer. (2,1),(7,4),(26,15)(2,1),(7,4),(26,15).

Check. 49−3(16)=149-3(16)=1, and 676−3(225)=1676-3(225)=1.

Predict the three printed pairs. Then change only D, u, v = 2, 3, 2 to D, u, v = 3, 2, 1 and repeat. The simultaneous assignment on the update line uses both old coordinates.

Generate exact Pell solutions

{"code":"D, u, v = 2, 3, 2\nx, y = 1, 0\nfor k in range(3):\n x, y = u * x + D * v * y, v * x + u * y\n print(x, y, x * x - D * y * y)","instructions":"Predict all three pairs and the final check value on each line, then run. Replace the first line by D, u, v = 3, 2, 1 and run again after predicting the new pairs. Leave the simultaneous update unchanged."}

An unbounded search for a fundamental solution can take substantial time for some DD. A bounded search reporting no hit means only that no hit was found within its bound. Positive square DD has no solution with y>0y>0: the integer factors (x−D y)(x+D y)=1(x-\sqrt D\,y)(x+\sqrt D\,y)=1 force y=0y=0.

Watch out

Wrong: update x and then use that new value to update y. Right: use the old pair for both formulas, with simultaneous assignment or saved old coordinates.

Use a supplied fundamental pair for a new equation.

Translate back, including the restrictions

Completing a square often turns an integer-counting problem into Pell's equation. The transformation also creates parity or congruence restrictions; a Pell solution that fails them is not a solution to the original problem.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account