Three basic operations are defined on matrices:
1. Scalar multiplication. For A=[aij]m×n and a scalar k, kA=[kaij]m×n — every entry is scaled by k. Taking k=−1 gives −A=[−aij], the negative of A (never call it "a negative matrix").
2. Addition and subtraction. These are defined only when A and B have the same order. Then A+B=[aij+bij] and A−B=A+(−1)B=[aij−bij], entrywise. If the orders differ, A+B and A−B are simply not defined. Addition/subtraction extends to any finite number of matrices of the same order.
3. Multiplication. A is conformable for the product AB only when the number of columns of A equals the number of rows of B: if A is m×n and B is n×p, then AB exists and has order m×p — schematically (m×n)(n×p)=(m×p), with the inner dimensions matching and cancelling. Each entry of AB is a row-by-column dot product:
cij=∑k=1naikbkj=ai1b1j+ai2b2j+⋯+ainbnj.
There is no division of matrices — A/B is never defined. Also, unlike ordinary numbers, matrix multiplication is not commutative in general (AB=BA, even when both products exist and even have different orders), it does not obey cancellation (AB=AC with A=O need not give B=C), and AB=O does not force A=O or B=O — two nonzero matrices can multiply to the zero matrix.