# What do my vectors add up to?

Adds, subtracts and scales 2D or 3D vectors, and finds their lengths, dot product, the angle between them, the unit vector and the cross product.

- Page: https://www.acalculator.org/math/vector-calculator
- JSON spec: https://www.acalculator.org/math/vector-calculator.json
- Version: a2d4ccb03938

## Default answer

Example with the default inputs (Vectors in 3D, A: x 3, A: y 5, A: z 2, B: x -1, B: y 3, B: z 0, Scalar k 2): A + B = ⟨2, 8, 2⟩, and A · B = 12.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| dim | Vectors in | Whether the vectors have two components (x, y) or three (x, y, z). |
| ax | A: x | The x component of vector A. |
| ay | A: y | The y component of vector A. |
| az | A: z | The z component of vector A. |
| bx | B: x | The x component of vector B. |
| by | B: y | The y component of vector B. |
| bz | B: z | The z component of vector B. |
| k | Scalar k | A number to multiply vector A by. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| sum | A + B | The sum, component by component. |
| difference | A − B | The difference, component by component. |
| scaled | k·A | Vector A with each component multiplied by k. |
| lengthA | \|A\| | The length (magnitude) of A: the square root of the sum of its squared components. |
| lengthB | \|B\| | The length (magnitude) of B. |
| dot | A · B | The dot product: the sum of the products of matching components. |
| angle | Angle between A and B (°) | The angle θ with cos θ = A · B ÷ (\|A\| \|B\|), in degrees. |
| unitA | Unit vector of A | A divided by its length: the vector of length 1 in the direction of A. |
| cross | A × B | The cross product (3D only): a vector at right angles to both A and B. |

## Method

A ± B = ⟨a₁ ± b₁, a₂ ± b₂, a₃ ± b₃⟩; k·A = ⟨ka₁, ka₂, ka₃⟩; |A| = √(a₁² + a₂² + a₃²); A · B = a₁b₁ + a₂b₂ + a₃b₃; cos θ = A · B ÷ (|A| |B|); A × B = ⟨a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁⟩.

## Assumptions

- The vectors have real components in the usual x, y (and z) directions; 2D vectors leave out z.
- There is no angle and no unit vector for a zero vector, which has no direction.

## Worked examples

1. dim = 3d, ax = 3, ay = 5, az = 2, bx = -1, by = 3, bz = 0, k = 2 gives dot = 12, sum = ⟨2, 8, 2⟩, difference = ⟨4, 2, 2⟩, scaled = ⟨6, 10, 4⟩, cross = ⟨-6, -2, 14⟩, lengthA = 6.164414, lengthB = 3.162278. Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product (Example 2.21: u · v = 12), https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product; for the sum, difference, k·A and cross product (§2.4, https://openstax.org/books/calculus-volume-3/pages/2-4-the-cross-product).
2. dim = 3d, ax = 2, ay = 5, az = 6, bx = -2, by = -4, bz = 4, k = 1 gives dot = 0, angle = 90. Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product (Example 2.23: cos θ = 0, θ = 90°), https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product.
3. dim = 2d, ax = 1, ay = 2, bx = 3, by = 4, k = -1 gives lengthA = 2.236068, unitA = ⟨0.4472135955, 0.894427191⟩, sum = ⟨4, 6⟩, scaled = ⟨-1, -2⟩, dot = 11, lengthB = 5, angle = 10.304846. Source: OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane (Example 2.7), https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane.
4. dim = 2d, ax = 0.1, ay = 0.2, bx = 0.2, by = 0.1, k = 3 gives sum = ⟨0.3, 0.3⟩, dot = 0.04, scaled = ⟨0.3, 0.6⟩. Source: OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane, https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane.

## FAQ

### How do I add two vectors?

Add the matching components. ⟨3, 5, 2⟩ + ⟨−1, 3, 0⟩ = ⟨3 − 1, 5 + 3, 2 + 0⟩ = ⟨2, 8, 2⟩. Subtraction works the same way, component by component.

### How do I find the length (magnitude) of a vector?

Square each component, add them, and take the square root. |⟨3, 5, 2⟩| = √(9 + 25 + 4) = √38 ≈ 6.1644.

### How do I find the angle between two vectors?

Divide the dot product by the product of the lengths to get cos θ, then take the inverse cosine. For ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ the dot product is 0, so the angle is 90°.

### What is a unit vector?

A vector of length 1 that points the same way. Divide the vector by its length: ⟨1, 2⟩ has length √5, so its unit vector is ⟨1/√5, 2/√5⟩ ≈ ⟨0.4472, 0.8944⟩.

### Why is there no cross product for 2D vectors?

The cross product is defined for vectors in 3D: it is the vector at right angles to both. Pick 3D and give z = 0 to treat 2D vectors as flat 3D vectors; the cross product then points along z.

### What if one vector is zero?

A zero vector has length 0 and no direction, so the page leaves out the angle and, for A, the unit vector. The sum, difference and dot product still work.

## Sources

- OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane: vector sum, scalar multiple, magnitude, unit vectors (Example 2.7). https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane (retrieved 2026-10-02)
- OpenStax, Calculus Volume 3, §2.2 Vectors in Three Dimensions. https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions (retrieved 2026-10-02)
- OpenStax, Calculus Volume 3, §2.3 The Dot Product: u · v and the angle between vectors (Examples 2.21 and 2.23). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product (retrieved 2026-10-02)
- OpenStax, Calculus Volume 3, §2.4 The Cross Product. https://openstax.org/books/calculus-volume-3/pages/2-4-the-cross-product (retrieved 2026-10-02)
