1.2 — Глава I, §1. Матрицы1.2 — Chapter I, §1. Matrices
Сложение и умножение на число почти буквально копируют арифметику чисел — операции поэлементные, ассоциативные, коммутативные. Умножение матриц — совсем другая история: оно ассоциативно, но не коммутативно (AB ≠ BA в общем случае), требует согласованности размеров и стоит O(n³) наивно — именно это отличие делает линейную алгебру нетривиальной дисциплиной, а не просто «арифметикой таблиц».Addition and scalar multiplication almost literally copy the arithmetic of numbers — element-wise, associative, commutative operations. Matrix multiplication is a different story entirely: it's associative but not commutative (AB ≠ BA in general), it requires matching dimensions, and it costs O(n³) naively — that difference is what makes linear algebra a nontrivial discipline rather than just "arithmetic on tables."
Операция сложения матриц вводится только для матриц одинаковых размеров: суммой A_(m×n) = (a_ij) и B_(m×n) = (b_ij) называется матрица C_(m×n) = (c_ij), где c_ij = a_ij + b_ij. Ничего не поделаешь — это ровно то, чего ждёшь от «таблицы чисел»: складываешь то, что стоит на одинаковых местах.Matrix addition is defined only for matrices of the same size: the sum of A_(m×n) = (a_ij) and B_(m×n) = (b_ij) is the matrix C_(m×n) = (c_ij) where c_ij = a_ij + b_ij. Nothing surprising here — it's exactly what you'd expect from a "table of numbers": add whatever sits in the same slot.
| 2 -3 0 | | 3 3 -1 | | 5 0 -1 |
| 4 5 6 | + | -2 -5 4 | = | 2 0 10 |
Произведением матрицы A_(m×n) = (a_ij) на число k называется матрица B_(m×n) = (b_ij), где b_ij = k · a_ij. Матрица -A = (-1) · A называется противоположной, а разность A - B = A + (-B).The product of a matrix A_(m×n) = (a_ij) and a number k is the matrix B_(m×n) = (b_ij), where b_ij = k · a_ij. The matrix -A = (-1) · A is called opposite to A, and the difference is A - B = A + (-B).
A = | 0 -1 2 |, k = 2, A·k = | 0 -2 4 |
| 3 4 5 | | 6 8 10 |
Обе операции обладают свойствами, буквально повторяющими школьную алгебру чисел: коммутативность и ассоциативность сложения, дистрибутивность умножения на число, нейтральность O и 1:Both operations satisfy properties that literally mirror school-level number algebra: commutativity and associativity of addition, distributivity of scalar multiplication, and the neutrality of O and 1:
A + B = B + A;A + (B + C) = (A + B) + C;A + O = A;A - A = O;1 · A = A;α · (A + B) = αA + αB;(α + β) · A = αA + βA;α · (βA) = (αβ) · A.Это тот редкий случай в линейной алгебре, когда интуиция «как с числами» работает без исключений — все сюрпризы начинаются с умножения матриц.This is the rare case in linear algebra where the "just like numbers" intuition holds without exceptions — all the surprises start with matrix multiplication.
Элементарными преобразованиями матрицы являются: перестановка местами двух параллельных рядов, умножение всех элементов ряда на число ≠ 0, прибавление к ряду другого ряда, умноженного на число. Две матрицы, получаемые одна из другой такими преобразованиями, называются эквивалентными (A ~ B).The elementary transformations of a matrix are: swapping two parallel rows/columns, multiplying all elements of a row/column by a nonzero number, and adding to a row/column another row/column multiplied by a number. Two matrices obtainable from one another by such transformations are called equivalent (A ~ B).
Это не абстрактное упражнение — это ровно то, что происходит на каждом шаге метода Гаусса (см. 4.4): вычитание строки, умноженной на коэффициент, из другой строки, чтобы обнулить элемент под диагональю. Любую матрицу элементарными преобразованиями можно привести к каноническому виду — с единицами на диагонали и нулями всюду ещё, и число этих единиц окажется в точности рангом матрицы (см. 3.3).This isn't an abstract exercise — it's precisely what happens at every step of Gaussian elimination (see 4.4): subtracting a scaled row from another row to zero out an entry below the diagonal. Any matrix can be reduced by elementary transformations to canonical form — ones on the diagonal and zeros everywhere else — and the number of those ones turns out to be exactly the rank of the matrix (see 3.3).
Привести к каноническому виду матрицуReduce the following matrix to canonical form
A = | 2 3 1 2 |
| 0 2 -1 1 |
| 4 0 5 1 |
Решение: выполняя элементарные преобразования, получаемSolution: performing elementary transformations, we obtain
| 2 3 1 2 | | 1 3 2 2 | | 1 3 2 2 |
| 0 2 -1 1 | ~ |-1 2 0 1 | ~ | 0 5 2 3 | ~
| 4 0 5 1 | | 5 0 4 1 | | 0 -15 -6 -9|
| 1 0 0 0 | | 1 0 0 0 | | 1 0 0 0 |
~ | 0 5 2 3 | ~ | 0 1 1 1 | ~ | 0 1 1 1 | ~
| 0 -15 -6 -9| | 0 -3 -3 -3 | | 0 0 0 0 |
| 1 0 0 0 |
~ | 0 1 1 1 |
| 0 0 0 0 |
Две единицы на диагонали — ранг этой матрицы равен 2.Two ones on the diagonal — the rank of this matrix is 2.
Умножение двух матриц определено только когда число столбцов первой равно числу строк второй — это не бюрократическое ограничение, а прямое следствие того, что матрица — это отображение: B: ℝⁿ → ℝᵖ, затем A: ℝᵖ → ℝᵐ компонуются в AB: ℝⁿ → ℝᵐ только если пространство, в которое приходит B, совпадает с тем, откуда стартует A.Multiplying two matrices is defined only when the number of columns of the first equals the number of rows of the second — that's not a bureaucratic restriction, it's a direct consequence of a matrix being a map: B: ℝⁿ → ℝᵖ, then A: ℝᵖ → ℝᵐ compose into AB: ℝⁿ → ℝᵐ only if the space B lands in matches the space A starts from.
Произведением A_(m×n) на B_(n×p) называется матрица C_(m×p) = (c_ik), гдеThe product of A_(m×n) and B_(n×p) is the matrix C_(m×p) = (c_ik), where
c_ik = a_i1·b_1k + a_i2·b_2k + ... + a_in·b_nk
— элемент i-й строки и k-го столбца результата равен скалярному произведению i-й строки A на k-й столбец B. Отсюда сразу видна стоимость операции: m·p элементов результата, каждый — сумма из n слагаемых, итого наивная сложность O(m·n·p) (для квадратных n×n — O(n³)). Это одна из самых массово оптимизируемых операций в вычислительной технике — от BLAS до тензорных ядер GPU, потому что она лежит в основе почти всего численного ML.— the entry in row i, column k of the result is the dot product of row i of A with column k of B. This immediately reveals the cost of the operation: m·p result entries, each a sum of n terms, for a naive complexity of O(m·n·p) (for square n×n matrices, O(n³)). It's one of the most heavily optimized operations in computing — from BLAS to GPU tensor cores — because it underlies almost all of numerical ML.
Если A и B квадратные одного размера, то AB и BA оба существуют, но, как показывает Пример 1.6, могут даже не совпадать по размеру, если матрицы не квадратные — а если и квадратные, то в общем случае AB ≠ BA. Единичная матрица — исключение: A · E = E · A = A.If A and B are square of the same size, both AB and BA exist, but as Example 1.6 shows, they might not even match in size if the matrices aren't square — and even when they are, in general AB ≠ BA. The identity matrix is the exception: A · E = E · A = A.
| a11 a12 a13 | | b11 b12 |
| a21 a22 a23 |_(2x3) × | b21 b22 |
| b31 b32 |_(3x2)
= | a11b11+a12b21+a13b31 a11b12+a12b22+a13b32 |
| a21b11+a22b21+a23b31 a21b12+a22b22+a23b32 |_(2x2)
A = (1 2 1; 3 1 0), B = (1 3; 1 2). Произведение A · B не определено (3 столбца у A ≠ 2 строки у B), но B × A определено:A = (1 2 1; 3 1 0), B = (1 3; 1 2). The product A · B is undefined (3 columns of A ≠ 2 rows of B), but B × A is defined:
| 1 3 | | 1 2 1 | | 10 5 1 |
| 1 2 | × | 3 1 0 | = | 7 4 1 |
Наглядная демонстрация того, что вопрос «AB = BA?» для не квадратных матриц зачастую даже не имеет смысла — это разные операции над разными пространствами.A vivid demonstration that the question "does AB = BA?" often doesn't even make sense for non-square matrices — these are different operations over different spaces.
Матрицы A и B называются перестановочными, если AB = BA — это исключение, а не правило (простейший пример перестановочных матриц — любые две диагональные матрицы одного размера). Умножение матриц ассоциативно и дистрибутивно, но не коммутативно:Matrices A and B are called commuting if AB = BA — that's the exception, not the rule (the simplest example of commuting matrices is any two diagonal matrices of the same size). Matrix multiplication is associative and distributive, but not commutative:
A · (B · C) = (A · B) · C;A · (B + C) = AB + AC;(A + B) · C = AC + BC;α(AB) = (αA)B.Для транспонирования: (A + B)^T = A^T + B^T, и — что менее очевидно — (AB)^T = B^T · A^T: порядок сомножителей при транспонировании произведения переворачивается, ровно как при обращении композиции функций (f∘g)⁻¹ = g⁻¹∘f⁻¹.For transposition: (A + B)^T = A^T + B^T, and — less obviously — (AB)^T = B^T · A^T: the order of the factors flips under transposition of a product, exactly as it does when inverting a function composition, (f∘g)⁻¹ = g⁻¹∘f⁻¹.
Самая частая ошибка новичка — машинально переставить множители при упрощении матричного выражения, как это привычно с числами. В приложениях порядок умножения матриц кодирует порядок применения преобразований: сначала повернуть, потом сдвинуть — не то же самое, что сначала сдвинуть, потом повернуть. Собственно, теория групп (некоммутативные группы) во многом выросла из наблюдения, что композиция геометрических преобразований именно такая.The most common beginner mistake is reflexively swapping factors when simplifying a matrix expression, out of habit from numbers. In applications, the order of matrix multiplication encodes the order transformations are applied: rotate then translate is not the same as translate then rotate. In fact, group theory (non-commutative groups) grew largely out of the observation that composing geometric transformations behaves exactly this way.
В арифметике чисел из ab = 0 следует a = 0 или b = 0 (отсутствие делителей нуля). У матриц это ломается: существуют ненулевые A и B, для которых AB = O — например, любые две матрицы с непересекающимися образом и ядром. Это прямое следствие того, что матрицы могут быть вырожденными (см. 3.1) — понятие, у чисел отсутствующее в принципе.In number arithmetic, ab = 0 implies a = 0 or b = 0 (no zero divisors). This breaks for matrices: there exist nonzero A and B with AB = O — for instance, any two matrices whose image and kernel don't overlap. This is a direct consequence of matrices being able to be singular (see 3.1) — a notion that doesn't even exist for plain numbers.
Формула из определения задаёт O(n³) для перемножения квадратных матриц n×n, но это далеко не предел: алгоритм Штрассена даёт O(n^2.807), а теоретический рекорд ещё ниже. На практике же реальный выигрыш производительности почти всегда приходит не от смены алгоритма, а от blocking/tiling под кэш CPU и векторизации (см. HPC, раздел 07) — асимптотика важна для собеседований, а cache-friendly доступ к памяти — для реальной скорости BLAS-библиотек.The formula from the definition gives O(n³) for multiplying n×n square matrices, but that's far from the limit: Strassen's algorithm achieves O(n^2.807), and the theoretical record goes even lower. In practice, though, the real performance win almost never comes from swapping algorithms — it comes from cache blocking/tiling and vectorization (see HPC, section 07) — asymptotics matter for interviews, cache-friendly memory access matters for the actual speed of BLAS libraries.
источникsource
Определения, свойства и Примеры 1.2–1.6 — по изданию: Письменный Д. Т. Конспект лекций по высшей математике: полный курс. — 9-е изд. — М.: Айрис-пресс, 2009. — 608 с. — Глава I, §1.2 «Действия над матрицами», с. 17–20. Интуиция, связь со сложностью вычислений и раздел «Грабли» — авторское дополнение.Definitions, properties, and Examples 1.2–1.6 — from: Pismenny D. T. Lecture Notes on Higher Mathematics: Complete Course. — 9th ed. — Moscow: Iris-press, 2009. — 608 p. — Chapter I, §1.2 "Operations on Matrices," pp. 17–20. The intuition, ties to computational complexity, and the "Gotchas" section are original additions.