A vector carries two pieces of information at once: a length and a direction. Forces, velocities, displacements on a map and the edges of a 3D model are all vectors, and most problems about them come down to a handful of operations. This calculator does each of them in 2D or 3D, with every step written out: the magnitude and unit vector, the sum and difference of two vectors, a scalar multiple, the dot product, the angle between two vectors, the projection of one vector onto another, and the vector joining two points.
Results come as decimals and, whenever the components are whole numbers or simple fractions, as exact values such as , or , which is what a textbook answer key expects. For the angle, the calculator also tells you whether the vectors are perpendicular, parallel or neither.
Need the vector perpendicular to two others, or the area they span? Use the cross product calculator, which works in 3D.
How to use this calculator
- Pick the operation from the list.
- Choose 2D or 3D.
- Enter the components of vector A (and B when the operation needs two vectors). For "vector from two points", enter the start point P and the end point Q instead.
- For a scalar multiple, enter the number k.
- Read the result. The exact value appears under the decimal one when it involves fractions or square roots, and the steps show each sum and product.
The formula
For and (drop the third component in 2D):
Addition, subtraction and scalar multiplication work component by component: and .
The dot product multiplies matching components and adds them:
so the angle between two non-zero vectors is
The projection of onto is , and the scalar projection is . The vector from to is .
Worked example
Take and .
- Magnitude: , so the unit vector is .
- Dot product: .
- Angle: , so .
- Projection of on : $\frac{6}{9}(0, 3) = $ (0, 2), the "shadow" of on the vertical axis.
In 3D, the angle between and is , slightly obtuse because the dot product is negative.
Reading the sign of the dot product
You often do not need the exact angle, only its type, and the sign of tells you at once:
| Dot product | Angle | Meaning |
|---|---|---|
| positive | the vectors point roughly the same way | |
| zero | perpendicular (orthogonal) | |
| negative | they point roughly in opposite ways |
Two vectors are parallel when one is a multiple of the other; then and the angle is 0° or 180°. Testing is the standard way to prove that two lines, two edges or two forces are perpendicular.
Where these operations are used
In physics, the work done by a constant force is , so only the part of the force along the motion counts; that part is exactly the scalar projection. Adding velocity vectors gives the ground speed of a plane in a crosswind. In computer graphics, normalised (unit) vectors and dot products decide how brightly a surface is lit. In data science, the cosine of the angle between two vectors (the cosine similarity) measures how alike two documents or profiles are, independently of their length.
Frequently asked questions
How do I find the angle between two vectors?
Divide the dot product by the product of the two magnitudes, then take the arccosine: θ = arccos(a·b / (|a| |b|)). For (2, 2) and (0, 3): 6 / (2√2 × 3) = √2/2, so θ = 45°. The result is always between 0° and 180°.
What is the magnitude of a vector?
Its length, found with Pythagoras: the square root of the sum of the squared components. The vector (3, 4) has magnitude √(9 + 16) = 5; in 3D, (1, 2, 2) has magnitude √9 = 3.
Why is the angle undefined for the zero vector?
The zero vector has length 0 and points nowhere, so the formula would divide by zero. Its dot product with any vector is 0, but it is not "perpendicular" in a useful sense, which is why the calculator reports an error instead of 90°.
What is the difference between vector and scalar projection?
The scalar projection (a·b)/|b| is a signed length: how far a reaches along the direction of b. The vector projection multiplies the unit vector of b by that length, giving a vector parallel to b. A negative scalar projection means a points partly against b.
How do I get the vector between two points?
Subtract the coordinates of the starting point from those of the end point: from P(1, 1) to Q(8, 5), PQ = (8 − 1, 5 − 1) = (7, 4). Its magnitude is the distance between the points.
Sources
- OpenStax, Calculus Volume 3 — §2.1 Vectors in the Plane
- OpenStax, Calculus Volume 3 — §2.2 Vectors in Three Dimensions
- OpenStax, Calculus Volume 3 — §2.3 The Dot Product
- Gilbert Strang, Introduction to Linear Algebra (MIT), ch. 1 Vectors and lengths
Last updated: