Linear Algebra

Vector Calculator

This vector calculator finds the dot product a · b = a₁b₁ + a₂b₂ + … + aₙbₙ of two vectors with 2 to 6 components, then the angle between them, each magnitude and unit vector, the scalar and vector projections, and the sum and difference, all kept exact.

Try

2 to 6 numbers separated by commas or spaces, for example 1, 2, 2 for 1i + 2j + 2k. Use decimals such as 0.5 (fractions are not accepted here).

Same number of components as a.

Result

Dot product a · b: 4

Dot product a · b

a→⋅b→=4\vec{a} \cdot \vec{b} = 4

|a| (magnitude of a)
33
|b| (magnitude of b)
33
Angle θ between a and bcos θ = 4/9
63.61220004° (1.110242335 rad)
a + b
(3,1,4)\left(3, 1, 4\right)
a − b
(−1,3,0)\left(-1, 3, 0\right)
Cross product a × b
(6,2,−5)\left(6, 2, -5\right)
Unit vector â = a/|a|
(13,23,23)\left(\frac{1}{3}, \frac{2}{3}, \frac{2}{3}\right)
Scalar projection of a onto b
43\frac{4}{3}
Vector projection of a onto b
(89,−49,89)\left(\frac{8}{9}, -\frac{4}{9}, \frac{8}{9}\right)

a · b = 4. It is positive, so the vectors point in broadly the same direction: the angle between them is 63.61220004°.

Step-by-step working (2 steps)
  1. Dot product

    Multiply matching components and add the products.

    a→⋅b→=1⋅2+2⋅(−1)+2⋅2=4\vec{a} \cdot \vec{b} = 1 \cdot 2 + 2 \cdot \left(-1\right) + 2 \cdot 2 = 4
  2. Interpret the sign

    The dot product is positive, so the angle between the vectors is acute (less than 90°).

For a × b with the i, j, k determinant, use the cross product calculator.

By Hira Noor, mathematicianLast reviewed Free, no sign-up, runs in your browserReport a problem

How to use this calculator

  1. Keep Dot product a · b as the main result, or choose the angle, projection, magnitude and unit vector, sum or cross product. Every other quantity is listed underneath as well.
  2. Type the components of a, separated by commas or spaces. For a = i + 2j + 2k, type 1, 2, 2. Decimals and negative numbers are fine.
  3. Type b with the same number of components, from 2 up to 6.
  4. Read the steps under the result. For 2D vectors a diagram shows a and b (and a + b or the projection when you choose those).

Formulas

Dot product and the angle between two vectors

a→⋅b→=a1b1+a2b2+⋯+anbn,cos⁡θ=a→⋅b→|a→||b→|\vec{a} \cdot \vec{b} = a_1 b_1 + a_2 b_2 + \cdots + a_n b_n, \qquad \cos\theta = \frac{\vec{a} \cdot \vec{b}}{\left|\vec{a}\right|\left|\vec{b}\right|}

Plain-text formula: vec(a) · vec(b) = a_1b_1 + a_2b_2 + ⋯ + a_nb_n, cos θ = (vec(a) · vec(b))/(|vec(a)||vec(b)|)

The algebraic sum equals |a→||b→|cos⁡θ|\vec{a}||\vec{b}|\cos\theta, which is how the angle is found. The dot product is 0 exactly when the vectors are perpendicular.

Magnitude and unit vector

|a→|=a12+⋯+an2,a^=a→|a→|\left|\vec{a}\right| = \sqrt{a_1^2 + \cdots + a_n^2}, \qquad \hat{a} = \frac{\vec{a}}{\left|\vec{a}\right|}

Plain-text formula: |vec(a)| = √(a_1^2 + ⋯ + a_n^2), a^ = vec(a)/|vec(a)|

The magnitude is the length (Euclidean norm). Dividing by it gives a vector of length 1 in the same direction, which is undefined for the zero vector.

Projection of a onto b

compb→a→=a→⋅b→|b→|,projb→a→=a→⋅b→|b→|2b→\operatorname{comp}_{\vec{b}}\vec{a} = \frac{\vec{a} \cdot \vec{b}}{\left|\vec{b}\right|}, \qquad \operatorname{proj}_{\vec{b}}\vec{a} = \frac{\vec{a} \cdot \vec{b}}{\left|\vec{b}\right|^2}\,\vec{b}

