Linear Algebra

Vector Calculator

Enter two vectors with 2 or 3 components each. This calculator finds the magnitude of each, their dot product, their cross product and the angle between them, with each formula shown.

Vector Calculator

Magnitude, dot product, cross product and angle.

Try:
Answera × b = (-3, 6, -3), a · b = 32, |a| = 3.74166, |b| = 8.77496, angle = 12.9332°
  1. Vectorsa = (1, 2, 3), b = (4, 5, 6)
  2. Magnitudes|a| = 3.74166, |b| = 8.77496
  3. Dot producta · b = 32
  4. Cross producta × b = (-3, 6, -3)
  5. Angle betweenθ = arccos(a·b / (|a||b|)) = 12.9332°

Two products, two meanings

Two vectors can be multiplied in two entirely different ways, and the difference is not a technicality. One produces a number that measures how much they point the same way; the other produces a vector perpendicular to both. They answer different questions and are not variants of one operation.

This calculator computes both, along with each vector's magnitude and the angle between them.

The dot product collapses two vectors into a single number and is largest when they are aligned, zero when they are perpendicular, and negative when they oppose. It is the operation behind projections, work done by a force, and every test for orthogonality.

The cross product goes the other way, producing a direction that neither input has. Its magnitude measures the area of the parallelogram the two vectors span, which is greatest when they are perpendicular — exactly the opposite of when the dot product peaks.

How to use this calculator

  1. Enter the first vector Two or three comma-separated components. Both vectors must have the same number, and anything other than two or three is rejected.
  2. Enter the second vector The same convention and the same length. Mixing a two-component vector with a three-component one is refused rather than padded.
  3. Read the magnitudes and the dot product The magnitudes come first, then the dot product. A dot product of zero means the two are perpendicular, whatever their sizes.
  4. Note how the cross product is reported In three dimensions it is a vector; in two it is reported as a single number, since the perpendicular direction lies outside the plane.

The formula, and where it comes from

|a| = √(Σ aᵢ²) a · b = Σ aᵢbᵢ cos θ = (a · b)/(|a||b|) a × b ⊥ a, b

The magnitude is the Pythagorean theorem extended to as many components as there are, computed with the hypotenuse routine rather than by squaring and adding directly — which keeps precision when the components differ greatly in size.

The dot product multiplies matching components and adds. Its sign alone is informative: positive means the vectors point broadly the same way, negative means broadly opposite, and exactly zero means perpendicular regardless of how long either is.

The angle follows by rearranging the dot product's geometric form. The quotient is clamped into the valid range before the inverse cosine is taken, because floating-point rounding can push a value fractionally past 1 and make the inverse fail on vectors that are genuinely parallel.

In three dimensions the cross product is a vector perpendicular to both inputs, with its own components built from cross-multiplied pairs. In two dimensions there is no perpendicular direction inside the plane, so only the scalar that would be its out-of-plane component is reported.

What each input means

a First vector — form field “Vector a (comma-separated)”
Two or three comma-separated components. Order matters for the cross product, which reverses sign when the two are swapped.
b Second vector — form field “Vector b (comma-separated)”
The same length as the first. Components may be negative or fractional.
θ Angle between
Reported in degrees, between 0 and 180. Undefined if either vector is zero, since a zero vector has no direction.

Worked examples

Every number below is produced by the same calculation engine the tool above runs. Nothing here is typed by hand, so the walkthrough cannot drift from what you get when you enter the same values yourself.

Two three-dimensional vectors

A pair of general 3D vectors, so both products are fully populated.

Inputs Vector a (comma-separated) = 1, 2, 3, Vector b (comma-separated) = 4, 5, 6

  1. Vectors a = (1, 2, 3), b = (4, 5, 6)
  2. Magnitudes |a| = 3.74166, |b| = 8.77496
  3. Dot product a · b = 32
  4. Cross product a × b = (-3, 6, -3)
  5. Angle between θ = arccos(a·b / (|a||b|)) = 12.9332°

Result a × b = (-3, 6, -3), a · b = 32, |a| = 3.74166, |b| = 8.77496, angle = 12.9332°

The dot product is positive and the angle comes out well under a right angle, so the two point broadly the same way. The cross product is a third vector perpendicular to both, which can be checked by dotting it against either input and getting zero.

That check is worth doing once. A cross product whose dot product with an input is not zero has a sign or an index wrong somewhere in the cross-multiplication.

Two-dimensional vectors

A 3-4-5 vector against a unit vector along the horizontal axis. The cross product is reported as a scalar rather than a vector.

Inputs Vector a (comma-separated) = 3, 4, Vector b (comma-separated) = 1, 0

  1. Vectors a = (3, 4), b = (1, 0)
  2. Magnitudes |a| = 5, |b| = 1
  3. Dot product a · b = 3
  4. Cross product (2D scalar) a × b = -4
  5. Angle between θ = arccos(a·b / (|a||b|)) = 53.1301°

Result a · b = 3, |a| = 5, |b| = 1, angle = 53.1301°

The first vector has magnitude 5 exactly, and the dot product picks out its horizontal component alone — since the second vector is a unit vector along that axis, the dot product is simply that component.

The scalar cross product is the perpendicular component instead, and its magnitude is the area of the parallelogram the two span. In two dimensions the perpendicular direction points out of the plane, so only that one number survives.

Reading the result

A zero dot product means perpendicular

It is the cleanest test for orthogonality there is, and it requires no angle calculation. The converse also holds: perpendicular vectors always have a dot product of exactly zero.

The cross product's magnitude is an area

It equals the area of the parallelogram the two vectors span, so it is zero for parallel vectors and largest for perpendicular ones — the exact opposite of the dot product's behaviour.

The angle is always between 0 and 180

The inverse cosine returns a value in that range, so no distinction is made between an angle and its reflection. The dot product's sign tells you which side of a right angle you are on.

When you would use this

Testing alignment or perpendicularity

The dot product decides both at once: zero for perpendicular, positive for broadly aligned, negative for broadly opposed. No angle needs computing to answer either question.

Finding a perpendicular direction

The cross product of two vectors in a plane gives a normal to that plane, which is how surface normals and rotation axes are constructed.

Assumptions and limitations

What this calculator assumes

  • Both vectors have the same number of components, either two or three.
  • Components are real numbers separated by commas or spaces.
  • The angle is reported in degrees and requires both vectors to be non-zero.
  • In two dimensions the cross product is reported as the single out-of-plane scalar.

Where it stops being the right tool

  • Two or three components only; higher-dimensional vectors are rejected.
  • Two vectors at a time, so a triple product must be built in stages.
  • No vector addition, subtraction or scalar multiplication.
  • No unit vector or normalisation is reported alongside the magnitudes.

Common mistakes

Expecting the cross product to be a number

Why it happens. The dot product is a number and both are called products, so the same shape of answer is expected from each.

How to avoid it. In three dimensions it is a vector, perpendicular to both inputs. Only in two dimensions does it reduce to a single value, and that value is a component pointing out of the plane.

Swapping the order for a cross product

Why it happens. The dot product is unaffected by order, which builds the expectation that the cross product is too. Reversing it negates every component.

How to avoid it. Enter the vectors in the order the problem specifies. If your answer is the exact negative of the tool's, the order is what differs.

Reading a negative dot product as an error

Why it happens. It is described as a measure of alignment, and a negative measure sounds wrong.

How to avoid it. A negative value means the angle exceeds a right angle — the vectors broadly oppose each other. It is as ordinary a result as a positive one.

Key terms

Frequently asked questions

What is the dot product?

The sum of the products of matching components. It is a single number, positive when the vectors point broadly the same way, negative when they oppose, and exactly zero when they are perpendicular.

What does the cross product give?

In three dimensions, a vector perpendicular to both inputs whose length is the area of the parallelogram they span. In two dimensions there is no such direction within the plane, so only the out-of-plane component is reported, as a single number.

How is the angle between vectors found?

By rearranging the dot product: its value divided by the product of the two magnitudes is the cosine of the angle. The quotient is clamped before the inverse cosine is applied, so parallel vectors do not fail on rounding.

Why does the cross product change sign when I swap the vectors?

Because the perpendicular direction has two choices and the order picks between them. Reversing the inputs flips which side the result points to, negating every component while leaving its magnitude alone.