The dot product or scalar product of and is . The resulting value is a scalar. The dot product is 0 when the vectors are orthogonal to each other.

  • length of A (or B) times the length of A (or B) in the direction of B (or A), a.k.a the length of the other side of the triangle
  • is the acute or flat angle between and

The dot product is equal to the sum of the product of the corresponding components. For example, if they are two dimensional, then:

# assume u, v are two tuples of arbitrary dimensions
assert len(u) == len(v)
u_dot_v = sum([u_i * v_i for u_i, v_i in zip(u, v)])