Plain-text formula: comp_vec(b)vec(a) = (vec(a) · vec(b))/|vec(b)|, proj_vec(b)vec(a) = (vec(a) · vec(b))/|vec(b)|^2 vec(b)

The scalar projection is the signed length of the shadow of a on the line through b; the vector projection is that shadow as a vector.

Sum and difference

a→±b→=(a1±b1,;a2±b2,;…,;an±bn)\vec{a} \pm \vec{b} = \left(a_1 \pm b_1,; a_2 \pm b_2,; \ldots,; a_n \pm b_n\right)

Plain-text formula: vec(a) ± vec(b) = (a_1 ± b_1, ;a_2 ± b_2, ;…, ;a_n ± b_n)

Vectors add and subtract component by component. In 2D, a + b is the diagonal of the parallelogram on a and b.

Reading the result

The sign of the dot product tells you the type of angle: positive means acute (under 90°), zero means perpendicular, negative means obtuse. The angle itself is always between 0° and 180°.

The dot product is a number, not a vector, and the order does not matter: a→⋅b→=b→⋅a→\vec{a} \cdot \vec{b} = \vec{b} \cdot \vec{a}. The cross product, by contrast, is a vector that flips sign when you swap the order.

A zero vector has length 0 and no direction, so the angle, the unit vector and projection onto it are undefined. The calculator says so instead of returning a misleading number.

How to calculate a dot product

Multiply the matching components and add the products. For a = (1, 2, 2) and b = (2, −1, 2): a→⋅b→=(1)(2)+(2)(−1)+(2)(2)=2−2+4=4\vec{a} \cdot \vec{b} = (1)(2) + (2)(-1) + (2)(2) = 2 - 2 + 4 = 4.

The same rule works in any dimension, as long as both vectors have the same number of components. In 4D, (1, 2, 3, 4) · (1, 0, 1, 0) = 1 + 0 + 3 + 0 = 4.

How to find the angle between two vectors

Divide the dot product by the product of the lengths and take the inverse cosine: θ=arccos(a→⋅b→|a→||b→|)\theta = \arccos\left(\frac{\vec{a} \cdot \vec{b}}{|\vec{a}||\vec{b}|}\right). For a = (1, 2, 2) and b = (2, −1, 2), the dot product is 4 and both lengths are 3, so cos⁡θ=49\cos\theta = \frac{4}{9} and θ≈63.61°\theta \approx 63.61° (about 1.1102 radians).

The cross product gives the same angle from the other side: sin⁡θ=|a→×b→||a→||b→|\sin\theta = \frac{|\vec{a} \times \vec{b}|}{|\vec{a}||\vec{b}|}. Use the dot product form in practice, because arcsine cannot tell an acute angle from an obtuse one.

Cross product vs dot product

Both products multiply two vectors, but they answer different questions. The dot product measures how much two vectors point the same way; the cross product measures how much they turn away from each other, and in which direction. The cross product calculator shows the i, j, k determinant, the right-hand rule and the triple products in full.

Cross product and dot product compared
Cross product a→×b→\vec{a} \times \vec{b}Dot product a→⋅b→\vec{a} \cdot \vec{b}
ResultA vectorA number (scalar)
Dimensions3D (2D as the plane z = 0)Any number of components
Size|a→||b→|sin⁡θ|\vec{a}||\vec{b}|\sin\theta|a→||b→|cos⁡θ|\vec{a}||\vec{b}|\cos\theta
Zero whenThe vectors are parallelThe vectors are perpendicular
Orderb→×a→=−(a→×b→)\vec{b} \times \vec{a} = -(\vec{a} \times \vec{b})b→⋅a→=a→⋅b→\vec{b} \cdot \vec{a} = \vec{a} \cdot \vec{b}
Typical useNormal vectors, areas, torqueAngles, projections, work

Where the dot product is used

Work. A constant force F→\vec{F} moving an object along d→\vec{d} does work W=F→⋅d→W = \vec{F} \cdot \vec{d}. Only the part of the force along the motion counts.

Perpendicular tests. Two nonzero vectors are perpendicular exactly when their dot product is 0, which is the quickest way to check right angles in coordinate geometry.

Projections and shadows. The projection of a onto b splits a into a part along b and a part at right angles to it, as in resolving forces on a slope.

