# Distance Formula/3 Dimensions

## Theorem

The distance $d$ between two points $A = \tuple {x_1, y_1, z_1}$ and $B = \tuple {x_2, y_2, z_2}$ in a Cartesian space of 3 dimensions is:

$d = \sqrt {\paren {x_1 - x_2}^2 + \paren {y_1 - y_2}^2 + \paren {z_1 - z_2}^2}$

Hence $d$ is the length of the straight line segment $AB$.

## Proof

Let $d$ be the distance to be found between $A = \tuple {x_1, y_1, z_1}$ and $B = \tuple {x_2, y_2, z_2}$.

Let the points $C$ and $D$ be defined as:

$C = \tuple {x_2, y_1, z_1}$
$D = \tuple {x_2, y_2, z_1}$

Let $d'$ be the distance between $A$ and $D$.

From Distance Formula, it can be seen that:

$d' = \sqrt {\paren {x_1 - x_2}^2 + \paren {y_1 - y_2}^2}$

We note that $\triangle ADB$ is a right triangle.

Thus by Pythagoras's Theorem:

$AB^2 = AD^2 + DB^2$

Thus:

 $\ds d^2$ $=$ $\ds d'^2 + DB^2$ $\ds$ $=$ $\ds \paren {x_1 - x_2}^2 + \paren {y_1 - y_2}^2 + \paren {z_1 - z_2}^2$

and so:

$d = \sqrt {\paren {x_1 - x_2}^2 + \paren {y_1 - y_2}^2 + \paren {z_1 - z_2}^2}$

as it was to be proved.

$\blacksquare$