Vector Distance Calculator

Compute distance and angle between any two n-dimensional vectors.

abθO

Euclidean vector distance

d(a, b) = Σ (aᵢ − bᵢ)²

Enter two vectors (up to 6 dimensions)

Vector a

Vector b

What is vector distance?

A vector is an ordered tuple of numbers — a list of coordinates in n-dimensional space — and 'distance' between two vectors quantifies how dissimilar those two tuples are. Different definitions of distance measure dissimilarity in different ways: Euclidean distance captures the straight-line gap in space, Manhattan distance captures the sum of axis-aligned steps, Chebyshev distance captures the largest single-axis gap, and cosine similarity captures angular alignment regardless of magnitude.

Vector distances are core building blocks in machine learning (k-nearest-neighbour, k-means clustering, embedding-based search), recommender systems, document retrieval (cosine similarity on TF-IDF or embedding vectors), computer vision (image-feature matching), bioinformatics (sequence-feature comparison), and dozens of other fields. Picking the right metric for your data — symmetric vs asymmetric, magnitude-sensitive vs direction-only — is often more important than tuning the algorithm itself.

How the vector calculator works

Enter both vectors

Type the components of vectors a and b. The calculator supports up to 6 dimensions and treats missing components as 0.

Read every metric

Euclidean, Manhattan, Chebyshev, Minkowski-3, cosine similarity, cosine distance, dot product, and the angle between the vectors — all reported simultaneously.

Inspect the classification

A one-word verdict (Identical, Parallel, Orthogonal, Acute, Obtuse) summarises the angular relationship between the two vectors.

Step through the math

The step-by-step section shows how every metric was computed so you can use the panel as a teaching tool.

Formulas inside this tool

Euclidean (L₂)

d = √Σ(aᵢ − bᵢ)²

Straight-line distance in n-D — the default 'distance'.

Manhattan (L₁)

d₁ = Σ|aᵢ − bᵢ|

Sum of axis-aligned steps, like a taxi on a grid.

Chebyshev (L∞)

d∞ = max |aᵢ − bᵢ|

Largest single-axis gap — like a king on a chessboard.

Minkowski (Lₚ)

dₚ = (Σ|aᵢ − bᵢ|ᵖ)^(1/p)

Family of distances interpolating between L₁, L₂, and L∞.

Cosine similarity

cos θ = (a · b) / (‖a‖ ‖b‖)

Angular similarity ignoring magnitudes.

Cosine distance

d = 1 − cos θ

Bounded in [0, 2], 0 for identical direction, 1 for orthogonal.

Real-world uses

Recommender systems

Netflix-style recommendations compute cosine similarity between user-rating vectors to find users with the most similar taste.

Document search

Search engines and modern retrieval-augmented generation tools compare embedding vectors of query and document using cosine similarity.

k-Nearest-Neighbour classification

kNN classifiers identify the k closest training vectors in Euclidean (or other) distance and vote for a label.

Clustering

k-means assigns each point to the cluster whose centroid is closest in Euclidean distance, iteratively refining the partition.

Why use this calculator?

Picking the right distance metric for a data-science problem is mostly experience — and getting a quick comparison between Euclidean, Manhattan, Chebyshev, and cosine for a sample pair of vectors is the fastest way to build that experience. This tool lets you tinker with toy vectors and see how the metrics differ, before plugging the chosen one into a much larger pipeline.

Frequently Asked Questions

A measure of how far apart two vectors are in n-dimensional space. The most common is Euclidean distance — the straight line between the two endpoints — but other distance metrics like Manhattan, Chebyshev, and Minkowski capture different ideas of 'how far'.

Euclidean: straight line, √Σ(aᵢ − bᵢ)². Manhattan: sum of axis-aligned steps Σ|aᵢ − bᵢ| — like a taxi on a grid. Chebyshev: the largest single-axis gap max|aᵢ − bᵢ| — like a king moving on a chessboard. Each measures distance differently and is preferred in different settings.

A generalisation: dₚ = (Σ|aᵢ − bᵢ|ᵖ)^(1/p). Setting p = 1 recovers Manhattan; p = 2 gives Euclidean; p → ∞ gives Chebyshev. Choosing p between these values gives 'shaped' notions of distance used by some machine-learning algorithms.

cos θ = (a · b) / (‖a‖ ‖b‖). It is the cosine of the angle between two vectors and measures how similarly oriented they are, ignoring magnitude. +1 means identical direction, 0 means orthogonal, −1 means exact opposite direction.

When magnitude is irrelevant and only direction matters — e.g. comparing two text documents represented as word-frequency vectors. Cosine similarity treats a long document and a short document on the same topic as similar, whereas Euclidean distance would put them far apart simply because the long one has bigger counts.

a · b = Σ aᵢ bᵢ. Geometrically it equals ‖a‖ · ‖b‖ · cos θ, so it captures both the magnitudes of the vectors and the angle between them. A positive dot product means the vectors lean in the same direction; zero means they are orthogonal; negative means they oppose.

Cosine distance = 1 − cosine similarity. Zero distance means cosine similarity is 1, which means the two vectors point in exactly the same direction. They might still have very different lengths.

Yes — all the formulas extend naturally to any number of dimensions. This calculator supports up to 6 coordinates per vector via the UI. In practice, machine-learning algorithms operate on vectors with hundreds or thousands of dimensions using the same definitions.

‖v‖₂ = √Σ vᵢ² — the standard 'length' of a vector. The Euclidean distance between two vectors a and b is exactly the L2 norm of their difference: ‖a − b‖₂.

Euclidean distance powers k-nearest-neighbour classifiers and k-means clustering. Cosine similarity drives most recommendation engines and document-search retrieval. Manhattan distance is the workhorse of L1-regularised models like Lasso regression.