In the previous post is a table of values.

Suppose you wish to find the simplest primitive Pythagorean triangle (a,b,c) where one of the angles is θ° to within some (small) error bound Δθ°.

Here’s the derivation of the method which was given in an earlier post.

(Throughout, I use τ = 2π.)

It is well known that all *primitive* Pythagorean triads (a,b,c) may be generated by pairs (u,v) where:

u, v ∈ ℕ₀ — i.e. u and v are non-negative integers,

u < v,

u ⊥ v — i.e. u and v are coprime, i.e. have no common factors, and

u + v ≡ 1 (mod 2) — i.e. u and v have different parity, i.e. one is even, and the other odd

and then

a = v² − u²,

b = 2uv, and

c = u² + v²

In this case:

a is odd

b is even

c is odd

[ref.: Euclid’s Formula for Generating Pythagorean Triples and Primitive Pythagorean Triples on Wikipedia.]

That is essentially step (5).

It is additionally required to show that if

u, v ∈ ℕ₀,

u < v,

u ⊥ v, and

u, v ≡ 1 (mod 2) — i.e. u and v are both odd

and then

a = (v² − u²) / 2,

b = uv, and

c = (u² + v²) / 2

then a, b and c are natural numbers, and (a,b,c) is again primitive.

In this case:

a is even,

b is odd, and

c is odd

Proof of the parities:

u, v ≡ 1 (mod 2)

so

uv ≡ 1 (mod 2)

u, v ≡ 1 or 3 (mod 4)

so

u², v² ≡ 1 (mod 4)

so

v² − u² ≡ 0 (mod 4)

v² + u² ≡ 2 (mod 4)

so

(v² − u²) / 2 ≡ 0 (mod 2),

(v² + u²) / 2 ≡ 1 (mod 2)

QED ■

Proof of the primitiveness:

We already have that

2 | a but

2 ∤ b, c

Now consider a prime p > 2

Suppose

p | a, c

then

p | (v² − u²)/2, (v² + u²)/2

p | u², v²

but p is prime, so

p | u, v

which is a contradiction.

Now suppose

p | b

then

p | u, v

but p is prime so

either p | u or p | v

but not both since u ⊥ v,

so

p | u xor p | v (where xor means “or, but not both”)

so

p | u² xor p | v²

so

p ∤ v² − u² and p ∤ v² + u²

so

p ∤ 2a and p ∤ 2c

so

p ∤ a and p ∤ c

QED ■

The cosine of the angle opposite arm b is:

cos θ = a / c

Notice that for 0° ≤ θ° ≤ 90°, we have 0 ≤ cos θ° ≤ 1,

Notice also that 0 ≤ u/v ≤ 1.

Since

then the cosine, x = cos θ, is a simple function of the ratio y = u/v:

and so, inverting the function, the ratio is a function of the cosine:

The functions g and h are both considered as functions on the range [0,1], i.e. functions from [0,1] to [0,1].

They are monotonic (decreasing) over that range, which allows the inverses to be meaningful.

The function h is used in step (3) of the method.

(3) Calculate the Farey ratio approximant …

When considering an error (magnitude) in x, we make use of the approximation

Δy ≈ |df(x)/dx| · Δx

This is required for steps (2) and (3):

C = cos θ

so

ΔC = | d cos θ / dθ | · Δθ = | −sin θ | · Δθ = sin θ · Δθ

(for 0° ≤ θ° ≤ 90°)

Similarly:

so

Thus all that’s left to do is to find a fraction u/v such that

| R − u/v | ≤ ΔR

That’s step (4), which makes use of Farey sequences and mediants.

If:

u₀ ⊥ v₀

u₂ ⊥ v₂

u₂·v₀ − u₀·v₂ = 1

And:

u₁ = u₀ + u₂

v₁ = v₀ + v₂

Then:

i.e.

u₁ ⊥ v₁

u₁·v₀ − u₀·v₁ = 1

u₂·v₁ − u₁·v₂ = 1

[ref.: Farey Neighbours on Wikipedia.]

[ref.: Properties of the Mediant on Wikipedia.]

In the previous post is a table of values.

## Leave a Reply