# Distance Formula in 3d

Here you will learn distance formula in 3d to calculate distance between two points with example.

Let’s begin –

## Distance Formula in 3d

The distance between the points P$$(x_1, y_1, z_1)$$ and Q$$(x_2, y_2, z_2)$$ is given by

PQ = $$\sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2 + (z_2 – z_1)^2}$$

Proof : Let O be the origin and let P$$(x_1, y_1, z_1)$$ and Q$$(x_2, y_2, z_2)$$ be two given points. Then,

$$\vec{OP}$$ = $$x_1\hat{i} + y_1\hat{j} + z_1\hat{k}$$,  $$\vec{OQ}$$ = $$x_2\hat{i} + y_2\hat{j} + z_2\hat{k}$$

Now,

$$\vec{PQ}$$ = Position vector Q – Position vector of P

$$\implies$$ $$\vec{PQ}$$ = $$x_2\hat{i} + y_2\hat{j} + z_2\hat{k}$$ – $$x_1\hat{i} + y_1\hat{j} + z_1\hat{k}$$

$$\implies$$ $$\vec{PQ}$$ = $$(x_2 – x_1)\hat{i} + (y_2 – y_1)\hat{j} + (z_2 – z_1)\hat{k}$$

$$\therefore$$ PQ = |$$\vec{PQ}$$| = $$\sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2 + (z_2 – z_1)^2}$$

Hence, PQ = $$\sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2 + (z_2 – z_1)^2}$$.

Example : Find the distance between the points P (-2, 4, 1) and Q (1, 2, -5).

Solution : We have,  P (-2, 4, 1) and Q (1, 2, -5).

Distance PQ = $$\sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2 + (z_2 – z_1)^2}$$

$$\implies$$ PQ = $$\sqrt{(1 – (-2))^2 + (2 – 4)^2 + (-5 – 1)^2}$$

$$\implies$$ PQ = $$\sqrt{9 + 4 + 36}$$ = 7 units

Example : Prove by using the distance formula that the points P(1, 2, 3), Q(-1, -1, -1) and R(3, 5, 7) are collinear.

Solution : We have, P(1, 2, 3), Q(-1, -1, -1) and R(3, 5, 7)

Distance Formula = $$\sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2 + (z_2 – z_1)^2}$$

PQ = $$\sqrt{(-1 – 1)^2 + (-2 – 2)^2 + (-1 – 3)^2}$$ =  $$\sqrt{4 + 9 + 16}$$ = $$\sqrt{29}$$ units

QR = $$\sqrt{(3 + 1)^2 + (5 + 1)^2 + (7 + 1)^2}$$ =  $$\sqrt{16 + 36 + 64}$$ = $$\sqrt{116}$$ units

and, PR = $$\sqrt{(3 – 1)^2 + (5 – 2)^2 + (7 – 3)^2}$$ =  $$\sqrt{4 + 9 + 16}$$ = $$\sqrt{29}$$ units

Clearly, QR = PQ + PR.

Therefore, Points P, Q and R are collinear.