Dot
a.b.c or Dot[a,b,c]
gives products of vectors, matrices, and tensors.
Details
 a.b gives an explicit result when a and b are lists with appropriate dimensions. It contracts the last index in a with the first index in b.
 Various applications of Dot:

{a_{1},a_{2}}.{b_{1},b_{2}} scalar product of vectors {a_{1},a_{2}}.{{m_{11},m_{12}},{m_{21},m_{22}}}product of a vector and a matrix {{m_{11},m_{12}},{m_{21},m_{22}}}.{a_{1},a_{2}}product of a matrix and a vector {{m_{11},m_{12}},{m_{21},m_{22}}}.{{n_{11},n_{12}},{n_{21},n_{22}}}product of two matrices  The result of applying Dot to two tensors and is the tensor . Applying Dot to a rank tensor and a rank tensor gives a rank tensor. »
 Dot can be used on SparseArray and structured array objects. It will return an object of the same type as the input when possible. »
 Dot is linear in all arguments. » It does not define a complex (Hermitian) inner product on vectors. »
 When its arguments are not lists or sparse arrays, Dot remains unevaluated. It has the attribute Flat.
Examples
open allclose allBasic Examples (4)
Scope (26)
Dot Products of Vectors (7)
Scalar product of machineprecision vectors:
Inner product of symbolic vectors:
The dot product of arbitraryprecision vectors:
Dot allows complex inputs, but does not conjugate any of them:
To compute the complex or Hermitian inner product, apply Conjugate to one of the inputs:
Some sources, particularly in the mathematical literature, conjugate the second argument:
Compute the norm of u using the two inner products:
Verify the result using Norm:
Dot product of sparse vectors:
Compute the scalar product of two QuantityArray vectors:
MatrixVector Multiplication (5)
Define a rectangular matrix of dimensions :
Define a 2vector and a 3vector:
The matrix can be multiplied by the 2vector only on the left:
Multiplying in the opposite order produces an error message due to the incompatible shapes:
Similarly, the matrix can be multiplied by the 3vector only on the right:
Multiply the matrix on both sides at once:
Define a square matrix and a compatible vector:
The products m.v and v.m return different vectors:
The product v.m.v is a scalar:
Define a column and row matrices c and r with the same numerical entries as v:
Products involving m, c and r have the same entries as those involving m and v, but are all matrices:
Moreover, the products must be done in an order that respects the matrices' shapes:
Define a matrix and two vectors:
Since is a vector, is an allowed product:
Note that it is effectively multiplying on the left side of the matrix, not the right:
The product of a sparse matrix and sparse vector is a sparse vector:
Format the result as a row matrix:
The product of a sparse matrix and an ordinary vector is a normal vector:
The product of a structured matrix with a vector will retain the structure if possible:
The product of a normal matrix with a structured vector may have the structure of the vector:
MatrixMatrix Multiplication (9)
Multiply real machinenumber matrices:
Visualize the input and output matrices:
Multiply arbitraryprecision matrices:
Since , these matrices cannot be multiplied in the opposite order:
The product of sparse matrices is another sparse matrix:
The product of structured matrices preserves the structure if possible:
Compare with MatrixPower:
Raise a matrix to the tenth power using Dot in combination with Apply (@@) and ConstantArray:
HigherRank Arrays (5)
Dot works for arrays of any rank:
The dimensions of the result are those of the input with the common dimension collapsed:
Any combination is allowed as long as products are done with a common dimension:
Create a rankthree array with three equal dimensions:
Create three vectors of the same dimension:
is the complete contraction that pairs with 's last level and with its first:
is the different contraction that pairs with 's first level and with its last:
Contract both levels of m with the second and third levels of a, respectively:
Dot of two sparse arrays is generally another sparse array:
Dot of a sparse array and an ordinary list may be another sparse array or an ordinary list:
The product of two SymmetrizedArray objects is generally another symmetrized array:
The symmetry of the new array may be much more complicated than the symmetry of either input:
Applications (16)
Projections and Bases (6)
Project the vector on the line spanned by the vector :
Visualize and its projection onto the line spanned by :
Project the vector on the plane spanned by the vectors and :
First, replace with a vector in the plane perpendicular to :
The projection in the plane is the sum of the projections onto and :
Find the component perpendicular to the plane:
Confirm the result by projecting onto the normal to the plane:
Visualize the plane, the vector and its parallel and perpendicular components:
Apply the Gram–Schmidt process to construct an orthonormal basis from the following vectors:
The first vector in the orthonormal basis, , is merely the normalized multiple :
For subsequent vectors, components parallel to earlier basis vectors are subtracted prior to normalization:
Confirm the answers using Orthogonalize:
Verify that the basis is orthonormal:
Find the components of a general vector with respect to this new basis:
Verify the components with respect to the :
Verify that it is a basis by showing that the matrix formed by the vectors has nonzero determinant:
The change of basis matrix is the inverse of the matrix whose columns are the :
A vector whose coordinates are in the standard bases will have coordinates with respect to :
Verify that these coordinates give back the vector :
The Frenet–Serret system encodes every space curve's properties in a vector basis and scalar functions. Consider the following curve:
Construct an orthonormal basis from the first three derivatives by subtracting parallel projections:
Ensure that the basis is righthanded:
Compute the curvature, , and torsion, , which quantify how the curve bends:
Verify the answers using FrenetSerretSystem:
Visualize the curve and the associated moving basis, also called a frame:
Matrices and Linear Operators (6)
A matrix is orthogonal of . Show that a rotation matrix is orthogonal:
Confirm using OrthogonalMatrixQ:
A matrix is unitary of . Show that Pauli matrices are unitary:
Confirm with UnitaryMatrixQ:
A matrix is normal if . Show that the following matrix is normal:
Confirm using NormalMatrixQ:
Normal matrices include many other types of matrices as special cases. Unitary matrices are normal:
Hermitian or selfadjoint matrices for which are also normal, as the matrix shows:
However, the matrix is not a named type of normal matrix such as unitary or Hermitian:
In quantum mechanics, systems with finitely many states are represented by unit vectors and physical quantities by matrices that act on them. Consider a spin1/2 particle such as an electron. It might be in a state such as the following:
The angular momentum in the direction is given by the following matrix:
The angular momentum of this state is :
The uncertainty in the angular momentum of this state is :
The uncertainty in the direction is computed analogously:
The uncertainty principle gives a lower bound on the product of uncertainties, :
Get the matrix representation for :
Create a vector to be acted upon:
Apply the linear mapping to the vector using different methods:
Using with Dot is the faster method:
The application of a single matrix to multiple vectors can be computed as :
The matrix method is significantly faster than repeated application:
Matrices and Arrays with Symmetry (4)
A real symmetric matrix gives a quadratic form by the formula :
Quadratic forms have the property that :
Equivalently, they define a homogeneous quadratic polynomial in the variables of :
The range of the polynomial can be , , or . In this case it is :
A positivedefinite, real symmetric matrix or metric defines an inner product by :
Being positivedefinite means that the associated quadratic form is positive for :
Note that Dot itself is the inner product associated with the identity matrix:
Apply the Gram–Schmidt process to the standard basis to obtain an orthonormal basis:
Confirm that this basis is orthonormal with respect to the inner product :
An antisymmetric matrix for which defines a Hamiltonian 2form :
However, the form is nondegenerate, meaning implies :
Construct six vectors in dimension six:
Construct the totally antisymmetric array in dimension six using LeviCivitaTensor:
Compute the complete contraction :
This is equal to the determinant of the matrix formed by the vectors:
By the antisymmetry of , the reversed contraction differs by in dimension :
Properties & Relations (15)
Dot is linear in each argument:
For a vector with real entries, Norm[v] equals :
For a vector with complex values, the norm is given by :
For two vectors with real entries, , with the angle between and :
The scalar product of vectors is invariant under rotations:
For two matrices, the , entry of is the dot product of the row of with the column of :
Matrix multiplication is noncommutative, :
Use MatrixPower to compute repeated matrix products:
Compare with a direct computation:
The action of b on a vector is the same as acting four times with a on that vector:
For two tensors and , is the tensor :
Applying Dot to a rank tensor and a rank tensor gives a rank tensor:
Dot with two arrays is a special case of Inner:
Dot can be implemented as a combination of TensorProduct and TensorContract:
Use Dot in combination with Flatten to contract multiple levels of one array with those of another:
TensorReduce can simplify expressions involving Dot:
Outer of two vectors can be computed with Dot:
Construct the column and row matrices corresponding to u and v:
Dot of a row and column matrix equals the KroneckerProduct of the corresponding vectors:
Possible Issues (2)
Dot effectively treats vectors multiplied from the right as column vectors:
Dot effectively treats vectors multiplied from the left as row vectors:
Dot does not give the standard inner product on :
Use Conjugate in one argument to get the Hermitian inner product:
Check that the result coincides with the square of the norm of a:
Text
Wolfram Research (1988), Dot, Wolfram Language function, https://reference.wolfram.com/language/ref/Dot.html (updated 2012).
CMS
Wolfram Language. 1988. "Dot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Dot.html.
APA
Wolfram Language. (1988). Dot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Dot.html