Recent from talks
Nothing was collected or created yet.
Outer product
View on WikipediaIn linear algebra, the outer product of two coordinate vectors is the matrix whose entries are all products of an element in the first vector with an element in the second vector. If the two coordinate vectors have dimensions n and m, then their outer product is an n × m matrix. More generally, given two tensors (multidimensional arrays of numbers), their outer product is a tensor. The outer product of tensors is also referred to as their tensor product, and can be used to define the tensor algebra.
The outer product contrasts with:
- The dot product (a special case of "inner product"), which takes a pair of coordinate vectors as input and produces a scalar
- The Kronecker product, which takes a pair of matrices as input and produces a block matrix
- Standard matrix multiplication
Definition
[edit]Given two vectors of size and respectively
their outer product, denoted is defined as the matrix obtained by multiplying each element of by each element of :[1]
Or, in index notation:
Denoting the dot product by if given an vector then If given a vector then
If and are vectors of the same dimension bigger than 1, then .
The outer product is equivalent to a matrix multiplication provided that is represented as a column vector and as a column vector (which makes a row vector).[2][3] For instance, if and then[4]
For complex vectors, it is often useful to take the conjugate transpose of denoted or :
Contrast with Euclidean inner product
[edit]If then one can take the matrix product the other way, yielding a scalar (or matrix):
which is the standard inner product for Euclidean vector spaces,[3] better known as the dot product. The dot product is the trace of the outer product.[5] Unlike the dot product, the outer product is not commutative.
Multiplication of a vector by the matrix can be written in terms of the inner product, using the relation .
The outer product of tensors
[edit]Given two tensors with dimensions and , their outer product is a tensor with dimensions and entries
For example, if is of order 3 with dimensions and is of order 2 with dimensions then their outer product is of order 5 with dimensions If has a component A[2, 2, 4] = 11 and has a component B[8, 88] = 13, then the component of formed by the outer product is C[2, 2, 4, 8, 88] = 143.
Connection with the Kronecker product
[edit]The outer product and Kronecker product are closely related; in fact the same symbol is commonly used to denote both operations.
If and , we have:
In the case of column vectors, the Kronecker product can be viewed as a form of vectorization (or flattening) of the outer product. In particular, for two column vectors and , we can write:
(The order of the vectors is reversed on the right side of the equation.)
Another similar identity that further highlights the similarity between the operations is
where the order of vectors needs not be flipped. The middle expression uses matrix multiplication, where the vectors are considered as column/row matrices.
Connection with the matrix product
[edit]Given a pair of matrices of size and of size , consider the matrix product defined as usual as a matrix of size .
Now let be the -th column vector of and let be the -th row vector of . Then can be expressed as a sum of column-by-row outer products:
This expression has duality with the more common one as a matrix built with row-by-column inner product entries (or dot product):
This relation is relevant[6] in the application of the Singular Value Decomposition (SVD) (and Spectral Decomposition as a special case). In particular, the decomposition can be interpreted as the sum of outer products of each left () and right () singular vectors, scaled by the corresponding nonzero singular value :
This result implies that can be expressed as a sum of rank-1 matrices with spectral norm in decreasing order. This explains the fact why, in general, the last terms contribute less, which motivates the use of the truncated SVD as an approximation. The first term is the least squares fit of a matrix to an outer product of vectors.
Properties
[edit]The outer product of vectors satisfies the following properties:
The outer product of tensors satisfies the additional associativity property:
Rank of an outer product
[edit]If u and v are both nonzero, then the outer product matrix uvT always has matrix rank 1. Indeed, the columns of the outer product are all proportional to u. Thus they are all linearly dependent on that one column, hence the matrix is of rank one.
("Matrix rank" should not be confused with "tensor order", or "tensor degree", which is sometimes referred to as "rank".)
Definition (abstract)
[edit]Let V and W be two vector spaces. The outer product of and is the element .
If V is an inner product space, then it is possible to define the outer product as a linear map V → W. In this case, the linear map is an element of the dual space of V, as this maps linearly a vector into its underlying field, of which is an element. The outer product V → W is then given by
This shows why a conjugate transpose of v is commonly taken in the complex case.
In programming languages
[edit]In some programming languages, given a two-argument function f (or a binary operator), the outer product, f, of two one-dimensional arrays, A and B, is a two-dimensional array C such that C[i, j] = f(A[i], B[j]). This is syntactically represented in various ways: in APL, as the infix binary operator ∘.f; in J, as the postfix adverb f/; in R, as the function outer(A, B, f) or the special %o%;[7] in Mathematica, as Outer[f, A, B]. In MATLAB, the function kron(A, B) is used for this product. These often generalize to multi-dimensional arguments, and more than two arguments.
In the Python library NumPy, the outer product can be computed with function np.outer().[8] In contrast, np.kron results in a flat array. The outer product of multidimensional arrays can be computed using np.multiply.outer.
Applications
[edit]As the outer product is closely related to the Kronecker product, some of the applications of the Kronecker product use outer products. These applications are found in quantum theory, signal processing, and image compression.[9]
Spinors
[edit]Suppose s, t, w, z ∈ C so that (s, t) and (w, z) are in C2. Then the outer product of these complex 2-vectors is an element of M(2, C), the 2 × 2 complex matrices:
The determinant of this matrix is swtz − sztw = 0 because of the commutative property of C.
In the theory of spinors in three dimensions, these matrices are associated with isotropic vectors due to this null property. Élie Cartan described this construction in 1937,[10] but it was introduced by Wolfgang Pauli in 1927[11] so that M(2,C) has come to be called Pauli algebra.
Concepts
[edit]The block form of outer products is useful in classification. Concept analysis is a study that depends on certain outer products:
When a vector has only zeros and ones as entries, it is called a logical vector, a special case of a logical matrix. The logical operation and takes the place of multiplication. The outer product of two logical vectors (ui) and (vj) is given by the logical matrix . This type of matrix is used in the study of binary relations, and is called a rectangular relation or a cross-vector.[12]
See also
[edit]References
[edit]- ^ Lerner, R. G.; Trigg, G. L. (1991). Encyclopaedia of Physics (2nd ed.). VHC. ISBN 0-89573-752-3.
- ^ Lipschutz, S.; Lipson, M. (2009). Linear Algebra. Schaum’s Outlines (4th ed.). McGraw-Hill. ISBN 978-0-07-154352-1.
- ^ a b Keller, Frank (February 23, 2020). "Algebraic Properties of Matrices; Transpose; Inner and Outer Product" (PDF). inf.ed.ac.uk. Archived (PDF) from the original on 2017-12-15. Retrieved September 6, 2020.
- ^ James M. Ortega (1987) Matrix Theory: A Second Course, page 7, Plenum Press ISBN 0-306-42433-9
- ^ Stengel, Robert F. (1994). Optimal Control and Estimation. New York: Dover Publications. p. 26. ISBN 0-486-68200-5.
- ^ Trefethen, Lloyd N.; Bau III, David (1997). Numerical linear algebra. Philadelphia: Society for Industrial and Applied Mathematics. ISBN 978-0-89871-361-9.
- ^ "outer function | R Documentation". rdocumentation.org. Retrieved 2020-09-07.
- ^ "numpy.outer — NumPy v1.19 Manual". numpy.org. Retrieved 2020-09-07.
- ^ Steeb, Willi-Hans; Hardy, Yorick (2011). "Applications (Chapter 3)". Matrix Calculus and Kronecker Product: A Practical Approach to Linear and Multilinear Algebra (2 ed.). World Scientific. ISBN 978-981-4335-31-7.
- ^ Élie Cartan (1937) Lecons sur la theorie des spineurs, translated 1966: The Theory of Spinors, Hermann, Paris
- ^ Pertti Lounesto (1997) Clifford Algebras and Spinors, page 51, Cambridge University Press ISBN 0-521-59916-4
- ^ Ki-Hang Kim (1982) Boolean Matrix Theory and Applications, page 37, Marcel Dekker ISBN 0-8247-1788-0
Further reading
[edit]- Carlen, Eric; Canceicao Carvalho, Maria (2006). "Outer Products and Orthogonal Projections". Linear Algebra: From the Beginning. Macmillan. pp. 217–218. ISBN 9780716748946.
Outer product
View on GrokipediaDefinitions
For vectors
In linear algebra, the outer product of two column vectors and is defined as the matrix , where the -th entry is given by .[1][3] This operation constructs a rank-at-most-one matrix from the vectors, with each column being a scalar multiple of (specifically, scaled by the corresponding entry of ) and each row being a scalar multiple of .[1] The notation is commonly used to denote this outer product, equivalent to .[8] For small dimensions, such as two-dimensional vectors, the result is a matrix; in general, the dimensions follow directly from those of the input vectors, producing an output regardless of whether .[9] The outer product is bilinear in its arguments: it is linear with respect to the first vector when the second is fixed, and linear with respect to the second vector when the first is fixed.[8] This bilinearity follows directly from the entry-wise multiplication and the linearity of scalar multiplication in vector spaces.[8] For example, consider and . The outer product is computed entry-wise as follows: Thus, This can also be verified as .For tensors
In multilinear algebra, the outer product extends the concept from vectors to higher-order tensors. Consider a tensor of order over a vector space with components and a tensor of order with components . Their outer product is a tensor of order whose components are defined by the component-wise multiplication without any summation over repeated indices.[10][11] This operation contrasts with inner products or contractions for tensors, which require summation over one or more shared indices to reduce the order.[12] The outer product thus preserves all indices separately, resulting in a higher-order tensor that encodes the independent structure of both inputs. For instance, the outer product of a first-order tensor (vector) with components and a second-order tensor (matrix) with components yields a third-order tensor with components .[13] Regarding index modes, if has a specific valence (e.g., contravariant and covariant indices denoted by upper and lower positions), the outer product concatenates these directly: the indices of precede those of , maintaining their original contravariant or covariant nature without alteration.[10] This is a direct generalization of the vector outer product, where both operands are first-order tensors.[10]Properties
Algebraic properties
The outer product of two vectors is a bilinear map, meaning it is linear in each argument when the other is fixed. Specifically, for vectors , , and scalars in the base field, , and similarly .[14] This multilinearity extends to higher-order outer products, where the operation is linear in each of the multiple vector arguments separately.[14] To see this from the component-wise definition, suppose and are finite-dimensional with bases and , so and . Then . Substituting yields , confirming linearity in the first argument; the proof for the second is analogous.[15] The outer product is associative: for vectors , , , in the triple tensor product . This identification holds via the canonical isomorphisms of iterated tensor products, allowing unambiguous notation for higher-order tensors like .[14] In components, both sides expand to , where is a basis for .[14] The zero vector acts as an absorbing element under the outer product: and , where the zero on the right denotes the zero tensor. This follows immediately from multilinearity, as substituting gives all coefficients zero in the component expansion.[14]Rank and decomposition
The outer product of two non-zero vectors and , denoted or , yields an matrix of rank exactly 1. If either or is the zero vector, the resulting matrix has rank 0.[5][16] This rank property follows from the structure of the outer product matrix: each column of is the scalar multiple of , where is the -th entry of ; thus, all columns lie in the one-dimensional span of , implying that the column space has dimension at most 1.[5] This concept generalizes to higher-order tensors, where the outer product of non-zero vectors (one along each mode) produces a rank-1 tensor, meaning it can be expressed as a single such outer product with no further decomposition needed. The outer product of rank-1 tensors preserves rank 1, while sums of multiple rank-1 outer products yield tensors of higher rank that exhibit separability, as the minimal number of such components defines the tensor rank.[17][18] In matrix decomposition, every rank-1 matrix can be uniquely expressed (up to scaling) as the outer product of two non-zero vectors, providing a canonical representation for low-rank structures. This forms the foundation for broader decompositions, such as the singular value decomposition (SVD), where any matrix factors as , a weighted sum of rank-1 outer products of the left and right singular vectors and , with singular values .[19][20] For example, consider the matrix , which has rank 1 since its determinant is . This decomposes as the outer product with and , verifiable by the trace equality .[5]Connections to Other Operations
Contrast with inner product
The inner product of two vectors and yields a scalar value that quantifies their similarity or the extent of projection of one onto the other, whereas the outer product produces a matrix or higher-order tensor that encodes a bilinear form.[21][22] Geometrically, in Euclidean space, the inner product measures the cosine of the angle between the vectors, providing a notion of alignment or orthogonality. In contrast, the outer product constructs a rank-1 linear operator whose action on any vector is given by which projects onto the direction of and rescales the result to lie along .[23] For real column vectors, the inner product is denoted and computed as , producing a scalar, while the outer product is , yielding an outer product matrix. This relationship is evident in the identity , where the trace extracts the scalar inner product from the outer product matrix.[21][24] Both concepts arise from the broader framework of bilinear forms on vector spaces, but the inner product is characterized as symmetric and positive-definite, enabling definitions of norms and angles, whereas the outer product is neither symmetric nor positive-definite in general.[25][26] In non-Euclidean settings, the inner product necessitates a metric tensor or inner product structure to induce geometry on the space, while the outer product, rooted in the algebraic tensor product, requires no such metric and operates purely on the vector space structure.[27][28]Relation to Kronecker product
The outer product of two column vectors and yields the rank-1 matrix . This operation corresponds to the Kronecker product , where is regarded as a row matrix, producing the same result.[29] In general, the Kronecker product of matrices and forms a block matrix , in which the -th block is . The outer product of vectors emerges as the special case where , reducing the block structure to scalar multiples of the second vector arranged in matrix form.[30] Outer products thus inherit key properties of the Kronecker product, including its block-wise structure and the mixed-product rule: , provided the inner dimensions are compatible for multiplication.[31] For example, let and . The outer product is . Equivalently, treating as a row matrix, the Kronecker product yields the same matrix via scalar blocks: the first row block is and the second is . In contrast, for matrices with more than one column, such as (now if augmented) and a , produces a block matrix with two columns of blocks, generalizing beyond the rank-1 outer form.[29][30] The dimension of the outer product is , while the Kronecker product extends this to , accommodating larger block arrangements for matrices with multiple rows and columns in each factor.[31]Relation to matrix multiplication
In the context of inner product spaces, the outer product of two vectors and can be interpreted as a linear operator that maps any vector to , where denotes the inner product.[32] This representation highlights the outer product's role in defining rank-one transformations, which are fundamental to matrix operations. For instance, when expressed in matrix form as (where indicates the conjugate transpose), applying this operator via matrix-vector multiplication yields the scaled vector .[33] The composition of outer products further connects them to matrix multiplication, as the product of two such operators , reducing to a scalar multiple of another outer product.[34] This non-commutative structure—unlike scalar multiplication, where order is irrelevant—mirrors the non-commutativity of general matrix multiplication, emphasizing that unless the inner product . In Hilbert spaces, the adjoint of an outer product operator satisfies , where denotes the adjoint (conjugate transpose for matrices), directly linking outer products to the transpose operation in matrix algebra.[35] A key relation arises through the trace: the inner product equals the trace of the outer product matrix, specifically for real vectors (with analogous forms in complex cases using the conjugate transpose).[36] More broadly, for a matrix , the bilinear form decomposes matrix-vector multiplication into products of inner products, illustrating how outer products facilitate efficient computations in low-rank settings.[37] For example, any matrix can be expressed as a sum of outer products , enabling low-rank approximations where multiplication properties preserve the structure for tasks like data compression.[38]Abstract Perspectives
In linear algebra over vector spaces
In linear algebra, the outer product of vectors from finite-dimensional vector spaces is formalized using the tensor product construction. Let and be vector spaces over a field . The tensor product is a vector space equipped with a bilinear map such that for any and , denotes the simple tensor (or pure tensor) generated by and . This map extends linearly to the entire space, meaning any element of can be expressed as a finite sum for and .[14] The tensor product space is constructed as the quotient of the free vector space on the set by the subspace generated by the relations enforcing bilinearity: specifically, relations like , , and for . This quotient ensures the uniqueness of the representation up to the bilinear structure, and the tensor product is unique up to isomorphism satisfying the universal property for bilinear maps.[14] Suppose is a basis for and is a basis for . Then forms a basis for , which has dimension . For and , the outer product is . This coordinate-free representation highlights the abstract nature of the operation.[14]Universal construction
The tensor product of two vector spaces and over a field is characterized by its universal bilinear mapping property: for any vector space and any bilinear map , there exists a unique linear map such that for all and .[14] This property ensures that is the "universal" object mediating bilinear maps out of , up to unique isomorphism.[14] One explicit construction of realizes it as the free vector space generated by the set , quotiented by the subspace of relations enforcing bilinearity, namely additivity in each argument and homogeneity under scalar multiplication.[14] Specifically, the relations include elements like , , and (and similarly for the second argument) for .[14] The images of the generators under the quotient map are denoted , forming a basis for when and are bases for and , respectively.[14] To verify the universal property from this construction, note that the bilinear map extends uniquely to the free space by linearity on finite formal sums , and this extension descends to the quotient because respects the bilinearity relations, yielding the desired linear .[14] Surjectivity of follows since the generate , and uniqueness arises because any linear map agreeing on generators is determined on the whole space.[14] A direct consequence is the natural isomorphism , where the bijection sends a linear to the bilinear composition , with inverse as above.[14] This identifies the space of linear functionals on the tensor product with bilinear forms on the product space. For higher-order tensors, the construction iterates: the -fold tensor product satisfies a universal multilinear mapping property, obtained by successive applications of the bilinear case.[14]Implementations and Computations
In programming languages
In numerical computing environments, the outer product of two vectors is typically implemented as a function that produces a rank-2 tensor (matrix) by pairwise multiplication of elements, with inputs expected as one-dimensional arrays and outputs as two-dimensional arrays of shape (m, n) for input lengths m and n.[39] In Python's NumPy library, thenp.outer function computes the outer product of two one-dimensional arrays u and v, returning a two-dimensional array without transposing the inputs. It supports broadcasting for arrays with more than one dimension, treating them as flattened for the operation. For example:
import numpy as np
u = np.[array](/page/Array)([1, 2])
v = np.[array](/page/Array)([3, 4])
outer_prod = np.outer(u, v)
print(outer_prod)
import numpy as np
u = np.[array](/page/Array)([1, 2])
v = np.[array](/page/Array)([3, 4])
outer_prod = np.outer(u, v)
print(outer_prod)
[[3 4]
[6 8]]
[[3 4]
[6 8]]
outer function; instead, the outer product of two column vectors u and v is computed using matrix multiplication as u * v.', where .' denotes the non-conjugate transpose. For complex-valued vectors, u * conj(v).' is used to include the complex conjugate transpose, ensuring the standard Hermitian outer product. For example, with real vectors:
u = [1; 2];
v = [3; 4];
outer_prod = u * v.';
disp(outer_prod)
u = [1; 2];
v = [3; 4];
outer_prod = u * v.';
disp(outer_prod)
3 4
6 8
3 4
6 8
@tensor macro for index notation or the ⊗ operator for direct outer products of vectors. Inputs are one-dimensional arrays, and the result is a two-dimensional matrix. For example:
using TensorOperations
u = [1, 2]
v = [3, 4]
C = u ⊗ v # or @tensor C[i,j] := u[i] * v[j]
println(C)
using TensorOperations
u = [1, 2]
v = [3, 4]
C = u ⊗ v # or @tensor C[i,j] := u[i] * v[j]
println(C)
2×2 Matrix{Int64}:
3 4
6 8
2×2 Matrix{Int64}:
3 4
6 8
kron can be used indirectly, but TensorOperations.jl is preferred for efficient tensor handling.[41]
In R, the base outer function computes the outer product by applying a binary operation (defaulting to multiplication via FUN = "*") to all pairs of elements from vectors u and v, returning a matrix; it is vectorized for efficiency across inputs. Higher-dimensional arrays are supported via broadcasting in the result dimensions. For example:
u <- c(1, 2)
v <- c(3, 4)
outer_prod <- outer(u, v)
print(outer_prod)
u <- c(1, 2)
v <- c(3, 4)
outer_prod <- outer(u, v)
print(outer_prod)
[,1] [,2]
[1,] 3 4
[2,] 6 8
[,1] [,2]
[1,] 3 4
[2,] 6 8
u = [0, 0]), the outer product yields the zero matrix of the appropriate dimensions. Broadcasting enables extension to higher-dimensional inputs in libraries like NumPy and R, where extra dimensions are preserved in the output shape.[39]
Numerical considerations
The direct computation of the outer product between two vectors of dimensions and requires time and space complexity, as it involves scalar multiplications to form each entry of the resulting matrix.[3] This approach is computationally preferable to more general tensor product methods like the Kronecker product when applied to vectors, as it avoids the overhead of constructing larger block-structured intermediates that are unnecessary for the rank-1 result.[42] For large values of and , the dense storage of the outer product matrix demands memory, which can become prohibitive; however, since the result is a rank-1 matrix, sparse storage formats can be employed to represent it efficiently using the factorizing vectors, reducing space to plus indices for nonzeros, particularly beneficial when the input vectors are sparse.[43] Libraries such as SciPy support this through sparse matrix classes like COO or CSR, allowing construction of the outer product without materializing the full dense array.[44] Numerical stability concerns arise in floating-point implementations of the outer product, as the standard component-wise multiplication algorithm is not backward stable: the computed matrix typically has numerical rank , whereas the exact rank-1 structure of is unlikely to hold under rounding errors, leading to perturbations that do not correspond to a nearby exact outer product.[45] Floating-point errors accumulate in the individual scalar multiplications with (machine epsilon), and these can be exacerbated for near-zero vectors, where small input norms result in ill-conditioned outputs sensitive to relative perturbations. Parallelization enhances efficiency for large-scale outer products through vectorized operations in GPU-accelerated libraries; for instance, CuPy provides NumPy-compatible outer product functions that leverage CUDA for parallel execution, while TensorFlow supports similar via tensor operations, yielding speedups of 10-16x over CPU baselines for related tensor contractions.[46] Computing higher-order outer products in tensor libraries introduces challenges such as irregular memory access patterns and scalability for sparse higher-dimensional structures, often requiring specialized functions like TensorFlow'stf.tensordot with axis specifications (e.g., empty axes for full outer contraction) to avoid dense intermediates.
As a representative benchmark, optimized vectorized outer product implementations in NumPy outperform explicit Python loops by factors of up to 370x for comparable matrix formation tasks, highlighting the benefits of compiled backends over interpreted iteration.[47]
