induwara.lk
induwara.lkAI · Linear algebra

Dot Product Calculator

Find the dot product of two vectors in your browser. See the scalar result, each vector's magnitude, the cosine, and the angle between them — with the full element-wise working behind every number. No signup, nothing uploaded.

By Induwara AshinsanaUpdated Jun 10, 2026
Dot product calculator

Numbers separated by commas, spaces, or new lines.

Must have the same number of components as A.

Examples
Dot product A · B
32.0000
Magnitudes
‖A‖ 3.7417
‖B‖ 8.7750 · 3-D
Angle
12.93°
0.2257 rad
Relationship
Acute angle (θ < 90°)
cosθ = 0.9746
Decimals
Angle

Cross-check. The direct sum Σ aᵢbᵢ gives 32.0000; the independent polarisation identity (‖A+B‖² − ‖A‖² − ‖B‖²)/2 — which never multiplies aᵢ by bᵢ — gives 32.0000. They reconcile, as they must.

Step-by-step working

Componentaᵢbᵢaᵢ·bᵢaᵢ²bᵢ²
#11.00004.00004.00001.000016.0000
#22.00005.000010.00004.000025.0000
#33.00006.000018.00009.000036.0000
Totals32.000014.000077.0000
A · B = Σ aᵢbᵢ = 32.0000
‖A‖ = √14.0000 = 3.7417
‖B‖ = √77.0000 = 8.7750
cosθ = 32.0000 / (3.7417 × 8.7750) = 0.9746

Method: A·B = Σ aᵢbᵢ; ‖A‖ = √(Σ aᵢ²); cosθ = (A·B)/(‖A‖‖B‖); θ = arccos(cosθ) — Wolfram MathWorld Dot Product and L2-Norm. Nothing leaves this page.

How it works

The dot product (also called the scalar product or inner product) takes two vectors of the same length and returns a single number. It is the sum of the products of matching components, and it underpins cosine similarity, projections, and most of the geometry used in machine learning. The definitions below follow Wolfram MathWorld and standard linear algebra.

For two equal-length vectors A = [a₁…aₙ] and B = [b₁…bₙ]:

A · B = Σ aᵢbᵢ = a₁b₁ + a₂b₂ + … + aₙbₙ

The tool computes the result and its geometry in four steps:

  1. Dot product. Multiply the vectors component by component and add the results: A · B = Σ aᵢbᵢ. This single number is the scalar product.
  2. Magnitudes.Take the square root of each vector's sum of squares: ‖A‖ = √(Σ aᵢ²) and likewise for ‖B‖ — the Euclidean magnitude, or L2 norm.
  3. Cosine of the angle. Rearranging the geometric identity A · B = ‖A‖‖B‖cosθ gives cosθ = (A·B)/(‖A‖·‖B‖). This is defined only when both magnitudes are non-zero; a zero vector has no direction, so the tool shows a clear note instead of dividing by zero.
  4. Angle. The angle is θ = arccos(cosθ), shown in degrees and radians. The cosine is clamped to [−1, 1] first so floating-point drift never produces an invalid arccos.

The sign of the dot product alone tells you the kind of angle: positive means acute (the vectors broadly agree), zero means orthogonal (perpendicular, a right angle), and negative means obtuse, up to exactly opposite at 180°. As a credibility check, the calculator also recovers the dot product a second, independent way — the polarisation identity A·B = (‖A+B‖² − ‖A‖² − ‖B‖²)/2, which never multiplies aᵢ by bᵢ — and confirms the two routes agree. The dot product is the numerator of cosine similarity, so the cosine similarity and Euclidean distance tools linked below sit in the same family.

Worked examples

General 3-D vectors — A = [1, 2, 3], B = [4, 5, 6]

  1. Dot product: 1·4 + 2·5 + 3·6 = 4 + 10 + 18 = 32
  2. ‖A‖ = √(1 + 4 + 9) = √14 = 3.741657
  3. ‖B‖ = √(16 + 25 + 36) = √77 = 8.774964
  4. cosθ = 32 / (3.741657 × 8.774964) = 32 / 32.832910 = 0.974632
  5. θ = arccos(0.974632) = 0.225726 rad = 12.93° → Acute angle

Orthogonal vectors — A = [2, −1, 3], B = [1, 5, 1]

  1. Dot product: 2·1 + (−1)·5 + 3·1 = 2 − 5 + 3 = 0
  2. ‖A‖ = √(4 + 1 + 9) = √14, ‖B‖ = √(1 + 25 + 1) = √27
  3. cosθ = 0 / (√14 × √27) = 0
  4. θ = arccos(0) = 90.00°
  5. Dot product = 0 → Orthogonal (perpendicular)

Opposite direction — A = [1, 2, 3], B = [−2, −4, −6] (B = −2·A)

  1. Dot product: 1·(−2) + 2·(−4) + 3·(−6) = −2 − 8 − 18 = −28
  2. ‖A‖ = √14, ‖B‖ = √56, product = √784 = 28
  3. cosθ = −28 / 28 = −1
  4. θ = arccos(−1) = 180.00°
  5. Negative dot product, cosθ = −1 → Opposite direction (anti-parallel)

Frequently asked questions

Sources & references

The formulas on this page were last cross-checked against these sources on 2026-06-10. The dot product is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.