The angle in radians between two vectors is found using the dot product formula: take the dot product of the two vectors, divide it by the product of their magnitudes, then apply the inverse cosine (arccos) to the result. The formula is θ = arccos((a · b) / (‖a‖ ‖b‖)), and the answer always falls between 0 and π radians (0° to 180°).
The Core Formula
The relationship between the dot product and the angle comes from this identity:
a · b = ‖a‖ ‖b‖ cos(θ)
Rearranging to solve for the angle gives you:
cos(θ) = (a · b) / (‖a‖ ‖b‖)
θ = arccos((a · b) / (‖a‖ ‖b‖))
This works in any number of dimensions, not just 2D or 3D. Two vectors in five-dimensional or hundred-dimensional space still span a plane between them, and the law of cosines still applies within that plane. The formula stays exactly the same.
Step-by-Step Calculation
There are three pieces you need before you can find the angle: the dot product of the two vectors, the magnitude of each vector, and a calculator that can compute arccos in radians. Here’s the process broken down.
1. Compute the Dot Product
Multiply matching components and add the results. For two 2D vectors a = (a₁, a₂) and b = (b₁, b₂), the dot product is a₁b₁ + a₂b₂. For 3D vectors, you add a third term: a₁b₁ + a₂b₂ + a₃b₃.
2. Compute Each Magnitude
The magnitude of a vector is the square root of the sum of its squared components. For a = (a₁, a₂), that’s √(a₁² + a₂²).
3. Divide and Take Arccos
Divide the dot product by the product of the two magnitudes. This gives you cos(θ), a value between -1 and 1. Then take the inverse cosine to get θ in radians.
Worked Example
Suppose a = (100, 50) and b = (90, -70).
The dot product is (100 × 90) + (50 × -70) = 9000 – 3500 = 5500.
The magnitude of a is √(100² + 50²) = √12500 ≈ 111.80. The magnitude of b is √(90² + 70²) = √13000 ≈ 114.02.
Dividing gives cos(θ) = 5500 / (111.80 × 114.02) ≈ 0.431.
Finally, θ = arccos(0.431) ≈ 1.124 radians, which is roughly 64.4°.
Special Angles to Recognize
A few common results are worth memorizing because they come up constantly in math and physics:
- θ = 0 radians (0°): The vectors point in exactly the same direction. The dot product equals the product of the magnitudes, so cos(θ) = 1.
- θ = π/2 radians (90°): The vectors are perpendicular (orthogonal). The dot product is zero. This is one of the fastest checks in linear algebra: if a · b = 0, the vectors are at right angles.
- θ = π radians (180°): The vectors point in exactly opposite directions (antiparallel). The dot product equals the negative of the product of the magnitudes, so cos(θ) = -1.
Converting Between Degrees and Radians
If your calculator returns degrees and you need radians, multiply by π/180. Going the other way, multiply radians by 180/π. For quick reference: π radians = 180°, π/2 ≈ 1.5708 radians = 90°, and π/4 ≈ 0.7854 radians = 45°.
Most scientific calculators and programming languages let you choose which unit you want. Make sure you know which mode you’re in before reading the output of an arccos function.
Computing the Angle in Code
In Python with NumPy, you can calculate the angle between two vectors in a few lines:
import numpy as np
a = np.array([100, 50])
b = np.array([90, -70])
cos_theta = np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
theta = np.arccos(np.clip(cos_theta, -1, 1))
The np.clip step is a practical safeguard. Floating-point arithmetic can sometimes produce a value like 1.0000000002, which would cause arccos to throw an error. Clipping to the range [-1, 1] prevents that.
The result, theta, is in radians by default. NumPy’s arccos always returns radians unless you convert with np.degrees().
Cosine Similarity and the Angle
In data science and machine learning, the same formula appears under a different name: cosine similarity. It’s defined as the dot product divided by the product of magnitudes, which is simply cos(θ). A cosine similarity of 1 means the vectors point the same way (θ = 0), 0 means they’re perpendicular (θ = π/2), and -1 means they point in opposite directions (θ = π).
If you need an actual distance metric rather than a similarity score, you can convert cosine similarity to angular distance by dividing the angle by π. This normalizes the result to a 0-to-1 scale, where 0 means identical direction and 1 means opposite directions.

