Vector Calculator

Enter two vectors and pick what you want done with them. The dot product a · b = aₓbₓ + a_yb_y + a_zb_z is a single number whose sign tells you whether they lean the same way, and whose zero says they are perpendicular. The cross product a × b is a vector perpendicular to both, whose length is the area of the parallelogram they span — in 2D it collapses to one signed number. From those two everything else follows: the angle between them, the magnitude and unit vector, the projection of one onto the other, and the sum and difference. This page is about how two vectors relate to each other; if you want how far apart two POINTS are in 3D, that is the distance calculator, and for two points on a plane with the slope, line equation and midpoint, use the slope calculator. Dot, cross, angle and projection are on neither of them.

  • Accurate
  • Real-time
  • Easy to use
  • 100% free

Dot product a · b

11.000000

Magnitude |b|

3.000000

Details

Updates as you type

Every operation reads both vectors except the magnitude, which describes a on its own but still reports |b| alongside it.

Choosing 2D treats both z components as zero rather than hiding their boxes, so nothing you typed is thrown away. In 2D the cross product is a single signed number, not a vector.

<-20-1001020+

First component of a. With the defaults, a = (3, 4, 0) has a magnitude of exactly 5.

<-20-1001020+

Second component of a. Negative components are perfectly ordinary.

<-1-0.500.51+

Third component of a. Ignored in 2D. The slider is narrow because it is centred on a default of zero; type any value you need.

<-5-2.502.55+

First component of b. With the defaults, b = (1, 2, 2) has a magnitude of exactly 3.

<-10-50510+

Second component of b.

<-10-50510+

Third component of b. Ignored in 2D.

Summary

Dot product a · b

11.000000

Magnitude |a|
5.000000
Magnitude |b|
3.000000
Angle between a and b
42.8334 °
cos of that angle
0.733333
Magnitude of a × b
10.198039
Perpendicular?
No
  • The dot product is a number, not a vector. Its sign is the whole point: positive means the two vectors lean the same way (the angle between them is under 90°), negative means they lean opposite ways, and exactly zero means they are perpendicular. That zero test is the reason the dot product turns up everywhere from lighting a 3D scene to checking whether a force does any work.
  • It is commutative — a · b and b · a are the same number — and it distributes over addition. a · a is |a|², which is where the magnitude formula comes from.
  • This page is the algebra of two vectors — how they combine and how they lie relative to one another. If what you want is how far apart two POINTS are, that is the distance calculator, which covers the 3D straight line, the Manhattan metric and great-circle distance on the Earth. For two points on a plane with the slope, the line equation and the midpoint, use the slope calculator. Subtracting b from a here and reading off the magnitude gives the same straight-line distance, because the displacement between two points is the difference of their position vectors.
How this is calculated
Vector a
(3, 4, 0)
Vector b
(1, 2, 2)

aₓ × bₓ
3.000000
a_y × b_y
8.000000
a_z × b_z
0.000000
a · b, the sum of those
11.000000

|a| × |b|
15.000000
cos θ = (a · b) ÷ (|a| |b|)
0.733333
θ
42.8334 °

Compare scenarios

See how one change moves the result

  • CurrentYour inputs as they stand11.000000Current
  • Vector a — x412.000000
  • Vector a — y513.000000
  • Vector b — x1.512.500000

Frequently asked questions

What is the difference between the dot product and the cross product?

The dot product returns a number and the cross product returns a vector, and they answer opposite questions. a · b = |a| |b| cos θ measures how much the two vectors agree in direction: it is largest when they are parallel and exactly zero when they are perpendicular. a × b has length |a| |b| sin θ, so it measures how much they disagree: zero when parallel, largest when perpendicular. The dot product exists in any number of dimensions; the cross product, as a vector, only exists in three.

What does the cross product mean in 2D?

It is a single signed number, not a vector. Two vectors lying in a plane span that plane, so a vector perpendicular to both must point straight out of it — only the z component can be non-zero, and it works out to aₓb_y − a_ybₓ. That number is the signed area of the parallelogram the two vectors span: positive when b lies counter-clockwise from a, negative when clockwise, and zero when they are parallel. It is the standard orientation test in computational geometry, used for deciding which side of a line a point falls on.

How do I find the angle between two vectors?

Divide the dot product by the product of the magnitudes and take the arc cosine: θ = acos((a · b) ÷ (|a| |b|)). With a = (3, 4, 0) and b = (1, 2, 2) that is acos(11 ÷ 15) = 42.83°. This calculator actually uses θ = atan2(|a × b|, a · b), which is the same angle computed in a numerically better-behaved way — acos loses precision badly for nearly parallel vectors and can return NaN when rounding pushes its argument past 1. The result is always between 0° and 180°, because vectors carry no sense of which way round you sweep.

Why can a zero vector have no angle or projection?

Because a vector of zero length points nowhere. The angle formula divides by |a| |b|, and the projection divides by |b|, so a zero magnitude makes the arithmetic undefined rather than merely awkward — and no convention rescues it, since every direction is equally consistent with a vector that has no direction. The calculator refuses these cases against the offending vector instead of returning a NaN. A zero magnitude is still a perfectly good answer to "how long is this vector", which is why the magnitude mode accepts it and only declines to hand back a unit vector.

What is a projection, and does the order matter?

The projection of a onto b is the shadow a casts along the direction of b. The scalar projection (a · b) ÷ |b| is how long that shadow is, signed so a negative value means a leans away from b. The vector projection ((a · b) ÷ |b|²)·b writes the same shadow back as a vector, and what is left over is the rejection, the part of a perpendicular to b. Order matters: projecting a onto b and b onto a share the numerator a · b but divide by different lengths. The length of b does not matter at all, only its direction, because b appears once on top and twice underneath.

Is the magnitude of a + b the same as |a| + |b|?

Only when a and b point in exactly the same direction. Otherwise |a + b| is strictly smaller, which is the triangle inequality: the direct route is never longer than going via a corner. With a = (3, 4, 0) and b = (1, 2, 2), |a| + |b| = 8 while |a + b| = √56 ≈ 7.483. The gap widens as the angle between the vectors grows, and at 180° the sum can be as small as the difference of the two magnitudes.

Can I use this to find the distance between two points?

Yes, indirectly. Treat the two points as position vectors, subtract, and the magnitude of a − b is the straight-line distance between them — the displacement between two points is the difference of their position vectors, so the arithmetic is identical. The distance calculator is the more direct route if that is all you want, since it also gives the Manhattan metric and great-circle distance from latitude and longitude. What it does not do is the dot product, the cross product, the angle between two directions, or a projection, which is what this page is for.

You might also like