Dot product

Short description: Algebraic operation on coordinate vectors

"Scalar product" redirects here. For the abstract scalar product, see Inner product space. For the product of a vector and a scalar, see Scalar multiplication.

In mathematics, the dot product or scalar product[note 1] is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors), and returns a single number. In Euclidean geometry, the dot product of the Cartesian coordinates of two vectors is widely used. It is often called the inner product (or rarely the projection product) of Euclidean space, even though it is not the only inner product that can be defined on Euclidean space (see Inner product space for more). It should not be confused with the cross product.

Algebraically, the dot product is the sum of the products of the corresponding entries of the two sequences of numbers. Geometrically, it is the product of the Euclidean magnitudes of the two vectors and the cosine of the angle between them. These definitions are equivalent when using Cartesian coordinates. In modern geometry, Euclidean spaces are often defined by using vector spaces. In this case, the dot product is used for defining lengths (the length of a vector is the square root of the dot product of the vector by itself) and angles (the cosine of the angle between two vectors is the quotient of their dot product by the product of their lengths).

The name "dot product" is derived from the dot operator " ⋅ " that is often used to designate this operation;[1] the alternative name "scalar product" emphasizes that the result is a scalar, rather than a vector (as with the vector product in three-dimensional space).

## Contents

* 1 Definition
* 1.1 Coordinate definition
* 1.2 Geometric definition
* 1.3 Scalar projection and first properties
* 1.4 Equivalence of the definitions
* 2 Properties
* 2.1 Application to the law of cosines
* 3 Triple product
* 4 Physics
* 5 Generalizations
* 5.1 Complex vectors
* 5.2 Inner product
* 5.3 Functions
* 5.4 Weight function
* 5.5 Dyadics and matrices
* 5.6 Tensors
* 6 Computation
* 6.1 Algorithms
* 6.2 Libraries
* 7 See also
* 8 Notes
* 9 References
* 10 External links

## Definition

The dot product may be defined algebraically or geometrically. The geometric definition is based on the notions of angle and distance (magnitude) of vectors. The equivalence of these two definitions relies on having a Cartesian coordinate system for Euclidean space.

In modern presentations of Euclidean geometry, the points of space are defined in terms of their Cartesian coordinates, and Euclidean space itself is commonly identified with the real coordinate space 𝐑n. In such a presentation, the notions of length and angle are defined by means of the dot product. The length of a vector is defined as the square root of the dot product of the vector by itself, and the cosine of the (non oriented) angle between two vectors of length one is defined as their dot product. So the equivalence of the two definitions of the dot product is a part of the equivalence of the classical and the modern formulations of Euclidean geometry.

### Coordinate definition

The dot product of two vectors 𝐚=[a1,a2,⋯,an] and 𝐛=[b1,b2,⋯,bn], specified with respect to an orthonormal basis, is defined as:[2] 𝐚⋅𝐛=∑i=1naibi=a1b1+a2b2+⋯+anbn where Σ (sigma) denotes summation and n is the dimension of the vector space. For instance, in three-dimensional space, the dot product of vectors [1,3,−5] and [4,−2,−1] is:  [1,3,−5]⋅[4,−2,−1]=(1×4)+(3×−2)+(−5×−1)=4−6+5=3

Likewise, the dot product of the vector [1,3,−5] with itself is:  [1,3,−5]⋅[1,3,−5]=(1×1)+(3×3)+(−5×−5)=1+9+25=35

If vectors are identified with column vectors, the dot product can also be written as a matrix product 𝐚⋅𝐛=𝐚T𝐛, where 𝐚T denotes the transpose of 𝐚.

Expressing the above example in this way, a 1 × 3 matrix (row vector) is multiplied by a 3 × 1 matrix (column vector) to get a 1 × 1 matrix that is identified with its unique entry: [13−5][4−2−1]=3.

### Geometric definition

Illustration showing how to find the angle between vectors using the dot product Calculating bond angles of a symmetrical tetrahedral molecular geometry using a dot product

