Vectors: Dot Product, Cross Product and Angles

After reading this you can compute the magnitude, dot product, cross product, angle and projection of two vectors by hand, and read what each number tells you about their geometry.

What a vector calculation gives you

A vector carries both a size and a direction. Write it as a list of components, like \mathbf{a} = (1, 2, 3). From two vectors you can extract five useful quantities: how long each one is, how much they point the same way (the dot product), the angle between them, the shadow one casts on the other (the projection), and a new vector perpendicular to both (the cross product).

Here is the hook. Take \mathbf{a} = (3, 0) and \mathbf{b} = (0, 4). The dot product is 3·0 + 0·4 = 0, which means they are exactly perpendicular. The cross product magnitude is 3·4 = 12, which is the area of the rectangle they span. Two numbers, two facts about the same pair.

When to use it, and when not

Reach for these tools when you have coordinates and you want a geometric fact: an angle, a distance along a direction, a test for perpendicularity, or an area. The dot product answers "how aligned?" and the cross product answers "how much do they spread out, and in what perpendicular direction?"

Do not use the cross product in two dimensions expecting a vector back. In 2D the cross product collapses to a single number, the signed area a_x·b_y - a_y·b_x. A true cross product vector only exists in 3D. If you need to solve a linear system or invert a coefficient matrix, that is a job for the Matrix calculator or the Equation solver, not for vector products.

The formulas and what they mean

The magnitude (length) of a vector comes from the Pythagorean theorem applied to its components.

\|\mathbf{a}\| = \sqrt{a_x^2 + a_y^2 + a_z^2}

Each a_x, a_y, a_z is a component of \mathbf{a}. Square them, add, take the root. For (3, 4) the length is 5.

The dot product multiplies matching components and sums them.

\mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y + a_z b_z = \|\mathbf{a}\|\,\|\mathbf{b}\|\cos\theta

The second form is the key insight: the dot product equals the product of the lengths times the cosine of the angle \theta between them. When the vectors point the same way, \cos\theta = 1 and the dot product is large. When they are perpendicular, \cos\theta = 0 and the dot product is zero. When they oppose, it goes negative.

Solving that relation for the angle gives a direct formula.

\theta = \arccos\left(\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|\,\|\mathbf{b}\|}\right)

The projection of \mathbf{a} onto \mathbf{b} is the part of \mathbf{a} that lies along \mathbf{b}, its shadow.

\text{proj}_{\mathbf{b}}\,\mathbf{a} = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2}\,\mathbf{b}

The scalar factor \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2} tells you how many copies of \mathbf{b} to lay down. Multiply it back by \mathbf{b} to get the projection as a vector.

The cross product (3D only) produces a vector perpendicular to both inputs.

\mathbf{a} \times \mathbf{b} = (a_y b_z - a_z b_y,\; a_z b_x - a_x b_z,\; a_x b_y - a_y b_x)

Its length equals \|\mathbf{a}\|\,\|\mathbf{b}\|\sin\theta, which is the area of the parallelogram the two vectors form. When they are parallel, \sin\theta = 0 and the cross product is the zero vector.

Dot product uses cosine and returns a number. Cross product uses sine and returns a vector (in 3D). One peaks when vectors align, the other peaks when they are perpendicular. They are complementary measurements of the same pair.

Worked example with the demo data

Everything from a = (1, 2, 3) and b = (4, 5, 6)

Load the demo values a = 1, 2, 3 and b = 4, 5, 6 and press Calculate. Here is every number, step by step.

  1. Magnitudes: \|\mathbf{a}\| = \sqrt{1 + 4 + 9} = \sqrt{14} \approx 3.742 and \|\mathbf{b}\| = \sqrt{16 + 25 + 36} = \sqrt{77} \approx 8.775.
  2. Dot product: 1·4 + 2·5 + 3·6 = 4 + 10 + 18 = 32.
  3. Angle: \cos\theta = \frac{32}{\sqrt{14}\,\sqrt{77}} = \frac{32}{32.85} \approx 0.9740, so \theta \approx 13.06^\circ. The vectors point in nearly the same direction.
  4. Cross product: (2\cdot6 - 3\cdot5,\; 3\cdot4 - 1\cdot6,\; 1\cdot5 - 2\cdot4) = (-3, 6, -3).
  5. Parallelogram area: \|(-3, 6, -3)\| = \sqrt{9 + 36 + 9} = \sqrt{54} \approx 7.348.
  6. Projection of \mathbf{a} onto \mathbf{b}: the scalar is \frac{32}{77} \approx 0.4156, so the projection vector is 0.4156 \cdot (4, 5, 6) \approx (1.662, 2.078, 2.494).

Check the cross product is perpendicular to both inputs: (-3)·1 + 6·2 + (-3)·3 = -3 + 12 - 9 = 0. It works.

Reading and interpreting the results

The sign of the dot product is the fastest read. Positive means the angle is under 90 degrees, zero means exactly 90 degrees, negative means obtuse. In the demo, 32 is positive and large relative to the length product, so 13 degrees is expected.

How the dot product tracks the angle for two unit vectors
Anglecos θDot productMeaning
0°11Same direction
45°0.70710.7071Partly aligned
90°00Perpendicular
135°-0.7071-0.7071Partly opposed
180°-1-1Opposite direction

The cross product magnitude tells you area, but its direction matters too. It follows the right hand rule: point your fingers from \mathbf{a} toward \mathbf{b} and your thumb points along \mathbf{a} \times \mathbf{b}. Swapping the order flips the sign: \mathbf{b} \times \mathbf{a} = -(\mathbf{a} \times \mathbf{b}).

The dot product of two unit vectors is the cosine curve. The marker at 13 degrees matches the demo angle, where the value is near 0.974.

Fix vector a at (3, 0) and rotate vector b of length 4 around the origin. At 0 degrees the dot product is 12 and the cross product area is 0. At 90 degrees the dot product is 0 and the area is 12. At 180 degrees the dot product is -12 and the area is 0 again.

Common mistakes

The errors below are the ones that show up most often when people compute vector quantities by hand.

Do not forget to divide by both magnitudes when finding the angle. The bare dot product 32 is not a cosine. You must divide by \sqrt{14}\,\sqrt{77} \approx 32.85 first to get 0.974, then take the arccosine.

A second mistake is mixing dimensions. You cannot dot a 2D vector with a 3D vector, and the components must line up in the same order. A third is reversing the cross product order and reporting the wrong sign. If you get (3, -6, 3) instead of (-3, 6, -3), you computed \mathbf{b} \times \mathbf{a}.

Finally, watch the projection formula. The denominator is \|\mathbf{b}\|^2, the squared length of the vector you project onto, not \|\mathbf{b}\|. Using the wrong denominator scales the answer incorrectly.

Related tools

Vectors sit next to several other topics on this site. If your problem grows into a system of equations, the Matrix decompositions page covers LU, QR and SVD, which are built from vector dot products. When you need exact roots of a squared magnitude, the Radical simplifier turns \sqrt{54} into 3\sqrt{6}. For quadratic relationships that appear when you set a magnitude equal to a target, try the Quadratic equation solver. And if your components are complex numbers, the Complex number calculator handles the arithmetic.

Frequently asked questions

What does a dot product of zero mean?

The two vectors are perpendicular, at exactly 90 degrees, as long as neither vector is the zero vector. For example (1, 2) and (2, -1) give 1·2 + 2·(-1) = 0.

Can I take a cross product in 2D?

Not as a vector. In 2D the cross product reduces to one signed number, a_x·b_y - a_y·b_x, which is the signed area of the parallelogram. To get a full cross product vector you need 3D inputs. You can promote a 2D vector to 3D by adding a zero third component.

Why is my angle always between 0 and 180 degrees?

The arccosine of the normalized dot product returns values in that range. The dot product cannot distinguish a 30 degree turn from a 330 degree turn because cosine is even. If you need a signed angle in 2D, use the cross product number to decide the direction.

How do I find a unit vector?

Divide each component by the magnitude. For \mathbf{a} = (1, 2, 3) with length \sqrt{14} \approx 3.742, the unit vector is (0.267, 0.535, 0.802). Its length is 1 by construction.

Is the cross product magnitude always the area?

Yes, it equals the parallelogram area spanned by the two vectors. Half of it is the area of the triangle they form. For the demo the parallelogram area is \sqrt{54} \approx 7.348, so the triangle area is about 3.674.