# Outer product

In linear algebra, the outer product of two coordinate vectors is a matrix. If the two 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

## Definition

Given two vectors

${\displaystyle \mathbf {u} =(u_{1},u_{2},\dots ,u_{m})}$
${\displaystyle \mathbf {v} =(v_{1},v_{2},\dots ,v_{n})}$

their outer product uv is defined as the m × n matrix A obtained by multiplying each element of u by each element of v:[1][2]

${\displaystyle \mathbf {u} \otimes \mathbf {v} =\mathbf {A} ={\begin{bmatrix}u_{1}v_{1}&u_{1}v_{2}&\dots &u_{1}v_{n}\\u_{2}v_{1}&u_{2}v_{2}&\dots &u_{2}v_{n}\\\vdots &\vdots &\ddots &\vdots \\u_{m}v_{1}&u_{m}v_{2}&\dots &u_{m}v_{n}\end{bmatrix}}}$

Or in index notation:

${\displaystyle (\mathbf {u} \otimes \mathbf {v} )_{ij}=u_{i}v_{j}}$

The outer product uv is equivalent to a matrix multiplication uvT, provided that u is represented as a m × 1 column vector and v as a n × 1 column vector (which makes vT a row vector).[3] For instance, if m = 4 and n = 3, then

{\displaystyle {\begin{aligned}\mathbf {u} \otimes \mathbf {v} =\mathbf {u} \mathbf {v} ^{\top }={\begin{bmatrix}u_{1}\\u_{2}\\u_{3}\\u_{4}\end{bmatrix}}{\begin{bmatrix}v_{1}&v_{2}&v_{3}\end{bmatrix}}={\begin{bmatrix}u_{1}v_{1}&u_{1}v_{2}&u_{1}v_{3}\\u_{2}v_{1}&u_{2}v_{2}&u_{2}v_{3}\\u_{3}v_{1}&u_{3}v_{2}&u_{3}v_{3}\\u_{4}v_{1}&u_{4}v_{2}&u_{4}v_{3}\end{bmatrix}}.\end{aligned}}} [4]

For complex vectors, it is often useful to take the conjugate transpose of v, denoted ${\displaystyle \mathbf {v} ^{\dagger }}$ or ${\displaystyle (\mathbf {v} ^{\top })^{*}}$ :

${\displaystyle \mathbf {u} \otimes \mathbf {v} =\mathbf {u} \mathbf {v} ^{\dagger }=\mathbf {u} (\mathbf {v} ^{\top })^{*}\ }$ .

### Contrast with Euclidean inner product

If m = n, then one can take the matrix product the other way, yielding a scalar (or 1 × 1 matrix):

${\displaystyle \left\langle \mathbf {u} ,\mathbf {v} \right\rangle =\mathbf {u} ^{\top }\mathbf {v} }$

which is the standard inner product for Euclidean vector spaces, better known as the dot product. The inner product is the trace of the outer product.[5] Unlike the inner product, the outer product is not commutative.

### The outer product of tensors

Given two tensors u, v with dimensions ${\displaystyle (k_{1},k_{2}\dots k_{m})}$  and ${\displaystyle (l_{1},l_{2},\dots l_{n})}$  their outer product ${\displaystyle \mathbf {u} \otimes \mathbf {v} }$  is a tensor with dimensions ${\displaystyle (k_{1},k_{2}\dots k_{m},l_{1},l_{2},\dots l_{n})}$  and entries

${\displaystyle (\mathbf {u} \otimes \mathbf {v} )_{i_{1},i_{2},\dots i_{m},j_{1},j_{2}\dots j_{n}}=u_{i_{1},i_{2},\dots i_{m}}v_{j_{1},j_{2},\dots j_{n}}}$

For example, if A is of order 3 with dimensions (3, 5, 7) and B is of order 2 with dimensions (10, 100), their outer product c is of order 5 with dimensions (3, 5, 7, 10, 100). If A has a component A[2, 2, 4] = 11 and B has a component B[8, 88] = 13, then the component of C formed by the outer product is C[2, 2, 4, 8, 88] = 143.

### Contrast with the Kronecker product

The outer product and Kronecker product are closely related; in fact the same symbol is commonly used to denote both operations.

If ${\displaystyle \mathbf {u} ={\begin{bmatrix}1&2&3\end{bmatrix}}^{\top }}$  and ${\displaystyle \mathbf {v} ={\begin{bmatrix}4&5\end{bmatrix}}^{\top }}$ , we have

{\displaystyle {\begin{aligned}\mathbf {u} \otimes _{\text{Kron}}\mathbf {v} &={\begin{bmatrix}4\\5\\8\\10\\12\\15\end{bmatrix}}&\mathbf {u} \otimes _{\text{outer}}\mathbf {v} &={\begin{bmatrix}4&5\\8&10\\12&15\end{bmatrix}}\end{aligned}}}

The Kronecker product is a form of vectorization (or flattening) of the outer product. In particular, we can write

${\displaystyle \mathbf {u} \otimes _{\text{Kron}}\mathbf {v} ={\text{vec}}(\mathbf {v} \otimes _{\mathrm {outer} }\mathbf {u} )}$

(The order of the vectors is reversed.)

