Find the angle between two vectors
Type the components of two vectors with the same number of components. The page finds the angle between the two vectors in degrees and radians, and says whether they are perpendicular or parallel.
- Angle θ
- 107.975284
The angle between ⟨1, 1, 1⟩ and ⟨2, −1, −3⟩ is 107.975284°.
- Angle in radians
- 1.884524
- cos θ
- -0.308607
- Dot product a·b
- -2
- Length ‖a‖
- 1.732051
- Length ‖b‖
- 3.741657
- Vectors
- ⟨1, 1, 1⟩ and ⟨2, −1, −3⟩
- The vectors are
- at an obtuse angle
Angle θ: 107.975284. The angle between ⟨1, 1, 1⟩ and ⟨2, −1, −3⟩ is 107.975284°.
How to calculate
Finds the angle between two vectors in 2D, 3D or up to 10 dimensions, in degrees and radians, with the dot product, the lengths, cos θ, and whether they are perpendicular or parallel.
Example with the default inputs (Vector a [1, 1, 1], Vector b [2, -1, -3]): The angle between ⟨1, 1, 1⟩ and ⟨2, −1, −3⟩ is 107.975284°.
Method: cos θ = a·b ÷ (‖a‖‖b‖); θ = 2·atan2(‖â − b̂‖, ‖â + b̂‖) with â = a ÷ ‖a‖ and b̂ = b ÷ ‖b‖ (the same angle, precise near 0° and 180°).
- The angle is the smaller one between the two directions, from 0° to 180°.
- Both vectors have the same number of components (2 to 10) and neither is the zero vector.
- Perpendicular (a·b = 0) and parallel ((a·b)² = ‖a‖²‖b‖²) are decided exactly from the numbers as typed.
Worked examples
Each example is checked against the calculator on every build.
- Vector a 1, 1, 1, Vector b 2, -1, -3 gives Angle θ 107.975284, Angle in radians 1.884524, cos θ -0.308607, Dot product a·b -2, The vectors are at an obtuse angle.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
- Vector a 2, 5, 6, Vector b -2, -4, 4 gives Angle θ 90, Angle in radians 1.570796, Dot product a·b 0, The vectors are perpendicular (orthogonal).Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
- Vector a 3, 4, Vector b 4, 3 gives Angle θ 16.260205, Dot product a·b 24, cos θ 0.96, Length ‖a‖ 5, Length ‖b‖ 5.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
- Vector a 1, 2, Vector b -2, -4 gives Angle θ 180, The vectors are parallel, pointing opposite ways.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
How it works
For two vectors a = ⟨a₁, …, aₙ⟩ and b = ⟨b₁, …, bₙ⟩:
- Dot product: a·b = a₁b₁ + a₂b₂ + … + aₙbₙ.
- Lengths: ‖a‖ = √(a₁² + … + aₙ²) and ‖b‖ the same way.
- cos θ = a·b ÷ (‖a‖‖b‖), from −1 to 1.
- Angle: θ = arccos(cos θ), from 0 to π radians (0° to 180°). Degrees = radians × 180 ÷ π.
The page works the angle out with an equal form that stays precise for very small angles and angles near 180°: with the unit vectors â = a ÷ ‖a‖ and b̂ = b ÷ ‖b‖, θ = 2·atan2(‖â − b̂‖, ‖â + b̂‖). Each vector is first divided by its largest component (in absolute value), which does not change its direction.
Rules
- Both vectors have 2 to 10 components, and the same number; otherwise there is no answer.
- A zero vector (every component 0) has no answer.
- Perpendicular: when a·b = 0 exactly, computed from the numbers as typed (0.1 is exactly one tenth). The angle is then exactly 90° (π ÷ 2 radians) and cos θ is 0.
- Parallel: when (a·b)² = ‖a‖²‖b‖² exactly. The angle is exactly 0° and cos θ is 1 when a·b > 0 ("pointing the same way"), and exactly 180° (π radians) and cos θ is −1 when a·b < 0 ("pointing opposite ways").
- Otherwise the vectors are "at an acute angle" when a·b > 0 and "at an obtuse angle" when a·b < 0.
- The dot product and the lengths are left out when they are beyond the largest double-precision number; the angle still shows.
Output format. Angles, cos θ, the dot product and the lengths are double-precision numbers. "Vectors" writes the two vectors as ⟨1, 1, 1⟩ and ⟨2, −1, −3⟩, each component to 6 significant digits, trailing zeros dropped, with a true minus sign (−), also in an exponent.
Worked examples by hand
a = ⟨1, 1, 1⟩, b = ⟨2, −1, −3⟩. a·b = 2 − 1 − 3 = −2. ‖a‖ = √3, ‖b‖ = √14, so cos θ = −2 ÷ √42 = −0.308607. θ = arccos(−0.308607) = 1.884524 rad = 107.9753°, an obtuse angle.
a = ⟨2, 5, 6⟩, b = ⟨−2, −4, 4⟩. a·b = −4 − 20 + 24 = 0, so the vectors are perpendicular and θ = 90°.
a = ⟨3, 4⟩, b = ⟨4, 3⟩. a·b = 12 + 12 = 24. ‖a‖ = ‖b‖ = 5. cos θ = 24 ÷ 25 = 0.96, θ = 16.2602°.
a = ⟨1, 2⟩, b = ⟨−2, −4⟩. b = −2a, a·b = −10 and (a·b)² = 100 = 5 × 20 = ‖a‖²‖b‖², so the vectors are parallel and point opposite ways: θ = 180°.
Other questions people ask
How do I find the angle between two vectors?
Divide the dot product by the product of the lengths to get cos θ, then take the inverse cosine: θ = arccos(a·b ÷ (‖a‖‖b‖)). For ⟨3, 4⟩ and ⟨4, 3⟩, a·b = 24 and ‖a‖‖b‖ = 25, so θ = arccos 0.96 ≈ 16.26°.
What is the angle between i + j + k and 2i − j − 3k?
The dot product is 2 − 1 − 3 = −2, the lengths are √3 and √14, so cos θ = −2 ÷ √42 and θ ≈ 107.98° (1.8845 radians). This is Example 2.23 in OpenStax Calculus Volume 3.
How do I know if two vectors are perpendicular?
Their dot product is 0, so cos θ = 0 and θ = 90°. ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ give −4 − 20 + 24 = 0, so they are orthogonal.
How do I know if two vectors are parallel?
One is a multiple of the other, so the angle is 0° (same way) or 180° (opposite ways). ⟨1, 2⟩ and ⟨−2, −4⟩ are opposite: b = −2a and θ = 180°.
Can the angle be more than 180°?
No. The angle between two vectors is the smaller of the two angles between their directions, from 0° to 180°. An obtuse angle (over 90°) means the dot product is negative.
Why can I not use a zero vector?
The zero vector has length 0 and no direction, so cos θ would divide by 0. The page gives no answer for it.