Dot Product Calculator (with Angle Between Vectors)

  • Free
  • No sign-up
  • Works on phones
  • Shows the working
Vectors & Matrices#58

Dot Product & Angle

\(u \cdot v\), the lengths, the angle between the vectors and the projection of u onto v (2D, 3D or more).

This dot product calculator multiplies two vectors the dot-product way and then uses the result to find the angle between them, the scalar projection and the vector projection. It works for 2D, 3D and longer vectors (up to 6 components), shows each product in the sum, and tells you when the vectors are perpendicular or parallel.

It’s free and needs no sign-up.

Dot Product Calculator (with Angle Between Vectors): The dot product of u = ⟨4, 1⟩ and v = ⟨1, 3⟩ is 4·1 + 1·3 = 7, and it…
The dot product of u = ⟨4, 1⟩ and v = ⟨1, 3⟩ is 4·1 + 1·3 = 7, and it equals |u||v| cos θ, which gives the angle θ ≈ 57.5° between them.

How to use it

  1. Enter vector u as its components separated by commas, for example 1, 2, 3. Brackets like <1, 2, 3> or (1, 2, 3) are fine.
  2. Enter vector v with the same number of components.
  3. Press Calculate.

Formulas

The dot product multiplies matching components and adds:

$$u cdot v = u_1v_1 + u_2v_2 + cdots + u_nv_n$$

It is also related to the lengths and the angle ( theta ) between the vectors:

$$u cdot v = |u||v|costheta qquadRightarrowqquad costheta = frac{u cdot v}{|u||v|}$$

The scalar projection (component) of u onto v and the vector projection are

$$text{comp}_v u = frac{u cdot v}{|v|}, qquad text{proj}_v u = frac{u cdot v}{|v|^2},v$$

Worked example: two 3D vectors

For ( u = langle 1, 2, 3 rangle ) and ( v = langle 4, -5, 6 rangle ) (as loaded above):

Cookies forming a simple addition equation on graph paper.

$$u cdot v = (1)(4) + (2)(-5) + (3)(6) = 4 - 10 + 18 = 12$$

The lengths are ( |u| = sqrt{1 + 4 + 9} = sqrt{14} ) and ( |v| = sqrt{16 + 25 + 36} = sqrt{77} ), so

$$costheta = frac{12}{sqrt{14}sqrt{77}} approx 0.3655, qquad theta approx 68.56^circ$$

Worked example: testing for perpendicular vectors

For ( u = langle 2, -1 rangle ) and ( v = langle 1, 2 rangle ): ( u cdot v = 2 – 2 = 0 ). A dot product of zero means ( costheta = 0 ), so ( theta = 90^circ ): the vectors are perpendicular (orthogonal). This is the quickest perpendicularity test there is.

Worked example: work done by a force

In physics, work is the dot product of force and displacement: ( W = F cdot d ). A force ( F = langle 3, 4 rangle ) newtons moves an object along ( d = langle 5, 0 rangle ) metres. Then ( W = 3 cdot 5 + 4 cdot 0 = 15 ) joules. Only the part of the force along the motion does work; the vertical 4 N contributes nothing.

An old man pushing a cart full of terracotta pots.

What the sign tells you

  • ( u cdot v > 0 ): the angle is acute (less than 90°); the vectors point roughly the same way.
  • ( u cdot v = 0 ): the vectors are perpendicular.
  • ( u cdot v < 0 ): the angle is obtuse; conversely, they point roughly in opposite directions.

Using a dot product calculator to find applications

The dot product gives the directional derivative ( D_u f = nabla f cdot hat{u} ) (see gradient and directional derivative), the angle formula in the law of cosines, work in physics, and the “similarity” of vectors in data science. Its partner, the cross product, gives a vector instead of a number.

Common mistakes

  • Multiplying to get a vector. The dot product of two vectors is a single number (a scalar).
  • Mixing degrees and radians. The calculator gives the angle in both.
  • Vectors of different lengths. The dot product is only defined when both have the same number of components.

Step-by-step method

  1. Multiply the first components, the second components, and so on.
  2. Add the products: that is ( u cdot v ).
  3. For the angle, find ( |u| ) and ( |v| ). Next, divide ( u cdot v ) by their product, and take the inverse cosine.
  4. For the projection, multiply v by ( frac{u cdot v}{|v|^2} ).

Worked example: angle between two 2D vectors

For ( u = langle 3, 4 rangle ) and ( v = langle 4, 3 rangle ): ( u cdot v = 12 + 12 = 24 ) and ( |u| = |v| = 5 ), so

$$costheta = frac{24}{25} = 0.96, qquad theta approx 16.26^circ$$

Worked example: a projection

Project ( u = langle 2, 3 rangle ) onto ( v = langle 4, 0 rangle ): ( u cdot v = 8 ) and ( |v|^2 = 16 ), so ( text{proj}_v u = frac{8}{16}langle 4, 0 rangle = langle 2, 0 rangle ). The projection is the “shadow” of u on the line of v. Here v lies along the x-axis, so the shadow is just the x-part of u.

Properties

  • Commutative: ( u cdot v = v cdot u ).
  • Distributive: ( u cdot (v + w) = u cdot v + u cdot w ).
  • Scalars: ( (cu) cdot v = c(u cdot v) ).
  • Length: ( u cdot u = |u|^2 ).
  • Cauchy–Schwarz: ( |u cdot v| le |u||v| ), which is why ( costheta ) always lands between −1 and 1.

Applications

Besides work and the angle between vectors, the dot product tests whether lines and planes are perpendicular, finds the component of a force along a ramp, computes lighting in computer graphics (brightness depends on the angle between a surface normal and the light), and measures similarity between documents or user profiles in machine learning (cosine similarity).

Practice problems

  1. ( langle 2, 3 rangle cdot langle 4, -1 rangle ).
  2. Are ( langle 1, 0, -1 rangle ) and ( langle 2, 2, 2 rangle ) perpendicular?
  3. Find the angle between ( langle 1, 1 rangle ) and ( langle 0, 1 rangle ).

Answers: 1. ( 8 – 3 = 5 ). 2. Yes: ( 2 + 0 – 2 = 0 ). 3. ( costheta = frac{1}{sqrt{2}} ), so ( theta = 45^circ ).

The dot product as a matrix product

Written as columns, ( u cdot v = u^{T}v ): a 1×n row times an n×1 column gives a 1×1 result. Also, every entry of a matrix product is a dot product of a row with a column. This is why the dot product sits at the heart of matrix multiplication. The standard basis vectors are mutually perpendicular: ( mathbf{i} cdot mathbf{j} = mathbf{j} cdot mathbf{k} = mathbf{i} cdot mathbf{k} = 0 ) and each has dot product 1 with itself.

People using calculators and writing, possibly studying or doing math.

Worked example: angle between diagonals of a cube

The diagonal of a unit cube from the origin is ( langle 1, 1, 1 rangle ) and the diagonal of one face is ( langle 1, 1, 0 rangle ). Their dot product is 2, and their lengths are ( sqrt{3} ) and ( sqrt{2} ), so ( costheta = frac{2}{sqrt{6}} ) and ( theta approx 35.26^circ ).

Related guides

Further reading

FAQ

What is the dot product?

The sum of the products of matching components of two vectors: ( u cdot v = u_1v_1 + u_2v_2 + u_3v_3 ). Also, it equals ( |u||v|costheta ).

How do you find the angle between two vectors?

Compute ( costheta = frac{u cdot v}{|u||v|} ) and take the inverse cosine.

What does a dot product of zero mean?

The vectors are perpendicular (at right angles), assuming neither is the zero vector.

Is the dot product the same as the scalar product?

Yes. “Dot product”, “scalar product” and “inner product” (in ordinary space) all mean the same thing.

Can the dot product be greater than the product of the lengths?

No. ( |u cdot v| le |u||v| ) always, with equality only when the vectors are parallel.

What is the dot product of a vector with itself?

The square of its length: ( u cdot u = |u|^2 ).

Embed this calculator on your website

Teachers, tutors and bloggers are welcome to use this calculator for free. Copy the code below and paste it into any page (in WordPress, use a "Custom HTML" block). The small script makes the calculator grow to fit its answer; if your site removes scripts, it still works at a fixed height. Please keep the credit link.

More calculators

See all calculators