## Properties

The outer product of vectors satisfies the following properties:

${\displaystyle (\mathbf {u} \otimes \mathbf {v} )^{\top }=(\mathbf {v} \otimes \mathbf {u} )}$
${\displaystyle (\mathbf {v} +\mathbf {w} )\otimes \mathbf {u} =\mathbf {v} \otimes \mathbf {u} +\mathbf {w} \otimes \mathbf {u} }$
${\displaystyle \mathbf {u} \otimes (\mathbf {v} +\mathbf {w} )=\mathbf {u} \otimes \mathbf {v} +\mathbf {u} \otimes \mathbf {w} }$
${\displaystyle c(\mathbf {v} \otimes \mathbf {u} )=(c\mathbf {v} )\otimes \mathbf {u} =\mathbf {v} \otimes (c\mathbf {u} )}$

The outer product of tensors satisfies the additional associativity property:

${\displaystyle (\mathbf {u} \otimes \mathbf {v} )\otimes \mathbf {w} =\mathbf {u} \otimes (\mathbf {v} \otimes \mathbf {w} )}$

### Rank of an outer product

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 the first column. 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)

Let V and W be two vector spaces. The outer product of ${\displaystyle v\in V}$  and ${\displaystyle w\in W}$  is the element ${\displaystyle v\otimes w\in V\otimes W}$ .

If V is an inner product space then it is possible to define the outer product as a linear map VW. In this case the linear map ${\displaystyle x\mapsto \langle v,x\rangle }$  is an element of the dual space of V. The outer product VW is then given by

${\displaystyle (v\otimes w)(x)=\langle v,x\rangle w}$

This shows why a conjugate transpose of v is commonly taken in the complex case.

## In programming languages

In some programming languages, given a two-argument function f (or a binary operator), the outer product of f and 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 R, as the function outer(A, B, f);[6] 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.

### Python with NumPy

In the Python library NumPy, the outer product can be computed with function np.outer() [7]


>>> import numpy as np
>>> a = np.array([1, 2, 3])
>>> b = np.array([2, 4, 8])
>>> np.outer(a, b)

Out[*]:  array([[ 2,  4,  8],
[ 4,  8, 16],
[ 6, 12, 24]])

# in contrast np.kron, results in a flat array
>>> np.kron(a, b)

Out[*]:  array([ 2, 4, 8, 4, 8, 16, 6, 12, 24])


The outer product of multidimensional arrays can be computed using np.multiply.outer.

>>> np.multiply.outer(np.empty((1, 2, 3)), np.empty((4, 5))).shape

Out[*]:  (1, 2, 3, 4, 5)


## Applications

As the outer product is closely related to the Kronecker product, some of the applications of the Kronecker product use outer products. Some of these applications to quantum theory, signal processing, and image compression are found in chapter 3, "Applications", in a book by Willi-Hans Steeb and Yorick Hardy.[8]

### Spinors

Suppose s,t,w,z ∈ ℂ so that (s,t) and (w,z) are in ℂ2. Then the outer product of these complex 2-vectors is an element of M(2,ℂ), the 2 × 2 complex matrices:

${\displaystyle {\begin{pmatrix}sw&tw\\sz&tz\end{pmatrix}}.}$  The determinant of this matrix is swtzsztw = 0 because of the commutative property of ℂ.

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[9] but it was introduced by Wolfgang Pauli in 1927[10] so that M(2,ℂ) has come to be called Pauli algebra.

### Concepts

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 ${\displaystyle (a_{ij})\ =\ (u_{i}\land v_{j})}$ . This type of matrix is used in the study of binary relations and is called a rectangular relation or a cross-vector.[11]

## References

1. ^ "Kronecker Product". Wolfram MathWorld.
2. ^ Lerner, R. G.; Trigg, G. L. (1991). Encyclopaedia of Physics (2nd ed.). VHC. ISBN 0-89573-752-3.
3. ^ Lipschutz, S.; Lipson, M. (2009). Linear Algebra. Schaum’s Outlines (4th ed.). McGraw-Hill. ISBN 978-0-07-154352-1.
4. ^ James M. Ortega (1987) Matrix Theory: A Second Course, page 7, Plenum Press ISBN 0-306-42433-9
5. ^ Stengel, Robert F. (1994). Optimal Control and Estimation. New York: Dover Publications. p. 26. ISBN 0-486-68200-5.
6. ^ "outer function". RDocumentation.
7. ^ https://docs.scipy.org/doc/numpy/reference/generated/numpy.outer.html
8. ^ Willi-Hans Steeb and Yorick Hardy (2011) Matrix Calculus and Kronecker Product: A Practical Approach to Linear and Multilinear Algebra, second edition, World Scientific ISBN 981-4335-31-2
9. ^ Élie Cartan (1937) Lecons sur la theorie des spineurs, translated 1966: The Theory of Spinors, Hermann, Paris
10. ^ Pertti Lounesto (1997) Clifford Algebras and Spinors, page 51, Cambridge University Press ISBN 0-521-59916-4
11. ^ Ki Hang Kim (1982) Boolean Matrix Theory and Applications, page 37, Marcel Dekker ISBN 0-8247-1788-0