Similarity of data. Cosine similarity, a→⋅b→|a→||b→|\frac{\vec{a} \cdot \vec{b}}{|\vec{a}||\vec{b}|}, compares the direction of two lists of numbers and is widely used in search and recommendation systems.

Worked example

Dot product and angle of two 3D vectors

Find a · b and the angle between a = (1, 2, 2) and b = (2, −1, 2).

  1. Dot product: (1)(2)+(2)(−1)+(2)(2)=2−2+4=4(1)(2) + (2)(-1) + (2)(2) = 2 - 2 + 4 = 4.
  2. Magnitudes: |a→|=1+4+4=3|\vec{a}| = \sqrt{1 + 4 + 4} = 3 and |b→|=4+1+4=3|\vec{b}| = \sqrt{4 + 1 + 4} = 3.
  3. Cosine: cos⁡θ=43⋅3=49\cos\theta = \frac{4}{3 \cdot 3} = \frac{4}{9}.
  4. Angle: θ=arccos⁡49≈63.61°\theta = \arccos\frac{4}{9} \approx 63.61°, about 1.1102 radians. The dot product is positive, so the angle is acute.

Answer: a · b = 4 and the angle between the vectors is about 63.61°.

Frequently asked questions

How do I calculate a dot product?

Multiply the matching components of the two vectors and add the results. For (1, 2, 2) and (2, −1, 2) that is 2 − 2 + 4 = 4. Both vectors must have the same number of components.

How do I find the angle between two vectors?

Divide the dot product by the product of the two lengths and take the inverse cosine: θ = arccos(a · b / (|a||b|)). For (1, 2, 2) and (2, −1, 2), cos θ = 4/9, so θ ≈ 63.61°.

What does a dot product of zero mean?

The vectors are perpendicular (orthogonal), as long as neither is the zero vector. For example, (2, 1) · (−1, 2) = −2 + 2 = 0, so these vectors meet at exactly 90°.

What is the difference between scalar and vector projection?

The scalar projection is a number: the signed length of a’s shadow along b. The vector projection is that length times the unit vector of b. For a = (1, 2, 3, 4) and b = (1, 0, 1, 0), the scalar projection is 2√2 and the vector projection is (2, 0, 2, 0).

How do I find a unit vector?

Divide each component by the vector’s magnitude. For (3, 4, 12) the magnitude is √(9 + 16 + 144) = 13, so the unit vector is (3/13, 4/13, 12/13). The zero vector has no unit vector.

Can this vector calculator find a cross product?

Yes, choose Cross product a × b for two 3D vectors. For the full i, j, k determinant steps, 2D vectors, fractions, the unit normal and the triple products of three vectors, use the cross product calculator.

Cross Product Calculator

a × b with i, j, k determinant steps, magnitude, unit normal, angle and area, plus triple products.

Linear Algebra

Determinant Calculator

Exact determinants of 2x2 to 6x6 matrices by row reduction or cofactor expansion, with every step.

Linear Algebra

Matrix Calculator

Multiply, add and subtract matrices up to 6 × 6, plus determinant, inverse, transpose and powers, exactly.

Linear Algebra

Midpoint Calculator

Midpoint of two points in 2D or 3D, with steps, distance, a graph and the missing-endpoint solver.

Algebra & Equations

Scientific Calculator

Type or tap expressions with exact fractions, memory, variables, constants and complex mode.

Tools

Learn more: For typing vectors and matrices in the full calculator, read matrices and vectors.

Sources and further reading

  1. The Dot Product (Section 2.3, Calculus Volume 3) (opens in a new tab), OpenStax, Rice University (Gilbert Strang and Edwin Herman, 2016)
  2. Vectors in Space (Section 2.2, Calculus Volume 3) (opens in a new tab), OpenStax, Rice University (Gilbert Strang and Edwin Herman, 2016)
  3. 18.02SC Multivariable Calculus: Vectors and Matrices (opens in a new tab), MIT OpenCourseWare
  4. 18.06 Linear Algebra (Gilbert Strang) (opens in a new tab), MIT OpenCourseWare

Results are calculated in your browser with methods checked by automated tests, and are intended for learning and general use. For engineering, medical, financial, legal or safety-critical decisions, verify important values independently and follow the rounding rules your work requires. How accurate are these results?