Vector Calculator

Add, subtract and compare 2D or 3D vectors: magnitude, unit vector, dot product, cross product and the angle between two vectors.

Results

A · B
32
Zero when the vectors are perpendicular.

How it’s calculated

A vector has a size and a direction, written as components such as (x, y) in 2D or (x, y, z) in 3D. Enter vectors A and B, choose an operation, and read the result. Use 0 for a component that is missing.

magnitude: |A| = √(x² + y² + z²) unit vector: Â = A ÷ |A| add/subtract: A ± B = (Ax ± Bx, Ay ± By, Az ± Bz) dot product: A · B = AxBx + AyBy + AzBz = |A||B| cos θ cross product: A × B = (AyBz − AzBy, AzBx − AxBz, AxBy − AyBx) angle: θ = angle between A and B, from cos θ = A · B ÷ (|A||B|)

The dot product is a single number: 0 means the vectors are perpendicular. The cross product (3D) is a new vector perpendicular to both, and its length equals the area of the parallelogram they span. In 2D the cross product is just its z-component, AxBy − AyBx. The zero vector has no direction, so unit vectors and angles are not defined for it.

Example: A = (1, 2, 3), B = (4, 5, 6). A · B = 4 + 10 + 18 = 32. A × B = (2·6 − 3·5, 3·4 − 1·6, 1·5 − 2·4) = (−3, 6, −3). |A| = √14, |B| = √77, so cos θ = 32 ÷ √1078 = 0.9746 and θ = 12.93°.

Frequently asked questions

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

The dot product gives a single number that measures how much the vectors point the same way. The cross product (3D only) gives a vector perpendicular to both. Swapping the order flips the sign of a cross product but not of a dot product.

How do I find the angle between two vectors?

Divide the dot product by the product of the two lengths to get cos θ, then take the inverse cosine. This calculator does that for you and gives the angle in degrees and radians.

Why does the unit vector or angle say the zero vector is not allowed?

The zero vector (0, 0, 0) has length 0 and points nowhere. Dividing by its length would be division by zero, and there is no angle to measure.

Can I use this for 2D vectors?

Yes. Choose 2D and only the x and y components are used. The cross product of two 2D vectors is the single number AxBy − AyBx, which is the z-component of the 3D cross product.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator