Probably one of the most general ways to state the Pythagorean theorem is in the context of an inner product space. A modicum of abstract nonsense follows (in the non-technical sense of the word).

So let V be your favourite inner product space or Hilbert space. Mine happens to be at the moment L2(X, dμ), the space of square integrable functions in the measure space X with respect to the measure μ, but if you prefer something more commonplace, you could think of Euclidean space Rn, or even of the plain ol' Euclidean plane R2 of elementary geometry. Take any two orthogonal vectors v and w in V. By definition of orthogonality, <v|w> = 0.

In V, the lengths of v and w are defined by

||v|| := <v|v>1/2

||w|| := <w|w>1/2.

So, if the Pythagorean theorem is translated to the language of vectors, inner products, norms, and such, it should read in this context as

||v - w||2 = ||v||2 + ||w||2.

In other symbols,

<v - w|v - w> = <v|v> + <w|w>.

Is this true? Of course it is! Just recall the axioms of an inner product, linearity and quasi-symmetry (or unqualified symmetry, in case our field of scalars is real) being all that we need. This allows us to write

<v - w|v - w> = <v|v>+ <w|w> - <w|v> - <v|w>,

but <w|v> = <v|w> = 0, since the two vectors are orthgonal. This establishes the Pythagorean theorem.

But wait! We have not yet squeezed all the juice out of this orange. What if the two vectors v and w were not initially orthogonal? Then the two terms being subtracted on the right do not vanish, but instead

<v - w|v - w> = <v|v> + <w|w> - 2Re<v|w>,

where Re denotes the real part. To translate this, recall that the inner product can also be written as Re<v|w> = ||v|| ||w|| cos θ, where θ is the angle between v and w. Thus, we may write,

||v - w||2 = ||v||2 + ||w||2 - 2||v|| ||w|| cos θ

which we recognize to be the Law of Cosines.

Of course, once all the definitions and axioms are understood, everything written above is utterly trivial (in the mathematical sense of the word). In a way, the axioms and definitions are built just so that the Pythagorean theorem holds in an inner product space. Unfortunately, why the definitions are the way they are is not something that can be readily explained, but only comes with experience. One of those things that cannot be taught. Or rather, something that I would not know how to teach.

For another interesting version of the Pythagorean theorem (that probably could be subsumed under the present interpretation if the correct definitions are made), look at the Bessel inequality and Parseval's theorem, sometimes known as Plancherel's theorem. Warning: in those two interpretations the abstract nonsense gets piled higher and deeper, yet the basic idea is still the same, despite initial appearances.