Vector Calculator
Add, subtract, dot and cross two vectors in 2D or 3D, with magnitude and angle.
To add two vectors, add their matching components. For a = (3, 4) and b = (1, 2), a + b = (4, 6). The dot product a · b = 3×1 + 4×2 = 11, and the magnitude of a is √(3² + 4²) = 5. The angle between them is about 10.3°.
How vector operations work
A vector is a list of components — (x, y) in 2D or (x, y, z) in 3D. Addition and subtraction work component by component, matching position against position. The dot product multiplies matching components and sums them into a single number (a scalar), while the cross product (3D only) returns a new vector that points perpendicular to both inputs.
the dot product is a scalar; the magnitude is the vector’s length
Worked example
Take a = (3, 4) and b = (1, 2):
- 1 Add the matching components. (3 + 1, 4 + 2) = (4, 6) — addition is just position against matching position.
- 2 Multiply matching components for the dot product. 3×1 = 3 and 4×2 = 8, so a · b = 3 + 8 = 11.
- 3 Take the square root of the squared components for the magnitude. |a| = √(3² + 4²) = √25 = 5; likewise |b| = √(1² + 2²) ≈ 2.236.
- 4 Use the dot product and magnitudes for the angle. θ = acos(11 / (5 × 2.236)) ≈ acos(0.984) ≈ 10.3°.
Vector operations at a glance
For a = (a₁, a₂, a₃) and b = (b₁, b₂, b₃).
| Operation | Formula |
|---|---|
| Add (a + b) | (a₁+b₁, a₂+b₂, a₃+b₃) |
| Subtract (a − b) | (a₁−b₁, a₂−b₂, a₃−b₃) |
| Dot product (a · b) | Σ aᵢbᵢ — a single number |
| Cross product (a × b) | (a₂b₃−a₃b₂, a₃b₁−a₁b₃, a₁b₂−a₂b₁) — 3D only |
| Magnitude (|a|) | √(Σ aᵢ²) |
| Angle (θ) | acos( (a · b) / (|a| |b|) ) |
Reading the results
A dot product of 0 means the vectors are perpendicular. Because a · b = |a| |b| cos θ, a zero result forces cos θ = 0, so the angle between them is 90°. A positive dot product means they point in broadly the same direction; negative means opposite.
The cross product is perpendicular to both inputs. In 3D, a × b returns a vector at right angles to the plane containing a and b, with a length equal to the area of the parallelogram they span — which is why it only exists in three dimensions.
Magnitude is geometric length. |a| measures how long the arrow is, independent of direction, and it is what turns the dot product into the cosine of the angle between two vectors.