Suppose a triangle has sides *a*, *b*, and *c*. Label the angles opposite these three sides α, β, and γ respectively.

Edsger Dijkstra published (EWD975) a note proving the following extension of the Pythagorean theorem:

sgn(α + β – γ) = sgn(*a*² + *b*² – *c*²).

Here the sgn function is -1, 0, or 1 depending on whether its input is negative, zero, or positive.

To see that this really is an extension of the Pythagorean theorem, if γ is a right angle, then α + β = γ and so the sgn on the left hand side evaluates to 0. This forces the right hand side to 0, which says *a*² + *b*² = *c*².

As Dijkstra points out, his is a theorem about *triangles*, not simply a theorem about *right* triangles.

I’m not sure if this way of looking at it is useful, since the cosine law has strictly more information.

Since α + β + γ = π, we can rewrite the left hand side as sgn(π – 2γ). And we can use the cosine rule to rewrite the left hand side as sgn(-2ab cos(γ)). Since multiplying by a negative constant flips the sign we can rewrite as

sgn(γ – π/2) = sgn(cos(γ))

and of course this is true in the range 0 < γ < π, which γ must fall in by the convention of how we describe angles in triangles.

Yes! More EWD-related posts please! Thanks! :-)

EWD975 has been (re)published in 2009

http://www.nieuwarchief.nl/serie5/pdf/naw5-2009-10-2-094.pdf

Typo: @2nd para: (EWD975-0) -> (EWD975)

[“-0” is just the number of the first page]