Vector Calculator
Dot product, cross product, magnitudes, the angle between two vectors, their sum and difference, a unit vector and a projection, in 2D or 3D.
Result
Dot product, a · b: 32
Exact arithmetic on the components; decimals shown to six places.
- Cross product, a × b
- ⟨−3, 6, −3⟩
- Angle between a and b
- 12.933154 ° (0.225726 rad)
- Magnitude of a, ‖a‖
- 3.741657
- Magnitude of b, ‖b‖
- 8.774964
- Sum, a + b
- ⟨5, 7, 9⟩
- Difference, a − b
- ⟨−3, −3, −3⟩
- Unit vector in the direction of a
- ⟨0.2672612419, 0.5345224838, 0.8017837257⟩
- Projection of a onto b
- ⟨1.662337662, 2.077922078, 2.493506494⟩
- Scalar projection of a onto b
- 3.646738
https://calcgallery.com/algebra-numbers/vector-calculator/
Results follow the mathematical operation and values shown. Check that you selected the intended operation, convention and dataset type before relying on the result. Read the full disclaimer
How to use the Vector Calculator
- Choose 2 or 3 dimensions and enter the components of vectors a and b.
- Read the dot product first, then the cross product, the lengths and the angle between the vectors.
- Use the sum, difference, unit vector and projection further down as you need them.
The formulas
a · b = a₁b₁ + a₂b₂ + a₃b₃a × b = ⟨a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁⟩‖a‖ = √(a₁² + a₂² + a₃²)cos θ = a · b ÷ (‖a‖ ‖b‖)proj = (a · b ÷ ‖b‖²) b
Projections
The projection of a onto b is the part of a that runs along b: the shadow a casts on the line through b. The scalar projection is its signed length, a · b ÷ ‖b‖, negative when a leans away from b. Projecting onto a zero vector means nothing, since it has no line to project onto, so the page leaves those two results blank.
Unit vectors
Dividing a vector by its own length gives the unit vector in the same direction, length 1: ⟨3, 4⟩ becomes ⟨0.6, 0.8⟩. For the length of the gap between two points rather than of a vector, the distance calculator does the same square root on the differences of their coordinates.
With your numbers
- a · b = 1 × 4 + 2 × 5 + 3 × 6 = 32
- θ = atan2(‖a × b‖, a · b), the same angle as cos θ = a · b ÷ (‖a‖‖b‖)
Quick reference
Exact arithmetic on the components; decimals shown to six places.
| Example | Dot product, a · b |
|---|---|
| ⟨1, 2, 3⟩ and ⟨4, 5, 6⟩ | 32 |
| ⟨1, 0, 0⟩ and ⟨0, 1, 0⟩ | 0 |
| ⟨1, 2, 3⟩ and ⟨2, 4, 6⟩ | 28 |
| ⟨3, 4⟩ and ⟨4, 3⟩ | 24 |
| ⟨1, 0⟩ and ⟨−1, 0⟩ | -1 |
| ⟨2, −1, 5⟩ and ⟨0, 3, 1⟩ | 2 |
Common questions about the Vector Calculator
- How do I find the dot product?
- Multiply matching components and add: ⟨1, 2, 3⟩ · ⟨4, 5, 6⟩ = 1 × 4 + 2 × 5 + 3 × 6 = 32. The result is a single number. It is zero exactly when the vectors are perpendicular, positive when they point roughly the same way and negative when they point roughly opposite ways.
- How do I find the cross product?
- By the formula a × b = ⟨a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁⟩. For ⟨1, 2, 3⟩ and ⟨4, 5, 6⟩ that is ⟨−3, 6, −3⟩. The result is a vector perpendicular to both, and its length is the area of the parallelogram they span. Swapping the order flips its sign.
- Can I take the cross product of 2D vectors?
- Strictly, no: the cross product is defined for three-dimensional vectors. A common convention, used here, treats 2D vectors as lying flat in the xy-plane with z = 0. The cross product then points straight up or down, ⟨0, 0, a₁b₂ − a₂b₁⟩, and that last number is what people often call the 2D cross product.
- How do I find the angle between two vectors?
- From cos θ = a · b ÷ (‖a‖‖b‖). For ⟨3, 4⟩ and ⟨4, 3⟩ that is 24 ÷ 25, so θ is about 16.26°. The page computes the same angle from the cross and dot products together, which stays accurate when the vectors are nearly parallel. A zero vector has no direction, so no angle.