Skip to content
K Knidox Search…
Math · Linear Algebra

Vector Calculator

Add, subtract, dot and cross two vectors in 2D or 3D, with magnitude and angle.

Vector a
Vector b
a + b
(4, 6)

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.

a · b = Σ aᵢbᵢ · · · |a| = √Σaᵢ²

the dot product is a scalar; the magnitude is the vector’s length

Worked example

Take a = (3, 4) and b = (1, 2):

  1. 1
    Add the matching components. (3 + 1, 4 + 2) = (4, 6) — addition is just position against matching position.
  2. 2
    Multiply matching components for the dot product. 3×1 = 3 and 4×2 = 8, so a · b = 3 + 8 = 11.
  3. 3
    Take the square root of the squared components for the magnitude. |a| = √(3² + 4²) = √25 = 5; likewise |b| = √(1² + 2²) ≈ 2.236.
  4. 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₃).

OperationFormula
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.

What’s the difference between the dot and cross product?
The dot product returns a single number (a scalar) that measures how aligned two vectors are, while the cross product returns a new vector perpendicular to both. The dot product works in any dimension; the cross product is defined only in 3D.
What does a dot product of 0 mean?
It means the two vectors are perpendicular. Since a · b = |a| |b| cos θ, a zero dot product (with non-zero vectors) forces the angle θ to be 90°.
How is the magnitude of a vector calculated?
Square each component, add them, and take the square root: |a| = √(Σ aᵢ²). For a = (3, 4) that is √(9 + 16) = √25 = 5.
Why is there no cross product in 2D?
The cross product produces a vector perpendicular to both inputs, which requires a third dimension to point into. In 2D there is no such direction, so the cross product is offered only when you select 3D.
How do I find the angle between two vectors?
Use θ = acos( (a · b) / (|a| |b|) ). Compute the dot product, divide by the product of the magnitudes, then take the inverse cosine. The angle is undefined if either vector has zero length.
Does the order matter for these operations?
Addition and the dot product are commutative — order does not change the result. The cross product is anti-commutative: a × b = −(b × a), so swapping the inputs flips the resulting vector.