Generating Approximate Pythagorean Angles (I) – The Method

The next post provides a worked example of the method.

ADDENDUM [20-10-2015]: A slight simplification of the method below is described in an addendum post.

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

A Pythagorean triple (a,b,c) is such that:

a,b,c ∈ ℕ₀ (i.e. are natural numbers ≥ 0), and
a² + b² = c²

A primitive Pythagorean triple (a,b,c) is one such that also

a ⊥ b  (i.e. a and b are coprime, i.e. have no common factors),
a ⊥ c, and
b ⊥ c

that is, a, b and c are pairwise coprime.

The method follows.

The method.

(I use τ = 2π.)

(1) Convert the angles from degrees to radians:

θ = (θ°) × τ / 360
Δθ = (Δθ°) × τ / 360

(2) Calculate the required cosine, and cosine error bound:

C = cos θ
ΔC = sin θ · Δθ

(3) Calculate the Farey ratio approximant and its error bound.

R = \sqrt{\dfrac{1-C}{1+C}}
\Delta R = \dfrac{\Delta C}{(1+C^2) \sqrt{\dfrac{1-C}{1+C}}}

(4) Now iteratively generate Farey ratios to find numbers (u, v) such that (u/v) is ΔR-close to R:

Begin with u₀=0, v₀=1;
and u₂=1, v₂=1.

We have \dfrac{u_0}{v_0} < R < \dfrac{u_2}{v_2}

Produce the mediant (the ‘wrong sum’) u₁ = u₀ + u₂, v₁ = v₀ + v₂.

If \left| \dfrac{u_1}{v_1} - R \right| \le \Delta R
then (u₁,v₁) is the required (u,v)

Otherwise if \dfrac{u_0}{v_0} \le R \le \dfrac{u_1}{v_1},
so let (u₁,v₁) be the new (u₂,v₂), and repeat

Otherwise \dfrac{u_1}{v_1} \le R \le \dfrac{u_2}{v_2}
so let (u₁,v₁) be the new (u₀,v₀), and repeat.

(5) Once the pair (u,v) has been obtained, then:

if u and v are both odd, then let:

a = (v² − u²) / 2,
b = uv,
c = (v² + u²) / 2

otherwise let:

a = v² − u²,
b = 2uv,
c = v² + u²


a² + b² = c²; and
|cos−1(a/c) − θ| ≲ Δθ.

Variations of the Method

There are some variations of step (4).

Rather than stopping as soon as a (u/v) is found, we could continue until we have one such that u₁ and v₁ are not both odd. Beware that later (u₁/v₁) can be further from R (as the lower and upper bounds, (u₀/v₀) and (u₂/v₂) converge on R separately), so the nearness check must be repeated for each new (u/v) generated.

In this variation, the even arm of the triangle is always b.

Another variation is to require that

0 ≤ (u₁/v₁) − R ≤ ΔR

so that

(u₁/v₁) − R ≥ 0
(u₁/v₁) ≥ R

which leads to

cos−1(a/c) ≥ θ

or alternatively that

−ΔR ≤ (u₁/v₁) − R ≤ 0

so that

(u₁/v₁) − R ≤ 0
(u₁/v₁) ≤ R

which leads to

cos−1(a/c) ≤ θ

(This is because both the cosine and the function h are decreasing, and combine to make an increasing function once more.)

The two types of variation may also be combined.

The next post provides a worked example of the method.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: