dot

dot(A, B)

A * B

Try it yourself:

See also:

dot(): The Dot Product of Vectors

dot() calculates an inner, or dot, product. For vectors it multiplies corresponding entries and adds the results. The dot product connects direction and magnitude, making it fundamental in geometry, projections, graphics, and statistics.

Angle and projection

For normalized vectors, dot(a, b) equals the cosine of the angle between them. A positive result means similar direction, zero means perpendicular, and a negative result means opposite direction. Use acos() to turn a normalized dot product into an angle, and norm() to find lengths for normalization.

Vectors must have compatible lengths; matrix products additionally require matching inner dimensions. Do not confuse dot with dotMultiply(), which returns element-wise products, or multiply(), which performs general multiplication.

Practical checks

Use size() when dimensions come from data. In floating-point work, a near-zero dot product indicates approximate perpendicularity, not necessarily exact zero.

Try Dot in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions