Engineering/Mathematics/Matrices
Properties of Matrix Multiplication
Matrix multiplication obeys associativity, both distributive laws, the scalar rule and the identity law, but not commutativity and not cancellation. Knowing precisely which rules survive — and proving each one entry-by-entry — is what makes algebraic manipulation of matrix expressions safe.
- Core level
- Stream: matrix-algebra
- Reading time 16 min
- Ref KVS-ENG-MATH-0041
- Taxonomy
- Engineering / Mathematics
- Prerequisite
- Matrix multiplication; the entry formula
- Holds
- Associativity, distributivity, identity, scalar rule
- Fails
- Commutativity and cancellation
- Order reversal
- ,
- Structure
- is a non-commutative ring with identity
Overview
Once matrix multiplication is defined, the immediate question is which of the familiar rules of arithmetic still apply. The answer is neither "all" nor "none". Associativity, both distributive laws, the interaction with scalars and the behaviour of the zero and identity matrices all carry over intact. Commutativity and the cancellation law do not. There is no way to guess which is which, so every rule has to be stated with its hypotheses and proved.
The proofs share a single template. Matrix equality means equality of corresponding entries, so any claimed identity is reduced to a statement about a scalar, expanded with the entry formula , and then settled using the ordinary arithmetic of . Associativity becomes an exchange in the order of a double summation; distributivity becomes distributivity of complex numbers; the transpose rule becomes an index swap. None of these arguments needs a general array written out with ellipses, and that restraint is what keeps them short enough to check.
Taken together the rules make the set of square matrices of a fixed size into a ring with identity: closed under addition and multiplication, associative, distributive, with a multiplicative identity and an additive identity . It is a non-commutative ring, and one with zero divisors — non-zero matrices whose product is zero — which is precisely why cancellation is unavailable. Recognising the structure tells an engineer in advance which algebraic manipulations are legitimate.
The rules governing transposition, conjugation and the inner product are the ones most often misapplied. Conjugation passes through a product unchanged, but transposition and adjunction reverse the order of the factors. That reversal is not a curiosity: it is forced by conformability, since the transpose of an product must be and only the reversed order of the transposed factors has that shape. It reappears everywhere from the chain rule of backpropagation to the transformation of element stiffness matrices.
Definition
Matrix Multiplication and the Zero Matrix
MMZMFor an matrix : and . Multiplying by a zero matrix annihilates, and the subscripts matter — the zero matrices on the two sides of each identity generally have different sizes.
The converse fails badly. does not imply that or is the zero matrix; non-zero matrices with zero product are called zero divisors and they exist for every size .
Matrix Multiplication and the Identity Matrix
MMIMFor an matrix : and . The identity matrix has on the diagonal and elsewhere, and this pair of identities is what earns it the name — it plays the role for matrix multiplication that the scalar plays for ordinary multiplication.
The two identity matrices are of different sizes unless is square. Writing without subscripts is harmless for square matrices and wrong for rectangular ones.
Distributivity and the Scalar Rule
MMDAAFor of size , and of size , of size and a scalar :
Distributivity requires and to be the same size, since their sum must exist. The scalar may be moved freely into either factor or left outside.
Associativity of Matrix Multiplication
MMAFor of size , of size and of size : . Both groupings are conformable and both produce an matrix. Because the grouping is immaterial, a product of several matrices may be written without parentheses at all.
Concepts
The entry-by-entry proof template
Every property on this page is established the same way. To prove for matrix expressions, show for all valid and , then invoke the definition of matrix equality. Expanding with the entry formula turns matrices into finite sums of complex numbers, at which point the field axioms take over. Associativity, for example, becomes evaluated in two different orders, and finite sums may be reordered freely. The discipline of working with a single entry rather than a whole array is what keeps these proofs verifiable.
What associativity buys
Three consequences follow immediately. First, a chain needs no parentheses, so notation stays clean. Second, matrix powers are unambiguous, which is what makes matrix polynomials, exponentials and eigenvalue theory possible. Third — and most practically — the grouping can be chosen for cost. Multiplying an by an by a costs multiplications if grouped from the left and from the right; for a large chain the optimal parenthesisation is found by dynamic programming and can change the run time by orders of magnitude.
Bilinearity
The two distributive laws together with the scalar rule say exactly that matrix multiplication is a bilinear map: linear in its left argument when the right is held fixed, and linear in its right argument when the left is held fixed. This is the precise sense in which multiplication respects the vector space structure of matrices, and it is what allows a product to be expanded, factored and differentiated in the ordinary way, provided the order of factors is never disturbed.
Conjugation, transposition and the order-reversal rule
, and since conjugation passes straight through a product, as well. The reversal is forced before any arithmetic is done: if is then is , and the only conformable way to build that from (of size ) and (of size ) is . The entry proof then confirms the numbers agree. The same reversal governs inverses, , and it is the reason gradients propagate backwards through a network of linear layers.
, with no reversal of order. Conjugation is an entry-wise operation and complex conjugation is multiplicative and additive, so it commutes with every step of the entry formula. Combining this with the transpose rule gives the adjoint rule, and it explains the asymmetry: the reversal in comes entirely from the transposition, never from the conjugation.
The inner product is a matrix product
Regarding as matrices, , a matrix identified with its lone entry. This is more than a notational trick: it means every theorem about matrix products applies to inner products for free, and it produces the adjoint relation by a single application of the reversal rule. Gram matrices, normal equations and projection formulas all descend from this identification.
What does not hold, and why it matters
Commutativity fails: and may differ, may have different sizes, or only one may exist. Cancellation fails: does not give , because can occur with . Zero divisors exist, so tells you nothing about or individually. And is , never . Each of these is a live source of error in derivations, and the discipline is simple: never perform a manipulation that is not licensed by a stated rule.
Decision path: is this manipulation legitimate?
Equations
Zero matrix annihilates
EQ-PMM-01Valid for any matrix . The zero matrices on the two sides of each equation are of different sizes, which the subscripts record.
Identity matrix acts trivially
EQ-PMM-02For an matrix. The two identities have different sizes unless is square; this is the property that names the matrix.
Distributive laws
EQ-PMM-03Both must be stated. Non-commutativity means the left-hand and right-hand versions are logically independent, though both are true.
Scalars commute with products
EQ-PMM-04A scalar may be extracted from a product or pushed into either factor. Scalars are the one thing that commutes with everything.
Associativity
EQ-PMM-05For of size , of size and of size . The common value is , summed in either order.
Conjugate, transpose and adjoint of a product
EQ-PMM-06Conjugation preserves the order; transposition and adjunction reverse it. The reversal is required for conformability alone, before any entries are compared.
Inner product as a matrix product
EQ-PMM-07Treating vectors as single-column matrices identifies the inner product with a product, and the adjoint relation follows from the order-reversal rule.
Variable Definitions
| Symbol | Name | Meaning | Domain / type |
|---|---|---|---|
| Left factor | Matrix appearing first in a product | m x n matrix | |
| Middle factors | Matrices of matching size, so that exists in the distributive laws | n x p matrices | |
| Right factor | Matrix completing a three-term chain | p x s matrix | |
| Scalar | Multiplier that may be moved into either factor of a product | element of C | |
| Identity matrix | Square matrix with ones on the diagonal, the multiplicative identity of | n x n matrix | |
| Zero matrix | Matrix of all zeros, annihilator under multiplication and identity under addition | m x p matrix | |
| Transpose | Rows and columns exchanged; reverses factor order in a product | n x m matrix | |
| Adjoint | Conjugate transpose ; reverses factor order and conjugates entries | n x m matrix | |
| Matrix space | The set of all matrices; is a ring under these operations | vector space over C |
Worked Numerical Example
Problem statement
A measurement chain applies three linear stages to a raw reading: a -channel calibration vector is combined by a sensor-fusion stage, then reduced by a output stage. Verify associativity numerically, count the cost of both groupings, and confirm the transpose reversal rule on the same data.
Define the three factors
is the output stage, the fusion stage and the raw reading. The chain is conformable as and produces a result whichever way it is grouped.
Group from the left: form the composite stage first
Computing collapses the two stages into a single operator. Entry , for instance, is .
Apply the composite to the reading
Row of against gives ; row gives .
Group from the right instead
Now push the reading through the fusion stage first, then through the output stage. is a intermediate: , and .
Compare the cost of the two groupings
Left grouping: multiplications to form , then to apply it, giving . Right grouping: for , then , giving . Associativity guarantees identical answers; only the work differs, here by a factor of , and by far more at realistic sizes.
Verify the transpose reversal
is , so is . The only conformable product of the transposed factors is , of size . Computing both gives the same array, entry for entry.
Confirm that the wrong order is not even defined
The erroneous form would be , which is not conformable at all. Checking sizes therefore catches this particular mistake before any arithmetic, which is why the size check belongs at the start of every manipulation rather than the end.
Note what is not being claimed
Nothing here shows ; indeed does not exist, since has four columns and has two rows. Associativity concerns grouping only, never the order of the factors, and the two are routinely confused.
Both groupings return , as associativity requires, but the right-to-left evaluation uses multiplications against . The engineering rule follows directly: when a chain of operators ends in a vector, apply the factors to the vector rather than forming the composite operator — unless the composite will be reused across many readings, in which case forming it once amortises the cost. The transpose of the two-stage chain is the reversed product of the transposed stages, which is the identity that propagates sensitivities backwards through the same chain.
Applications & Industry Use
Kinematic chains and frame composition
The pose of an end effector is the product of the homogeneous transforms of each joint. Associativity lets sub-chains be precomputed and cached, while non-commutativity is the formal statement that rotating then translating differs from translating then rotating — a distinction that shows up as a physical error, not a numerical one.
Element stiffness transformation
A local element stiffness matrix is mapped into global coordinates by the congruence . The order-reversal rule is what guarantees this expression is conformable and symmetric: , which equals the original whenever is symmetric.
Backpropagation through linear layers
A forward pass composes weight matrices in one order; the gradient computation composes their transposes in the reverse order, which is exactly the rule applied along the chain. Frameworks implement the backward pass as a transposed GEMM precisely because of this identity.
State transition over multiple steps
For a discrete-time system the state after steps is , and the power is well defined only because multiplication is associative. Time-varying systems compose their step matrices in strict order, and reversing that order gives a different and physically wrong trajectory.
Cascaded MIMO channels and precoders
An effective channel is the product of precoder, propagation and combiner matrices. Associativity permits the receiver to fold the combiner into the channel estimate, while the adjoint rule gives the matched filter as the natural receive processing, with making the relationship precise.
Gram matrices and normal equations
The cross-product matrix of a design matrix is symmetric because transposing it reverses the order and returns the same expression. That symmetry halves the storage and permits a Cholesky factorisation, and it is a direct consequence of the reversal rule rather than an accident of the data.
Design Considerations
Choose the parenthesisation before you compute
Associativity means grouping is free to choose and never free of consequence. For a chain of several matrices the optimal ordering is found by a standard dynamic programming algorithm in time for factors, which is negligible against the products themselves. Libraries that evaluate expressions lazily — Eigen, NumPy's multi_dot, most tensor frameworks — do this automatically; hand-written loops do not.
Never rely on commutativity, even when it happens to hold
Some specific pairs commute: a matrix with its own powers, with the identity, with any scalar multiple of the identity, and diagonal matrices with each other. Building a derivation on such a coincidence is fragile, because a later change of data or generalisation of the code silently invalidates it. State the commuting hypothesis explicitly if the argument depends on it.
Cancel only through an inverse, and record the side
From nothing follows unless is invertible, and then only by multiplying on the left by . Left and right cancellation are different operations with different requirements. Where is rectangular or singular, the correct tool is the null space of : must have every column in .
Use transpose flags rather than materialising transposes
Every BLAS multiply accepts transpose and conjugate-transpose flags on each operand, so is computed without ever forming or in memory. Explicitly transposing a large matrix costs a full pass over memory with poor locality and doubles the footprint, for no benefit.
Do not confuse mathematical associativity with floating-point associativity
and are equal as matrices but will generally differ in their last bits when computed in floating point, because floating-point addition is not associative and the two routes sum different intermediate quantities. Any test comparing two groupings must use a tolerance, and any claim of bitwise reproducibility must fix the evaluation order.
Exploit structure that the rules preserve
The product of two upper triangular matrices is upper triangular; the product of a matrix with its own adjoint is Hermitian; congruence preserves Hermitian symmetry and positive semi-definiteness. Recognising that a product is structured allows a specialised kernel and a specialised storage format, often halving both time and memory.
Standards & Codes
Notation, interchange and numerical standards that govern how this material is written down, stored and computed in production systems.
| Reference | Title | Relevance to this topic |
|---|---|---|
BLAS Level 3 | Basic Linear Algebra Subprograms, matrix-matrix operations | The xGEMM signature encodes the scalar rule and distributivity directly in its interface, and its transpose flags implement the order-reversal rule without materialising a transpose. |
ISO 80000-2 | Quantities and units — Part 2: Mathematics | Standardises the notation for the identity matrix, the transpose and the conjugate transpose, distinctions on which every identity in this page depends. |
IEEE 754-2019 | IEEE Standard for Floating-Point Arithmetic | Floating-point addition is not associative, so mathematically identical groupings of a matrix chain produce numerically different results; the standard defines the rounding that bounds the discrepancy. |
ISO/IEC 14882 | Programming languages — C++ | Operator overloading and expression templates allow a library to see a whole product chain before evaluating it, which is what permits automatic reassociation into the cheapest grouping. |
ISO/IEC 40314 | Mathematical Markup Language (MathML) Version 3.0 | Encodes products, transposes and adjoints with explicit grouping structure, so that the distinction between and survives into machine-readable form. |
Material Selection
For a mathematical topic, "material" is the numeric representation: the scalar field, storage format and precision the computation is built from.
| Representation | Select when | Trade-off |
|---|---|---|
| Exact integer or rational arithmetic | Verifying an algebraic identity, testing a proof, or working with combinatorial and stoichiometric data. | The identities hold exactly, so a discrepancy is a genuine error rather than rounding; but entry growth in long chains is rapid and memory use unbounded. |
| IEEE 754 binary64 | General engineering and scientific chains. | Identities hold to within a relative error of order ; equality tests between different groupings must use a tolerance rather than exact comparison. |
| IEEE 754 binary32 or reduced precision | Inference, graphics and real-time pipelines where throughput dominates. | Two to four times the throughput, but the gap between mathematically equal groupings widens, and long chains may need a wider accumulator to remain meaningful. |
| Finite field arithmetic | Coding theory, cryptography and combinatorial algorithms over or a prime field. | All ring properties on this page hold verbatim and there is no rounding at all; but there is no notion of magnitude, so conditioning and tolerance have no meaning. |
| Structured storage: triangular, symmetric, banded | The operands or the product are known to be structured, as in stiffness assembly or Cholesky-based statistics. | Halves storage and roughly halves arithmetic through specialised kernels, at the cost of code paths that must be selected correctly — using a general kernel on packed storage produces silent nonsense. |
| Real versus complex scalars | The data carries phase, as in spectral, phasor or quantum computation. | The transpose must be replaced by the adjoint throughout or the adjoint relation for inner products fails; complex multiplication costs roughly four times its real counterpart per entry. |
Manufacturing Notes
Implementation notes — how the result is actually produced by hand, by algorithm and by library, including cost and numerical behaviour.
The proof pattern in practice
To verify any proposed identity, expand a single entry of each side with the entry formula, then justify each rewriting step by naming the scalar property used — distributivity in , commutativity of complex multiplication, or exchange of finite summation order. If no such justification exists for a step, the identity is false, and constructing a counterexample is usually a matter of minutes.
Matrix chain ordering
Given factors with dimensions , the minimum multiplication count over all parenthesisations is computed by dynamic programming in time and space. For chains that mix wide and tall factors the saving over a naive left-to-right evaluation is routinely a factor of ten or more, and it costs nothing at run time.
Library behaviour
NumPy's multi_dot performs chain ordering automatically; the plain @ operator evaluates strictly left to right. Eigen builds an expression tree and can fuse a scalar and an addition into a single gemm call, implementing the scalar and distributive rules as a compile-time optimisation. MATLAB evaluates left to right and offers no automatic reassociation, so the parenthesisation written is the one executed.
Verification on random data
The cheapest test of an implementation is to assert the identities themselves: generate random conformable matrices and check , and against a tolerance proportional to times the norms involved. Failures at a level far above tolerance point to an index or conformability bug rather than to rounding.
Cost of the identities themselves
Nothing on this page is free at scale. Forming costs operations, and rewriting an expression to avoid forming a large intermediate is usually a bigger win than any low-level optimisation. Where an identity permits the same result to be obtained with a smaller intermediate — associativity around a vector, or a transpose flag instead of an explicit transpose — the algebra is the performance work.
Failure Modes & Common Mistakes
| Failure mode / mistake | Impact | Root cause | Prevention & detection |
|---|---|---|---|
| Assuming commutativity | high | Rewriting as inside a derivation by analogy with scalar algebra. | Preserve factor order in every step. Where a swap is genuinely needed, use the transpose or adjoint rule, or prove that the specific pair commutes. |
| Writing | high | Applying transposition factor by factor without reversing the order. | Check conformability of the rewritten expression: for non-square factors the wrong order is not even defined, which exposes the error immediately. |
| Writing | high | Distributing inversion over a product in the same erroneous way as transposition. | Use and confirm by multiplying out: . |
| Cancelling a common factor | high | Deducing from without establishing that is invertible. | Multiply by explicitly on the correct side, and only after invertibility is proved. Otherwise conclude only that the columns of lie in . |
| Concluding a factor is zero from a zero product | high | Treating as implying or , which fails because matrix rings have zero divisors. | Recall the standard counterexample of two non-zero matrices with zero product, and reason instead about column spaces and null spaces. |
| Mismatched sizes in the distributive law | medium | Applying when and have different shapes, so their sum does not exist. | Confirm and are the same size before distributing; the rule requires the sum to be defined, not merely each product. |
| Confusing transpose with adjoint on complex data | high | Using where is required, so conjugates are omitted and the adjoint relation for inner products fails. | Use the adjoint throughout complex work and test the relation on random complex data. |
| Expecting bitwise equality between groupings | low | Comparing with using exact equality in a unit test. | Compare with a tolerance scaled by and the norms of the operands; mathematical associativity does not survive floating-point rounding. |
FAQs
Which familiar arithmetic rules survive for matrices and which do not?
Associativity, both distributive laws, the scalar rule and the identity and zero laws all survive. Commutativity and cancellation do not, and the product of two non-zero matrices can be zero. The practical rule is to perform no manipulation that is not licensed by a stated theorem, because intuition transferred from scalar algebra is unreliable here.
Why does transposition reverse the order of a product but conjugation does not?
Conjugation acts entry by entry and leaves positions alone, so it commutes with every step of the entry formula. Transposition moves entries between rows and columns, and for the result to be conformable the factors must swap: the transpose of an product is , and only has that shape. The adjoint reverses order because it contains a transposition.
If , can I conclude that ?
No, unless is invertible. Cancellation fails because can hold with whenever the columns of lie in the null space of . If is invertible, multiply on the left by — and note that this is left cancellation only; the right-hand version requires the factor on the right.
Does associativity mean I can compute a chain in any order I like?
It means the result is the same for any grouping, not for any ordering of the factors. Rearranging which matrices are adjacent is illegal; changing where the parentheses sit is not only legal but is the standard optimisation, since the cost of different groupings can differ by orders of magnitude.
Why do two groupings of the same product give slightly different numbers in floating point?
Because floating-point addition is not associative, and the two groupings accumulate different intermediate sums with different rounding. Both results are correct within their error bounds, and the discrepancy is of order times the norms involved. Any comparison must therefore use a tolerance.
In what sense do square matrices form a ring?
For a fixed size , the set is closed under addition and multiplication, addition is commutative with identity and inverses, multiplication is associative with identity , and multiplication distributes over addition. That is exactly the definition of a ring with identity. It is non-commutative, and it has zero divisors, so it is not an integral domain and not a field.
How does the inner product fit into these rules?
Treat vectors as single-column matrices. Then is an ordinary matrix product with a result. Every property of matrix products then applies to inner products automatically, and the adjoint relation is a single application of the order-reversal rule.
References
- Beezer, R. A. A First Course in Linear Algebra, Version 0.70. University of Puget Sound, 2006. Section MM, subsection PMM. Licensed under the GNU Free Documentation License v1.2.
- ISO 80000-2:2019, Quantities and units — Part 2: Mathematics. International Organization for Standardization.
- Horn, R. A. and Johnson, C. R. Matrix Analysis, 2nd edition. Cambridge University Press, 2013.
- Cormen, T. H., Leiserson, C. E., Rivest, R. L. and Stein, C. Introduction to Algorithms, 4th edition. MIT Press, 2022. Matrix-chain multiplication.
- Dongarra, J. J., Du Croz, J., Duff, I. S. and Hammarling, S. A Set of Level 3 Basic Linear Algebra Subprograms. ACM Transactions on Mathematical Software, 1990.
- IEEE 754-2019, IEEE Standard for Floating-Point Arithmetic. Institute of Electrical and Electronics Engineers.
AI Suggested Questions
- Give me two non-zero 2x2 matrices whose product is the zero matrix, and explain why this makes cancellation impossible.
- Prove associativity of matrix multiplication by exchanging the order of a double summation, naming the property used at each step.
- Find the optimal parenthesisation for a chain of matrices with dimensions 30x35, 35x15, 15x5, 5x10 and 10x20, and give the multiplication counts.
- Which pairs of matrices commute, and how would I characterise the set of matrices commuting with a given diagonal matrix?
- Show how the transpose reversal rule produces the backward pass of a two-layer linear network from its forward pass.
- How large can the difference between A(BD) and (AB)D become in binary64, and how should a unit test set its tolerance?
Related Calculators
Test associativity, distributivity, the transpose reversal and the adjoint rule on supplied or random matrices with a scaled tolerance.
Matrix Chain Order OptimiserCompute the cheapest parenthesisation of a product chain from the operand dimensions and report the multiplication count for each grouping.
Commutator CalculatorEvaluate to measure how far two matrices are from commuting, with a relative measure against their norms.
