##### Related Content

Programmers and Teachers:

# Distance Formula Calculator

## Distance Formula Lesson

#### Lesson Contents

### What is the Distance Formula?

The distance formula gives us a simple way of finding the distance between two points. It is an expansion of the Pythagorean theorem that allows us to use *x* and *y* coordinates instead of right triangle side lengths. For an in-depth look at the distance formula, see our lesson Distance Formula.

The distance formula can easily be extended to real-world applications. The distance between two points on a map can be calculated if the latitude and longitudes are known and converted to a distance unit such as miles.

The grid maps used by the military for navigation can also be used for distance calculations with the formula. The horizontal and vertical grid lines will be x and y coordinates respectively.

The distance formula also applies when designing a product with computer-aided design (CAD). To connect two parts that form a right angle, simply make the connecting part the length calculated by the distance formula.

### How to Hand Calculate Distance Between Points

There is a 2D distance formula and a 3D distance formula. We use the 2D formula when working in the x-y plane and the 3D distance formula when working in the x-y-z system.

The 2D distance formula is given as:**d =**

The 3D distance formula is given as:**d =**

To hand calculate the distance between points, we simply plug the coordinates into their respective variable in formula.

## How the Calculator Works

The calculator on this page is written in the programming language *JavaScript*. When you click the “calculate” button, the distance formula function is run by your internet browser’s JavaScript engine which provides virtually instant results.

The distance calculation code uses the 2D distance formula given above. Your *x1* input is subtracted from your *x2* input, then squared. The same operation is performed for your *y* inputs. Then, the squares of each difference are summed. The square root of that sum is taken, resulting in the distance between the points.

The raw distance output is rounded to the 4th decimal place before being displayed on this page. If any input errors are caught, an error notice will instead be displayed.