Vector Calculator

In short: Enter two vectors — leave z as 0 for flat 2D work — and get everything at once: magnitudes, unit vectors, A + B, A − B, the dot product, the cross product and the angle between them. For the defaults, A = (3, 4) has magnitude exactly 5, the dot product with B = (1, 2) is 11, and the angle between them is 10.30°.

The operations and their formulas

Magnitude: |A| = √(x² + y² + z²) — Pythagoras extended into three dimensions. Unit vector: Â = A ÷ |A|, the same direction shrunk or stretched to length exactly 1. Addition and subtraction are component by component: (3, 4) + (1, 2) = (4, 6); (3, 4) − (1, 2) = (2, 2).

Dot product: A · B = ax·bx + ay·by + az·bz. It produces a single number (a scalar), and it encodes the angle: A · B = |A| |B| cos θ, so θ = arccos(A · B ÷ (|A| |B|)). A dot product of zero means the vectors are perpendicular; positive means they point broadly the same way, negative means broadly opposite.

Cross product: A × B = (ay·bz − az·by, az·bx − ax·bz, ax·by − ay·bx). It produces a third vector perpendicular to both inputs, with magnitude |A| |B| sin θ — the area of the parallelogram the two vectors span. For flat 2D vectors the cross product has only a z-component: (3, 4) × (1, 2) = (0, 0, 3×2 − 4×1) = (0, 0, 2), pointing out of the page.

Worked example

Take A = (3, 4) and B = (1, 2), the defaults above. Magnitudes: |A| = √(9 + 16) = 5; |B| = √(1 + 4) = √5 ≈ 2.236. Unit vectors: Â = (0.6, 0.8); B̂ ≈ (0.447, 0.894). Sum (4, 6), difference (2, 2).

Dot product: 3×1 + 4×2 = 3 + 8 = 11. Angle: cos θ = 11 ÷ (5 × 2.236) = 0.9839, so θ ≈ 10.30° — the vectors point in nearly the same direction, which the strongly positive dot product already hinted at. Cross product (as 3D vectors with z = 0): (4×0 − 0×2, 0×1 − 3×0, 3×2 − 4×1) = (0, 0, 2), magnitude 2 — and indeed |A| |B| sin θ = 5 × 2.236 × sin 10.30° ≈ 2.00, the parallelogram area. In three dimensions, (1, 2, 3) × (4, 5, 6) = (2×6 − 3×5, 3×4 − 1×6, 1×5 − 2×4) = (−3, 6, −3): try it above by filling in the z boxes.

Where each operation earns its keep

The dot product is the workhorse of physics and graphics: work done by a force is force · displacement (only the component along the movement counts), and a surface’s brightness in 3D rendering is a dot product between the light direction and the surface normal. The cross product gives torque (r × F) and the direction a plane faces. The angle formula settles everything from navigation bearings to how aligned two machine-learning embeddings are — cosine similarity is literally the dot product of two unit vectors. And unit vectors are how directions are stored when size should not interfere: a direction is a point on a sphere, and normalising is how you get there from any vector that points the right way.

Frequently asked questions

How do you add two vectors?

Component by component: line the vectors up and add each matching part. (3, 4) + (1, 2) = (3 + 1, 4 + 2) = (4, 6). Subtraction is the same with minus signs: (3, 4) − (1, 2) = (2, 2). Geometrically, addition is walking the first vector then the second — tip to tail — and the result is the direct route from the start to the finish. You cannot add vectors of different dimensions; a 2D and a 3D vector first need a shared dimension (treat the 2D one as having z = 0).

What does the dot product tell you?

How much two vectors point the same way, scaled by their lengths: A · B = |A| |B| cos θ. If it is zero, the vectors are perpendicular. If it is positive they form an acute angle; negative, an obtuse one. Divide by the two magnitudes and you get cos θ itself, which is the angle formula this calculator uses — and, between unit vectors, the “cosine similarity” used to compare directions in data science. Unlike the cross product, the dot product is a plain number, not a vector.

What is the difference between the dot and cross products?

The dot product multiplies corresponding components and adds them into one number that measures alignment. The cross product combines components crosswise into a new vector that is perpendicular to both inputs, with a length equal to the area of the parallelogram they span. Mnemonic: dot = “how parallel”, cross = “how perpendicular”. The cross product only exists in this form in three dimensions (2D vectors give just its z-component), and order matters: A × B = −(B × A), while A · B = B · A.

How do you find a unit vector?

Divide the vector by its own magnitude. For (3, 4): the magnitude is 5, so the unit vector is (3/5, 4/5) = (0.6, 0.8), and sure enough √(0.36 + 0.64) = 1. The direction is untouched — the unit vector points exactly where the original pointed — only the length is standardised to 1. The one vector with no unit version is the zero vector, which has no direction to preserve.

How do you find the angle between two vectors?

Use the dot product rearranged: θ = arccos( (A · B) ÷ (|A| × |B|) ). For (3, 4) and (1, 2): the dot product is 11, the magnitudes are 5 and √5, so cos θ = 11 ÷ 11.18 = 0.9839 and θ ≈ 10.30°. The formula always returns an angle between 0° and 180°, which is the smaller angle between the directions — the natural reading of “the angle between” two arrows.

Related tools

Worked examples verified in Node on 24 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.