Cosine works in any dimension
The same dot-over-magnitudes formula compares 2D arrows, 3D forces, or 1,536-D text embeddings—angle is dimension-agnostic.
Vector a: Components
Vector b: Components
Vector a: Components
Vector b: Components
Vector a: Components
Vector b: Components
Vector a from Point A to Point B
Vector b from Point C to Point D
Vector a from Point A to Point B
Vector b from Point C to Point D
Vector a from Point A to Point B
Vector b from Point C to Point D
Formula: θ = arccos((a·b)/(||a||·||b||)) for non-zero vectors. We clamp the ratio to [-1,1] to avoid NaN from rounding.
Press Enter in any field to compute.
In 2D mode, shows a, b, and the measured angle. 3D and 4D results are calculated numerically.
a and vector b, or enter the initial and terminal points for each vector.For nonzero vectors a and b, the angle θ is found from the dot-product identity:
cos θ = (a · b) / (||a|| ||b||)
θ = arccos((a · b) / (||a|| ||b||))
The result is between 0° and 180°. The calculator clamps the cosine value to [-1, 1] before taking arccos to avoid floating-point rounding errors.
Let a = (3, 1) and b = (2, 4).
Dot product: a · b = 3·2 + 1·4 = 10
Magnitudes: ||a|| = √(3² + 1²) = √10 and ||b|| = √(2² + 4²) = √20
Substitute: cos θ = 10 / (√10 · √20) = 1 / √2 ≈ 0.7071
Take arccos: θ = arccos(0.7071) ≈ 0.7854 rad = 45°
Let a = (1, 2, 3) and b = (4, -5, 6).
First compute the dot product:
a · b = 1·4 + 2·(-5) + 3·6 = 4 - 10 + 18 = 12
Now compute the magnitudes:
||a|| = √(1² + 2² + 3²) = √14
||b|| = √(4² + (-5)² + 6²) = √77
Then substitute into the formula:
cos θ = 12 / (√14 · √77)
θ = arccos(12 / √1078) ≈ 68.58°
If your vectors are given by points, subtract the initial point from the terminal point first.
For example, if vector a goes from A(1, 2) to B(4, 6), then a = B - A = (4 - 1, 6 - 2) = (3, 4).
In 3D or 4D, use the same idea: subtract each starting coordinate from the matching ending coordinate. A 4D vector from A(x1, y1, z1, w1) to B(x2, y2, z2, w2) is (x2 - x1, y2 - y1, z2 - z1, w2 - w1).
-1 to 1.||a|| = 0 or ||b|| = 0, the angle is undefined.For more vector work, use the related tools above to find vector projections, dot products, cross products, and 2D or 3D distances.
Use θ = arccos((a·b)/(||a||·||b||)) for nonzero vectors.
Yes. Choose Two points, enter the initial and terminal point for each vector, and the calculator converts each pair into a vector.
Yes. Choose 3D or 4D to enter the matching number of components per vector or coordinates per point.
No. Cosine similarity is cos θ. The angle is found by taking arccos of that value.
The same dot-over-magnitudes formula compares 2D arrows, 3D forces, or 1,536-D text embeddings—angle is dimension-agnostic.
Multiply either vector by a positive number and the angle stays identical. That’s why cosine similarity ignores “loudness” and keeps only direction.
In 3D, ||a×b|| = ||a||·||b||·sin θ. Tiny cross magnitude? Nearly parallel. Max cross magnitude? Near 90° and the parallelogram area is huge.
In 2D, the scalar “cross” aₓbᵧ − aᵧbₓ is positive if you rotate counter-clockwise from a to b, negative if clockwise—a quick left/right test.
Smooth rotations (spherical linear interpolation) literally move along the angle between directions. Flight sims and VR cameras use this for buttery turns.