Skip to content

Vector Calculator: Magnitude, Dot Product and Angle

Magnitude, unit vector, sum, difference, dot product, angle between vectors and projection, in 2D or 3D.

Your details

Dimension

Results update as you type

Angle θ (degrees)

45 °

Dot product A · B
6
Angle θ (radians)
0.785398 rad
Angle θ (exact)
π/4 rad
cos θ
√2/2 ≈ 0.707107
Position of the vectors
Neither parallel nor perpendicular

Step-by-step solution
  1. Dot product: A · B = 2 × 0 + 2 × 3 = 6
  2. Magnitude: |A| = √8 = 2√2, |B| = √9 = 3
  3. Cosine of the angle: cos θ = (A · B) / (|A| |B|) = √2/2 ≈ 0.707107
  4. Angle: θ = arccos(0.707107) = 45° = π/4 rad

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 222\sqrt{2}, 22\frac{\sqrt{2}}{2} or π4\frac{\pi}{4}, 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

  1. Pick the operation from the list.
  2. Choose 2D or 3D.
  3. 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.
  4. For a scalar multiple, enter the number k.
  5. 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 a⃗=(a1,a2,a3)\vec a = (a_1, a_2, a_3) and b⃗=(b1,b2,b3)\vec b = (b_1, b_2, b_3) (drop the third component in 2D):

∥a⃗∥=a12+a22+a32a^=a⃗∥a⃗∥\|\vec a\| = \sqrt{a_1^2 + a_2^2 + a_3^2} \qquad \hat a = \frac{\vec a}{\|\vec a\|}

Addition, subtraction and scalar multiplication work component by component: a⃗+b⃗=(a1+b1,a2+b2,a3+b3)\vec a + \vec b = (a_1 + b_1, a_2 + b_2, a_3 + b_3) and ka⃗=(ka1,ka2,ka3)k\vec a = (ka_1, ka_2, ka_3).

The dot product multiplies matching components and adds them:

a⃗⋅b⃗=a1b1+a2b2+a3b3=∥a⃗∥ ∥b⃗∥cos⁡θ\vec a \cdot \vec b = a_1 b_1 + a_2 b_2 + a_3 b_3 = \|\vec a\|\,\|\vec b\| \cos\theta

so the angle between two non-zero vectors is

θ=arccos⁡(a⃗⋅b⃗∥a⃗∥ ∥b⃗∥),0≤θ≤π\theta = \arccos\left(\frac{\vec a \cdot \vec b}{\|\vec a\|\,\|\vec b\|}\right), \quad 0 \le \theta \le \pi

The projection of a⃗\vec a onto b⃗\vec b is proj⁡b⃗a⃗=a⃗⋅b⃗∥b⃗∥2 b⃗\operatorname{proj}_{\vec b}\vec a = \frac{\vec a \cdot \vec b}{\|\vec b\|^2}\,\vec b, and the scalar projection is a⃗⋅b⃗∥b⃗∥\frac{\vec a \cdot \vec b}{\|\vec b\|}. The vector from PP to QQ is PQ→=Q−P\overrightarrow{PQ} = Q - P.

Worked example

Take a⃗=(2,2)\vec a = (2, 2) and b⃗=(0,3)\vec b = (0, 3).

  • Magnitude: ∥a⃗∥=4+4=8=22≈2.828\|\vec a\| = \sqrt{4 + 4} = \sqrt{8} = 2\sqrt{2} \approx 2.828, so the unit vector is (22,22)\left(\frac{\sqrt{2}}{2}, \frac{\sqrt{2}}{2}\right).
  • Dot product: 2×0+2×3=62 \times 0 + 2 \times 3 = 6.
  • Angle: cos⁡θ=622×3=22\cos\theta = \frac{6}{2\sqrt{2} \times 3} = \frac{\sqrt{2}}{2}, so θ=45°=π/4\theta = 45° = π/4.
  • Projection of a⃗\vec a on b⃗\vec b: $\frac{6}{9}(0, 3) = $ (0, 2), the "shadow" of a⃗\vec a on the vertical axis.

In 3D, the angle between (1,1,1)(1, 1, 1) and (2,−1,−3)(2, -1, -3) is arccos⁡(−2314)≈107.98°\arccos\left(\frac{-2}{\sqrt{3}\sqrt{14}}\right) \approx 107.98°, 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 a⃗⋅b⃗\vec a \cdot \vec b tells you at once:

Dot product Angle Meaning
positive 0°≤θ<90°0° \le \theta < 90° the vectors point roughly the same way
zero θ=90°\theta = 90° perpendicular (orthogonal)
negative 90°<θ≤180°90° < \theta \le 180° they point roughly in opposite ways

Two vectors are parallel when one is a multiple of the other; then ∣cos⁡θ∣=1|\cos\theta| = 1 and the angle is 0° or 180°. Testing a⃗⋅b⃗=0\vec a \cdot \vec b = 0 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 W=F⃗⋅d⃗W = \vec F \cdot \vec d, 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

Last updated:

More Math calculators

People also use