Cosine Similarity, Angular Distance, Euclidean (L2) & Manhattan (L1) Distance Calculator

Compute Cosine Similarity, angle θ°, L2 Euclidean distance, and L1 Manhattan distance.

Cosine Similarity (cos θ)
0.947 similarity
Cosine Distance (1 − cos θ) 0.053 distance
Euclidean L2 Norm ||u − v||₂ 1.732 L2
Manhattan L1 Norm ||u − v||₁ 3 L1
Inputs
⚡ Scenarios:
u₁
Vector u component 1.
u₂
Vector u component 2.
u₃
Vector u component 3.
v₁
Vector v component 1.
v₂
Vector v component 2.
v₃
Vector v component 3.
Results & Graph
Cosine Similarity (cos θ)
0.947 similarity
Cosine Distance (1 − cos θ)
0.053 distance
Euclidean L2 Norm ||u − v||₂
1.732 L2
Manhattan L1 Norm ||u − v||₁
3 L1

Cosine Similarity (cos θ)

Graph 1 • Cosine Similarity & L1/L2 Distance • Domain Architecture & Live Telemetry Maps U1, U2, U3 through Cosine Similarity & L1/L2 Distance Formula.
Cosine Similarity (cos θ): 0.947 similarity Cosine Similarity & L1/L2 Distance • Invariants & Metrics Cosine Similarity (cos θ) 0.947 similarity Cosine Distance (1 − cos θ) 0.053 distance Euclidean L2 Norm ||u − v||₂ 1.732 L2 Manhattan L1 Norm ||u − v||₁ 3 L1
Graph 2 • Cosine Similarity (cos θ) Across U1 Sweep (40% → 160%) Evaluates CosineSim = (u · v) / (||u||₂ × ||v||₂); L2_Dist = √Σ(u_i − v_i)²; L across 7 operating points (current input highlighted).
0 simila 0.550 simila 1.10 simila 0.813 1.20u₁ 0.875 1.80u₁ 0.919 2.40u₁ 0.947 3u₁ 0.964 3.60u₁ 0.972 4.20u₁ 0.974 4.80u₁
Graph 3 • Joint Sensitivity: U1 × U2 Compares Cosine Similarity (cos θ) when U2 is shifted +25% (solid) vs. −25% (dashed).
0 simila 0.550 simila 1.10 simila --- U2 @ 75% 0.855 -30% 0.886 -15% 0.910 +0% 0.929 +15% 0.943 +30%
Summary: Cosine similarity is 0.9469 (angle θ = 18.76°), Euclidean L2 distance is 1.7321, and Manhattan L1 distance is 3.
Summary: Cosine similarity is 0.9469 (angle θ = 18.76°), Euclidean L2 distance is 1.7321, and Manhattan L1 distance is 3.
Interactive chart & math engine powered by CalculatorGraph

Formula & Mathematical Methodology: Cosine Similarity & L1/L2 Distance Formula

CosineSim = u · v||u||₂ × ||v||₂
L2Dist = √Σ(ui − vi)²
L1Dist = Σ|ui − vi|
CosineSim = (u · v) / (||u||₂ × ||v||₂); L2_Dist = √Σ(u_i − v_i)²; L1_Dist = Σ|u_i − v_i|
  • u1: U1 (u₁)
  • u2: U2 (u₂)
  • u3: U3 (u₃)
  • v1: V1 (v₁)
  • v2: V2 (v₂)
  • v3: V3 (v₃)

Rounding: Internal floating-point calculations run in 64-bit IEEE-754 double precision; display values round to 2–4 decimal places.

Worked Example: Worked Mathematical Example: Cosine Similarity & L1/L2 Distance

Compute Cosine Similarity, angle θ°, L2 Euclidean distance, and L1 Manhattan distance.

  1. Specify the function parameters, matrix entries, or confusion matrix counts.
  2. Apply the closed-form or iterative formula: CosineSim = (u · v) / (||u||₂ × ||v||₂); L2_Dist = √Σ(u_i − v_i)²; L1_Dist = Σ|u_i − v_i|.
  3. Examine the primary result, error bounds, and 3 interactive SVG plots.
Result: Computes Cosine Similarity & L1/L2 Distance via CosineSim = (u · v) / (||u||₂ × ||v||₂); L2_Dist = √Σ(u_i − v_i)²; L1_Dist = Σ|u_i − v_i|.

Frequently Asked Questions

How does the Cosine Similarity, Angular Distance, Euclidean (L2) & Manhattan (L1) Distance Calculator compute the solution?

It evaluates CosineSim = (u · v) / (||u||₂ × ||v||₂); L2_Dist = √Σ(u_i − v_i)²; L1_Dist = Σ|u_i − v_i| directly in your browser and updates three custom SVG visualizations in real time.

Can I solve backwards for an input parameter using Goal Seek?

Yes. Click "🎯 Goal Seek" in the results toolbar to solve backwards for any numeric input field.

Does this calculator run locally offline?

Yes. All calculations run 100% locally in your browser and work offline via the CalculatorGraph PWA.

Mathematics & Statistics · Machine Learning & Classification Metrics

Cosine Similarity, Angular Distance, Euclidean (L2) & Manhattan (L1) Distance Calculator: inputs, method, and how to read the result

Compute Cosine Similarity, angle θ°, L2 Euclidean distance, and L1 Manhattan distance.

Choose inputs for the case you are checking

The defaults are illustrative. Replace them with values for your case and keep the units shown beside each field.

  • U1: Vector u component 1.
  • U2: Vector u component 2.
  • U3: Vector u component 3.
  • V1: Vector v component 1.

What the calculation includes

With the default values shown, Cosine Similarity (cos θ) is 0.947 similarity. The calculation follows Cosine Similarity & L1/L2 Distance Formula; the formula and variable definitions above show how the inputs combine.

One-input check: With the other defaults held constant, changing U1 from 3 u₁ to 4 u₁ changes Cosine Similarity (cos θ) from 0.947 similarity to 0.97 similarity. This is a comparison inside the calculator's stated model, not a prediction.

Where to use caution

  • Uses exact analytical or standard numerical analysis formulations from NIST DLMF.
  • Double-precision floating-point arithmetic has ~15–17 significant decimal digits of precision.

Scope: Global Mathematical & Statistical Standard Check the assumptions and limitations against your situation before relying on the estimate.

More in Mathematics & Statistics: Scientific Calculator, Statistics & Standard Deviation Calculator, Permutations, Combinations, Probability, Sample Size & P-Value Calculator.