In Euclidean space, a Euclidean vector is a geometric object that possesses both a magnitude and a direction. A vector can be pictured as an arrow. Its magnitude is its length, and its direction is the direction to which the arrow points. The magnitude of a vector 𝐚 is denoted by ‖𝐚‖. The dot product of two Euclidean vectors 𝐚 and 𝐛 is defined by[3][4][1] 𝐚⋅𝐛=‖𝐚‖‖𝐛‖cos⁡θ, where θ is the angle between 𝐚 and 𝐛.

In particular, if the vectors 𝐚 and 𝐛 are orthogonal (i.e., their angle is π2 or 90∘), then cos⁡π2=0, which implies that 𝐚⋅𝐛=0. At the other extreme, if they are codirectional, then the angle between them is zero with cos⁡0=1 and 𝐚⋅𝐛=‖𝐚‖‖𝐛‖ This implies that the dot product of a vector 𝐚 with itself is 𝐚⋅𝐚=‖𝐚‖2, which gives ‖𝐚‖=𝐚⋅𝐚, the formula for the Euclidean length of the vector.

### Scalar projection and first properties

Scalar projection

The scalar projection (or scalar component) of a Euclidean vector 𝐚 in the direction of a Euclidean vector 𝐛 is given by ab=‖𝐚‖cos⁡θ, where θ is the angle between 𝐚 and 𝐛.

In terms of the geometric definition of the dot product, this can be rewritten as ab=𝐚⋅𝐛^, where 𝐛^=𝐛/‖𝐛‖ is the unit vector in the direction of 𝐛.

Distributive law for the dot product

The dot product is thus characterized geometrically by[5] 𝐚⋅𝐛=ab‖𝐛‖=ba‖𝐚‖. The dot product, defined in this manner, is homogeneous under scaling in each variable, meaning that for any scalar α, (α𝐚)⋅𝐛=α(𝐚⋅𝐛)=𝐚⋅(α𝐛). It also satisfies the distributive law, meaning that 𝐚⋅(𝐛+𝐜)=𝐚⋅𝐛+𝐚⋅𝐜.

These properties may be summarized by saying that the dot product is a bilinear form. Moreover, this bilinear form is positive definite, which means that 𝐚⋅𝐚 is never negative, and is zero if and only if 𝐚=𝟎, the zero vector.

### Equivalence of the definitions

If 𝐞1,⋯,𝐞n are the standard basis vectors in 𝐑n, then we may write 𝐚=[a1,…,an]=∑iai𝐞i𝐛=[b1,…,bn]=∑ibi𝐞i. The vectors 𝐞i are an orthonormal basis, which means that they have unit length and are at right angles to each other. Since these vectors have unit length, 𝐞i⋅𝐞i=1 and since they form right angles with each other, if i≠j, 𝐞i⋅𝐞j=0. Thus in general, we can say that: 𝐞i⋅𝐞j=δij, where δij is the Kronecker delta.

Vector components in an orthonormal basis

Also, by the geometric definition, for any vector 𝐞i and a vector 𝐚, we note that 𝐚⋅𝐞i=‖𝐚‖‖𝐞i‖cos⁡θi=‖𝐚‖cos⁡θi=ai, where ai is the component of vector 𝐚 in the direction of 𝐞i. The last step in the equality can be seen from the figure.

Now applying the distributivity of the geometric version of the dot product gives 𝐚⋅𝐛=𝐚⋅∑ibi𝐞i=∑ibi(𝐚⋅𝐞i)=∑ibiai=∑iaibi, which is precisely the algebraic definition of the dot product. So the geometric dot product equals the algebraic dot product.

## Properties

The dot product fulfills the following properties if 𝐚, 𝐛, 𝐜 and 𝐝 are real vectors and α, β, γ and δ are scalars.[2][3]

Commutative
𝐚⋅𝐛=𝐛⋅𝐚, which follows from the definition (θ is the angle between 𝐚 and 𝐛):[6] 𝐚⋅𝐛=‖𝐚‖‖𝐛‖cos⁡θ=‖𝐛‖‖𝐚‖cos⁡θ=𝐛⋅𝐚. The commutative property can also be easily proven with the algebraic definition, and in more general spaces (where the notion of angle might not be geometrically intuitive but an analogous product can be defined) the angle between two vectors can be defined as

