# Generalizing an alternative derivation of distance

I've been playing around with the Pythagorean theorem trying to find equivalent metrics for distance that don't involve squaring and rooting.

From the definition of cosine it's easy to see that, given a triangle with sides $a, b, c$ and angles $A, B, C$, the length $c$ is simply $a*\cos(B) + b*\cos(A)$.

This works on any triangle, not just right triangles.

Now suppose we want to use this formula as a distance metric in Euclidean space. We'll now label the sides $x, y, d$ where we are given x and y and wish to find d.

According to the above, $d = x*\cos(Y) + y*\cos(X)$ if we can find the angles $X, Y$. If we're given orthogonal axes then it is easy to determine that those angles are $X = \tan^{-1}(x/y)$ and $Y =\tan^{-1}(y/x)$.

This gives us the generalized $d = x*\cos(\tan^{-1}(y/x)) + y*\cos(\tan^{-1}(x/y))$ metric for distance.

• This should work even if x and y do not fall on orthogonal axes (though you'll have to find X and Y differently). Is that useful in any way? If so, I'm sure it's been used before. What have I stumbled upon?
• Is there any (elegant) way to show that the above reduces to $\sqrt{x^2+y^2}$ when $x$ and $y$ are on orthogonal axes?
• how can this be generalized to $n$-space? (it's easy to scale the Pythagorean theorem up to $\sqrt{x^2+y^2+z^2}$ and beyond, but I imagine it would be more complex to scale this).
-
What do you mean by "equivalent" here? What do you mean by "generalized"? –  Qiaochu Yuan May 22 '12 at 16:59
Isn't $\cos(\tan^{-1}(y/x))$ always equal to $x\over\sqrt{x^2 + y^2}$ whenever $x\ne 0$? If so, it seems to me that you haven't avoided the squaring and rooting so much as you've swept them under a trigonometric carpet. –  MJD May 22 '12 at 17:09
@MarkDominus I disagree. It depends which one you take as fundamental. Obviously trigonometry and squares are closely related, and obviously you can always transform one into the other, but I'd like to try to derive the Pythagorean theorem from the trig instead of the (more common) inverse. But yes, obviously, the above should reduce to a generalized case of the Pythagorean theorem. –  Nate May 22 '12 at 17:15
@QiaochuYuan it seems unnatural to me that triangular distances are found by extrapolating squares, adding them, and then rooting them. I'm trying to do the same thing but with trig. So by "equivalent" I mean "identical given Cartesian coordinates." By "generalized" I mean this: The Pythagorean theorem works in three-dimensional space. How do you add a z dimension to $x*cos(tan^{-1}(y/x)) + y*cos(tan^{-1}(x/y))$? –  Nate May 22 '12 at 17:17
@Nate: why does that seem unnatural to you? –  Qiaochu Yuan May 22 '12 at 17:23

Is there any (elegant) way to show that $d = x*\cos(\tan^{-1}(y/x)) + y*\cos(\tan^{-1}(x/y))$ reduces to $\sqrt{x^2+y^2}$ when $x$ and $y$ are on orthogonal axes?
First, I don't know that it's safe to claim that your $\tan^{-1}$ expressions are the correct angles if $x$ and $y$ are not orthogonal axes. But, given your expressions, we can do some simplification.
Since you said that $x$ and $y$ are sides, I'll make the assumption that $x,y>0$ (if not, then there are likely to be some issues with the range of the inverse tangent function). We can think of $\tan^{-1}(\frac{x}{y})$ and $\tan^{-1}(\frac{y}{x})$ as the two acute angles in a right triangle with legs $x$ and $y$, as shown. The length of the hypotenuse is $\sqrt{x^2+y^2}$. So, $$\cos\left(\tan^{-1}\left(\frac{y}{x}\right)\right)=\frac{x}{\sqrt{x^2+y^2}}$$ and $$\cos\left(\tan^{-1}\left(\frac{x}{y}\right)\right)=\frac{y}{\sqrt{x^2+y^2}},$$ which makes your distance expression \begin{align} d &= x*\cos(\tan^{-1}(y/x)) + y*\cos(\tan^{-1}(x/y)) \\&=\frac{x^2}{\sqrt{x^2+y^2}}+\frac{y^2}{\sqrt{x^2+y^2}} \\&=\frac{x^2+y^2}{\sqrt{x^2+y^2}} \\&=\frac{\sqrt{x^2+y^2}\cdot\sqrt{x^2+y^2}}{\sqrt{x^2+y^2}} \\&=\sqrt{x^2+y^2}. \end{align}