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 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 satisfying . It is primitive if . 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 ,
The triple is primitive when 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:
Worked example 1: one parameter pair
Question. Construct the triple from , and decide whether it is primitive.
Plan. Substitute, then check the conditions on the parameters and the resulting sides.
Why this step? The formula guarantees a triple; the extra conditions guarantee primitiveness.
Answer. , primitive.
Check. , and the three sides have no common factor greater than .
Keep and change only to .
Worked example 2: another primitive triple
Question. Construct the triple for .
Plan. Use the same three expressions and check the new parameter pair.
Why this step? The first leg need not be the shorter leg; the equation is symmetric in the legs.
Answer. , primitive.
Check. .
With , the parameters are both odd and give , which is not primitive. With , 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 once more.
A different exponent can still have a construction
The equation is not the Pythagorean equation. A triple cannot simply be relabelled, but complex multiplication gives a useful family of solutions.
Expand . Its real and imaginary parts are and ; the squared modulus is .
A family for a cubic right side
For integers , set
Then . Absolute values may be used if positive 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 to obtain a positive solution of .
Plan. Calculate the real and imaginary parts of the cube and use its norm.
Why this step? The norm of a cube is the cube of the norm; that is what produces exponent on the right.
Answer. .
Check. , agreeing with both coordinates.
Keep and change only from to .
Worked example 4: no primitive requirement
Question. Construct another solution with .
Plan. Apply the same identity, retaining the correct cube base.
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. .
Check. .
Other index patterns can need different constructions. For instance, scaling by gives , a solution to . Always substitute into the equation actually asked.
Watch out
Wrong: use unchanged for . Right: ; 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 , Pell's equation is
The fundamental positive solution has the least , with . The pair is a trivial solution. If unrestricted integer signs are wanted, sign changes of positive solutions also satisfy the equation.
For a small , search positive in increasing order and test whether 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 is the fundamental positive solution, the positive solutions are given by
Starting from , use
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: , so every power also has norm . 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 , then the next two positive solutions.
Plan. Check small positive , then iterate the fundamental pair.
Why this step? Searching in increasing order also increases , so the first hit is fundamental.
Answer. .
Check. , and .
Change only the equation parameter from to . Its fundamental unit and iteration coefficients must change with it.
Worked example 6: \(D=3\)
Question. Find the first three positive solutions of .
Plan. Find the new fundamental pair, then multiply by that same unit repeatedly.
Why this step? Reusing from the preceding example would not preserve this new Pell equation.
Answer. .
Check. , and .
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 . A bounded search reporting no hit means only that no hit was found within its bound. Positive square has no solution with : the integer factors force .
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