θ=arccos⁡(𝐚⋅𝐛‖𝐚‖‖𝐛‖).

Bilinear (additive, distributive and scalar-multiplicative in both arguments)
(α𝐚+β𝐛)⋅(γ𝐜+δ𝐝)=αγ(𝐚⋅𝐜)+αδ(𝐚⋅𝐝)+βγ(𝐛⋅𝐜)+βδ(𝐛⋅𝐝).
Not associative
Because the dot product is not defined between a scalar 𝐚⋅𝐛 and a vector 𝐜, associativity is meaningless.[7] However, bilinearity implies c(𝐚⋅𝐛)=(c𝐚)⋅𝐛=𝐚⋅(c𝐛). This property is sometimes called the "associative law for scalar and dot product",[8] and one may say that "the dot product is associative with respect to scalar multiplication".[9]
Orthogonal
Two non-zero vectors 𝐚 and 𝐛 are orthogonal if and only if 𝐚⋅𝐛=0.
No cancellation
Unlike multiplication of ordinary numbers, where if ab=ac, then b always equals c unless a is zero, the dot product does not obey the cancellation law:

If 𝐚⋅𝐛=𝐚⋅𝐜 and 𝐚≠𝟎, then we can write: 𝐚⋅(𝐛−𝐜)=0 by the distributive law; the result above says this just means that 𝐚 is perpendicular to (𝐛−𝐜), which still allows (𝐛−𝐜)≠𝟎, and therefore allows 𝐛≠𝐜.
Product rule
If 𝐚 and 𝐛 are vector-valued differentiable functions, then the derivative (denoted by a prime ') of 𝐚⋅𝐛 is given by the rule (𝐚⋅𝐛)′=𝐚′⋅𝐛+𝐚⋅𝐛′.

### Application to the law of cosines

Triangle with vector edges a and b, separated by angle θ

Main article: Law of cosines

Given two vectors 𝐚 and 𝐛 separated by angle θ (see the upper image), they form a triangle with a third side 𝐜=𝐚−𝐛. Let a, b and c denote the lengths of 𝐚, 𝐛, and 𝐜, respectively. The dot product of 𝐜 with itself is: 𝐜⋅𝐜=(𝐚−𝐛)⋅(𝐚−𝐛)=𝐚⋅𝐚−𝐚⋅𝐛−𝐛⋅𝐚+𝐛⋅𝐛=a2−𝐚⋅𝐛−𝐚⋅𝐛+b2=a2−2𝐚⋅𝐛+b2c2=a2+b2−2abcos⁡θ which is the law of cosines.

## Triple product

Main article: Triple product

There are two ternary operations involving dot product and cross product.

The scalar triple product of three vectors is defined as 𝐚⋅(𝐛×𝐜)=𝐛⋅(𝐜×𝐚)=𝐜⋅(𝐚×𝐛). Its value is the determinant of the matrix whose columns are the Cartesian coordinates of the three vectors. It is the signed volume of the parallelepiped defined by the three vectors, and is isomorphic to the three-dimensional special case of the exterior product of three vectors.

The vector triple product is defined by[2][3] 𝐚×(𝐛×𝐜)=(𝐚⋅𝐜)𝐛−(𝐚⋅𝐛)𝐜. This identity, also known as Lagrange's formula, may be remembered as "ACB minus ABC", keeping in mind which vectors are dotted together. This formula has applications in simplifying vector calculations in physics.

## Physics

In physics, the dot product takes two vectors and returns a scalar quantity. It is also known as the "scalar product". The dot product of two vectors can be defined as the product of the magnitudes of the two vectors and the cosine of the angle between the two vectors. Thus, 𝐚⋅𝐛=|𝐚||𝐛|cos⁡θ Alternatively, it is defined as the product of the projection of the first vector onto the second vector and the magnitude of the second vector.

For example:[10][11]

* Mechanical work is the dot product of force and displacement vectors,
* Power is the dot product of force and velocity.

## Generalizations

### Complex vectors

For vectors with complex entries, using the given definition of the dot product would lead to quite different properties. For instance, the dot product of a vector with itself could be zero without the vector being the zero vector (e.g. this would happen with the vector 𝐚=[1 i]). This in turn would have consequences for notions like length and angle. Properties such as the positive-definite norm can be salvaged at the cost of giving up the symmetric and bilinear properties of the dot product, through the alternative definition[12][2] 𝐚⋅𝐛=∑iaibi‾, where bi‾ is the complex conjugate of bi. When vectors are represented by column vectors, the dot product can be expressed as a matrix product involving a conjugate transpose, denoted with the superscript H: 𝐚⋅𝐛=𝐛H𝐚.

In the case of vectors with real components, this definition is the same as in the real case. The dot product of any vector with itself is a non-negative real number, and it is nonzero except for the zero vector. However, the complex dot product is sesquilinear rather than bilinear, as it is conjugate linear and not linear in 𝐚. The dot product is not symmetric, since 𝐚⋅𝐛=𝐛⋅𝐚‾. The angle between two complex vectors is then given by cos⁡θ=Re⁡(𝐚⋅𝐛)‖𝐚‖‖𝐛‖.

The complex dot product leads to the notions of Hermitian forms and general inner product spaces, which are widely used in mathematics and physics.

The self dot product of a complex vector 𝐚⋅𝐚=𝐚H𝐚, involving the conjugate transpose of a row vector, is also known as the norm squared, 𝐚⋅𝐚=‖𝐚‖2, after the Euclidean norm; it is a vector generalization of the absolute square of a complex scalar (see also: Squared Euclidean distance).

### Inner product

Main article: Inner product space

The inner product generalizes the dot product to abstract vector spaces over a field of scalars, being either the field of real numbers ℝ or the field of complex numbers ℂ. It is usually denoted using angular brackets by ⟨𝐚,𝐛⟩.

The inner product of two vectors over the field of complex numbers is, in general, a complex number, and is sesquilinear instead of bilinear. An inner product space is a normed vector space, and the inner product of a vector with itself is real and positive-definite.

### Functions

The dot product is defined for vectors that have a finite number of entries. Thus these vectors can be regarded as discrete functions: a length-n vector u is, then, a function with domain {k∈ℕ:1≤k≤n}, and ui is a notation for the image of i by the function/vector u.

This notion can be generalized to square-integrable functions: just as the inner product on vectors uses a sum over corresponding components, the inner product on functions is defined as an integral over some measure space (X,𝒜,μ):[2] ⟨u,v⟩=∫Xuvdμ.

For example, if f and g are continuous functions over a compact subset K of ℝn with the standard Lebesgue measure, the above definition becomes: ⟨f,g⟩=∫Kf(𝐱)g(𝐱)dn𝐱.

Generalized further to complex continuous functions ψ and χ, by analogy with the complex inner product above, gives: ⟨ψ,χ⟩=∫Kψ(z)χ(z)‾dz.

### Weight function

Inner products can have a weight function (i.e., a function which weights each term of the inner product with a value). Explicitly, the inner product of functions u(x) and v(x) with respect to the weight function r(x)>0 is ⟨u,v⟩r=∫abr(x)u(x)v(x)dx.

### Dyadics and matrices

A double-dot product for matrices is the Frobenius inner product, which is analogous to the dot product on vectors. It is defined as the sum of the products of the corresponding components of two matrices 𝐀 and 𝐁 of the same size: 𝐀:𝐁=∑i∑jAijBij‾=tr⁡(𝐁H𝐀)=tr⁡(𝐀𝐁H). And for real matrices, 𝐀:𝐁=∑i∑jAijBij=tr⁡(𝐁T𝐀)=tr⁡(𝐀𝐁T)=tr⁡(𝐀T𝐁)=tr⁡(𝐁𝐀T).

Writing a matrix as a dyadic, we can define a different double-dot product (see Dyadics § Product of dyadic and dyadic) however it is not an inner product.

### Tensors

The inner product between a tensor of order n and a tensor of order m is a tensor of order n+m−2, see Tensor contraction for details.

## Computation

### Algorithms

The straightforward algorithm for calculating a floating-point dot product of vectors can suffer from catastrophic cancellation. To avoid this, approaches such as the Kahan summation algorithm are used.

### Libraries

A dot product function is included in:

* BLAS level 1 real `SDOT`, `DDOT`; complex `CDOTU`, `ZDOTU = X^T * Y`, `CDOTC`, `ZDOTC = X^H * Y`
* Fortran as `dot_product(A,B)` or `sum(conjg(A) * B)`
* Julia as  `A' * B` or standard library LinearAlgebra as `dot(A, B)`
* R (programming language) as `sum(A * B)` for vectors or, more generally for matrices, as `A %*% B`
* Matlab as  `A' * B` or  `conj(transpose(A)) * B` or  `sum(conj(A) .* B)` or  `dot(A, B)`
* Python (package NumPy) as  `np.dot(A, B)` or  `np.inner(A, B)`
* GNU Octave as  `sum(conj(X) .* Y, dim)`, and similar code as Matlab
* Intel oneAPI Math Kernel Library real p?dot `dot = sub(x)'*sub(y)`; complex p?dotc `dotc = conjg(sub(x)')*sub(y)`

## See also

* Cauchy–Schwarz inequality
* Cross product
* Dot product representation of a graph
* Euclidean norm, the square-root of the self dot product
* Matrix multiplication
* Metric tensor
* Multiplication of vectors
* Outer product

## Notes

1. ↑ The term scalar product means literally "product with a scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. Not to be confused with scalar multiplication.

## References

1. ↑ 1.0 1.1 "Dot Product". https://www.mathsisfun.com/algebra/vectors-dot-product.html.
2. ↑ 2.0 2.1 2.2 2.3 2.4 S. Lipschutz; M. Lipson (2009). Linear Algebra (Schaum's Outlines) (4th ed.). McGraw Hill. ISBN 978-0-07-154352-1.
3. ↑ 3.0 3.1 3.2 M.R. Spiegel; S. Lipschutz; D. Spellman (2009). Vector Analysis (Schaum's Outlines) (2nd ed.). McGraw Hill. ISBN 978-0-07-161545-7.
4. ↑ A I Borisenko; I E Taparov (1968). Vector and tensor analysis with applications. Dover. p. 14.
5. ↑ Arfken, G. B.; Weber, H. J. (2000). Mathematical Methods for Physicists (5th ed.). Boston, MA: Academic Press. pp. 14–15. ISBN 978-0-12-059825-0.
6. ↑ Nykamp, Duane. "The dot product". https://mathinsight.org/dot_product.
7. ↑ Weisstein, Eric W. "Dot Product". From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/DotProduct.html
8. ↑ T. Banchoff; J. Wermer (1983). Linear Algebra Through Geometry. Springer Science & Business Media. p. 12. ISBN 978-1-4684-0161-5. https://archive.org/details/linearalgebrathr00banc_0/page/12/mode/2up.
9. ↑ A. Bedford; Wallace L. Fowler (2008). Engineering Mechanics: Statics (5th ed.). Prentice Hall. p. 60. ISBN 978-0-13-612915-8.
10. ↑ K.F. Riley; M.P. Hobson; S.J. Bence (2010). Mathematical methods for physics and engineering (3rd ed.). Cambridge University Press. ISBN 978-0-521-86153-3. https://archive.org/details/mathematicalmeth00rile.
11. ↑ M. Mansfield; C. O'Sullivan (2011). Understanding Physics (4th ed.). John Wiley & Sons. ISBN 978-0-47-0746370.
12. ↑ Berberian, Sterling K. (2014). Linear Algebra. Dover. p. 287. ISBN 978-0-486-78055-9.

## External links

* Hazewinkel, Michiel, ed. (2001), "Inner product", Encyclopedia of Mathematics, Springer Science+Business Media B.V. / Kluwer Academic Publishers, ISBN 978-1-55608-010-4, https://www.encyclopediaofmath.org/index.php?title=p/i051240
* Explanation of dot product including with complex vectors
* "Dot Product" by Bruce Torrence, Wolfram Demonstrations Project, 2007.

* v
* t
* e

Linear algebra

Basic concepts|

* Scalar
* Vector
* Vector space
* Scalar multiplication
* Vector projection
* Linear span
* Linear map
* Linear projection
* Linear independence
* Linear combination
* Basis
* Change of basis
* Row and column vectors
* Row and column spaces
* Orthogonality
* Kernel
* Eigenvalues and eigenvectors
* Outer product
* Inner product space
* Dot product
* Transpose
* Gram–Schmidt process
* Linear equations
* Fundamental theorem

Vector algebra|

* Cross product
* Triple product
* Seven-dimensional cross product

Multilinear algebra|

* Geometric algebra
* Exterior algebra
* Bivector
* Multivector
* Tensor
* Outermorphism

Matrices|

* Block
* Decomposition
* Invertible
* Minor
* Multiplication
* Rank
* Transformation
* Cramer's rule
* Gaussian elimination
* Determinant

Algebraic constructions|

* Dual
* Direct sum
* Function space
* Quotient
* Subspace
* Tensor product

Numerical|

* Floating-point
* MATLAB
* Numerical stability
* Basic Linear Algebra Subprograms (BLAS)
* Sparse matrix
* Comparison of linear algebra libraries
* Comparison of numerical analysis software

* Category
* Outline
* Mathematics portal
* Wikibook
* Wikiversity

* v
* t
* e

Tensors

Glossary of tensor theory

Scope|

| Mathematics|

* coordinate system
* multilinear algebra
* Euclidean geometry
* tensor algebra
* dyadic algebra
* differential geometry
* exterior calculus
* tensor calculus

|

* Physics
* Engineering

* continuum mechanics
* electromagnetism
* transport phenomena
* general relativity
* computer vision

Notation|

* index notation
* multi-index notation
* Einstein notation
* Ricci calculus
* Penrose graphical notation
* Voigt notation
* abstract index notation
* tetrad (index notation)
* Van der Waerden notation

Tensor
definitions|

* tensor (intrinsic definition)
* tensor field
* tensor density
* tensors in curvilinear coordinates
* mixed tensor
* antisymmetric tensor
* symmetric tensor
* tensor operator
* tensor bundle
* two-point tensor

Operations|

* tensor product
* exterior product
* tensor contraction
* transpose (2nd-order tensors)
* raising and lowering indices
* Hodge star operator
* covariant derivative
* exterior derivative
* exterior covariant derivative
* Lie derivative

Related
abstractions|

* dimension
* basis
* vector, vector space
* multivector
* covariance and contravariance of vectors
* linear transformation
* matrix
* spinor
* Cartan formalism
* differential form
* exterior form
* connection form
* geodesic
* manifold
* fiber bundle
* Levi-Civita connection
* affine connection

Notable tensors|

| Mathematics|

* Kronecker delta
* Levi-Civita symbol
* metric tensor
* nonmetricity tensor
* Christoffel symbols
* Ricci curvature
* Riemann curvature tensor
* Weyl tensor
* torsion tensor

|

Physics|

* moment of inertia
* angular momentum tensor
* spin tensor
* Cauchy stress tensor
* stress–energy tensor
* EM tensor
* gluon field strength tensor
* Einstein tensor
* metric tensor (GR)

Mathematicians|

* Leonhard Euler
* Carl Friedrich Gauss
* Augustin-Louis Cauchy
* Hermann Grassmann
* Gregorio Ricci-Curbastro
* Tullio Levi-Civita
* Jan Arnoldus Schouten
* Bernhard Riemann
* Elwin Bruno Christoffel
* Woldemar Voigt
* Élie Cartan
* Hermann Weyl
* Albert Einstein

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Dot product. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Dot_product&oldid=3983097"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template