# How to calculate distance between two points

Calculating the distance between two points is an essential skill that has immense applications in various fields such as mathematics, physics, and engineering. Whether you’re measuring the distance between two points on a plane, a map, or in space, there are different methods available to achieve this. In this article, we will look at some of the most common techniques for calculating the distance between two points.

**1. Euclidean Distance Formula**

The Euclidean distance formula calculates the straight-line distance between two points in a Cartesian coordinate system. It works for any dimensional space and is derived from the Pythagorean theorem. Here’s how to calculate the Euclidean distance between two points (x1, y1) and (x2, y2):

distance = sqrt((x2 – x1)^2 + (y2 – y1)^2)

To find the Euclidean distance in three-dimensional space, simply include the z-coordinates:

distance = sqrt((x2 – x1)^2 + (y2 – y1)^2 + (z2 – z1)^2)

For example:

Point A: (3, 4)

Point B: (6, 8)

Euclidean distance between A and B = sqrt((6-3)^2 + (8-4)^2) = sqrt(9 + 16) = sqrt(25) = 5

**2. Manhattan Distance**

The Manhattan distance is also known as the taxicab metric or L1 norm. It measures the distance between two points by adding up their absolute differences along each axis separately. Its name comes from its use to estimate the real-world distance of traveling through a grid-based city like Manhattan.

Manhattan distance formula:

distance = |x2 – x1| + |y2 – y1|

For example:

Point A: (3, 4)

Point B: (6, 8)

Manhattan distance between A and B = |6 – 3| + |8 – 4| = 3 + 4 = 7

**3. Haversine Formula**

The Haversine formula is used to calculate the distance between two points on a sphere, such as the Earth’s surface. It uses the latitude and longitude coordinates as well as the great-circle distance, which is the shortest route along the sphere’s surface.

The formula can be expressed as:

a = sin²(difference_latitude/2) + cos(latitude_1) * cos(latitude_2) * sin²(difference_longitude/2)

c = 2 * atan2(sqrt(a), sqrt(1-a))

distance = radius * c

**For example:**

Latitude and Longitude of Point A: (12.9715987, 77.5945627)

Latitude and Longitude of Point B: (19.0759837, 72.8776559)

By plugging in the values into the formula above, you would find the Haversine distance between two points.

**Conclusion**

Now that you are familiar with different methods for calculating distances, you can confidently apply them in various scenarios or solve problems that require distance measurements. Choosing the right technique for a specific problem depends on factors such as coordinate system or practicality of the calculation method, so make sure to consider these when deciding which formula to use.