MathorynMathematical Formula Database

Linear Algebra

Angle Between Two Vectors

The angle between two nonzero vectors follows from the dot product. A result of 90∘90^\circ means the vectors are orthogonal. Use it in geometry, physics and machine learning (cosine similarity) to compare directions.

cos⁡θ=a⋅b∣a∣ ∣b∣\cos\theta=\frac{\mathbf a\cdot\mathbf b}{|\mathbf a|\,|\mathbf b|}
LaTeX\cos\theta=\frac{\mathbf a\cdot\mathbf b}{|\mathbf a|\,|\mathbf b|}

Variables

θ\theta
angle between the vectors, 0 to 180°

Example

Angle between (1,0)(1,0) and (1,1)(1,1).

  1. cos⁡θ=11⋅2\cos\theta=\frac{1}{1\cdot\sqrt2}.

Answer: θ=45∘\theta=45^\circ.

Related formulas