Euclidean Distance is defined as the distance between two points in Euclidean space. To find the distance between two points, the length of the line segment that connects the two points should be measured.
Euclidean distance is like measuring the straightest and shortest path between two points. Imagine you have a string and you stretch it tight between two points on a map; the length of that string is the Euclidean distance. It tells you how far apart the two points are without any turns or bends, just like a bird would fly directly from one spot to another.
This metric is based on the Pythagorean theorem and is widely utilized in various fields such as machine learning, data analysis, computer vision, and more.
.webp)
Consider two points (x1, y1) and (x2, y2) in a 2-dimensional space; the Euclidean Distance between them is given by using the formula:
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
Where,
- d is Euclidean Distance,
- (x1, y1) is the Coordinate of the first point,
- (x2, y2) is the Coordinate of the second point.
Euclidean Distance in 3D
If the two points (x1, y1, z1) and (x2, y2, z2) are in a 3-dimensional space, the Euclidean Distance between them is given by using the formula:
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2+ (z_2 - z_1)^2}
Where,
- d is Euclidean Distance,
- (x1, y1, z1) is the Coordinate of the first point,
- (x2, y2, z2) is the Coordinate of the second point.
Euclidean Distance in nD
In general, the Euclidean Distance formula between two points (x11, x12, x13, ...., x1n) and (x21, x22, x23, ...., x2n) in an n-dimensional space is given by the formula:
d = \sqrt{∑^{n}_{i=1}(x_{2i} – x_{1i})^2}
Where,
- i Ranges from 1 to n,
- d is Euclidean distance,
- (x11, x12, x13, ...., x1n) is the Coordinate of the First Point,
- (x21, x22, x23, ...., x2n) is the Coordinate of the Second Point.
Euclidean Distance Formula is derived by following the steps added below:
- Step 1: Let us consider two points, A (x1, y1) and B (x2, y2), and d is the distance between the two points.
- Step 2: Join the points using a straight line (AB).
- Step 3: Now, let us construct a right-angled triangle whose hypotenuse is AB, as shown in the figure below.

Step 4: Now, using Pythagoras theorem we know that,
(Hypotenuse)2 = (Base)2 + (Perpendicular)2
⇒ d 2 = (x2 – x1) 2 + (y2 – y1) 2
Now, take the square root on both sides of the equation, and we get the Euclidean distance d.
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
Also Read:
Euclidean Distance Vs Manhattan Distance
Differences between the Euclidean and Manhattan distances are listed in the following table:
Aspect | Euclidean Distance | Manhattan Distance |
---|
Definition | Measures the shortest straight-line distance between two points. | Measures the distance between two points along axes at right angles. |
---|
Formula (2D) | d = √[(x2 - x1)2 + (y2 - y1)2] | d = [|x2 - x1| + |y2 - y1|] |
---|
Path | Direct straight line. | The path that resembles city blocks or a grid pattern. |
---|
Metric Name | L2 norm or Euclidean norm. | L1 norm or Manhattan norm. |
---|
Use Cases | Used in scenarios where direct distances are needed (e.g., physics). | Commonly used in planning, urban design, and certain optimization algorithms. |
---|
Sensitivity to Scaling | Less sensitive to the scaling of axes. | More sensitive to the scaling of axes since it adds absolute differences. |
---|
Read More:
Solved Questions on Euclidean Distance
Here are some sample questions based on the Euclidean distance formula to help you understand the application of the formula in a better way-
Question 1: Calculate the distance between the points (4,1) and (3,0).
Using Euclidean Distance Formula:
⇒ d = √(x2 – x1)2 + (y2 – y1)2
⇒ d = √(3 – 4)2 + (0 – 1)2
⇒ d = √(1 + 1)
⇒ d = √2 = 1.414 unit
Question 2: Show that the points A (0, 0), B (4, 0), and C (2, 2√3) are the vertices of an Equilateral Triangle.
To prove that these three points form an equilateral triangle, we need to show that the distances between all pairs of points, i.e., AB, BC, and CA, are equal.
Distance between points A and B:
AB = √[(4– 0)2 + (0-0)2]
⇒ AB = √16
AB = 4 unit
Distance between points B and C:
BC = √[(2-4)^2 + (2√3-0)^2]
⇒ BC = √[4+12] = √16
BC = 4 unit
Distance between points C and A:
CA = √[(0-2)2 + (0-2√3)2]
⇒ CA = √[4 + 12] = √16
CA = 4 unit
Here, we can observe that all three distances, AB, BC, and CA, are equal.
Therefore, the given triangle is an Equilateral Triangle
Question 3: Mathematically prove Euclidean distance is a non negative value.
Consider two points (x1, y1) and (x2, y2) in a 2-dimensional space; the Euclidean Distance between them is given by using the formula:
d = √(x2 – x1)2 + (y2 – y1)2
We know that squares of real numbers are always non-negative.
⇒(x2 – x1)2 >= 0 and (y2 – y1)2 >= 0
⇒ √(x2 – x1)2 + (y2 – y1)2 >= 0
As square root of a non-negative number gives a non-negative number,
Therefore Euclidean distance is a non-negative value. It cannot be a negative number.
Question 4: A triangle has vertices at points A(2, 3), B(5, 7), and C(8, 1). Find the length of the longest side of the triangle.
Given, the points A(2, 3), B(5, 7), and C(8, 1) are the vertices of a triangle.
Distance between points A and B:
AB = √[(5-2)2 + (7-3)2]
⇒ AB = √9+16= √25
AB = 5 unit
Distance between points B and C:
BC = √[(8-5)2 + (1-7)2]
⇒ BC = √[9+36] = √45
BC = 6.708 unit
Distance between points C and A:
CA = √[(8-2)2 + (1-3)2]
⇒ CA = √[36+4] = √40
CA = 6.325 unit
Therefore, the length of the longest side of triangle is 6.708 unit.
Practice Problems on Euclidean Distance
These Practice Problems on Euclidean Distance will help you to test your understanding of the concept:
Problem 1: Calculate the Euclidean distance between points P(1, 8, 3) and Q(6, 6, 8).
Problem 2: A car travels from point A(0, 0) to point B(5, 12). Calculate the distance traveled by the car.
Problem 3: An airplane flies from point P(0, 0, 0) to point Q(100, 200, 300). Calculate the distance traveled by the airplane.
Problem 4: A triangle has vertices at points M(1, 2), N(4, 6), and O(7, 3). Find the perimeter of the triangle.
Problem 5: On a graph with points K(2, 3) and L(5, 7), plot these points and calculate the Euclidean distance between them.
Problem 6: A drone needs to fly from point A(1, 1) to point B(10, 10). Find the shortest path the drone should take to conserve battery?
Problem 7: A robotic arm moves from position J(1, 2, 3) to position K(4, 5, 6). Calculate the total distance traveled by the robotic arm.
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i
6 min read
Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc
15+ min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
What is an Operating System? An Operating System is a System software that manages all the resources of the computing device. Acts as an interface between the software and different parts of the computer or the computer hardware. Manages the overall resources and operations of the computer. Controls and monitors the execution o
5 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
Python Functions Python Functions is a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over an
9 min read