In a recent post I described a method of generating 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 Δθ°.

One of the steps was, given the cosine C of the angle [from step (2)]:

(3) Calculate the Farey ratio approximant …

…

Now, that function

seemed semi-familiar, resembling functions that occur in trigonometric or hyperbolic identities.

An example is:

A little further investigation, and reading around, including the Wikipedia articles on trigonometric identities, and in particular on those of the tangent half-angle, revealed that the *Farey ratio approximant* does in fact correspond directly to a simple trigonometric function of the angle:

The slightly simplified method follows.

### The method (simplified)

(I use τ = 2π.)

Steps (1), (4) and (5) are essentially as before, and the variants of (4) described in the earlier post are likewise applicable as before. Step (2½) below replaces steps (2) and (3) in the earlier description.

(1) Convert the angles from degrees to radians:

θ = (θ°) × τ / 360

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

(2½) Calculate the required half-tangent and its error bound:

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

Begin with u₀=0, v₀=1;

and u₂=1, v₂=1.

We have

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

If

then (u₁,v₁) is the required (u,v)

Otherwise if ,

so let (u₁,v₁) be the new (u₂,v₂), and repeat

Otherwise

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²

Now:

a⊥b,

a⊥c,

b⊥c;

a² + b² = c²; and

|cos^{−1}(a/c) − θ| ≲ Δθ.

## Leave a Reply