Matrix Algebra
1. Introduction
Matrix Algebra is the branch of mathematics dealing with operations on matrices. Matrices are rectangular arrays of numbers, symbols, or expressions arranged in rows and columns. They are widely used in various fields, including engineering, physics, economics, and computer graphics.
2. Matrix Operations
Matrix operations include addition, subtraction, scalar multiplication, and matrix multiplication.
Addition and Subtraction
For matrices \(A = [a_{ij}]\) and \(B = [b_{ij}]\) of the same size:
Scalar Multiplication
For a scalar \(k\):
Matrix Multiplication
For matrices \(A (m \times n)\) and \(B (n \times p)\):
Code Example
import numpy as np
# Define matrices
A = np.array([[1, 2], [3, 4]])
B = np.array([[5, 6], [7, 8]])
# Matrix addition
C = A + B
# Matrix multiplication
D = A @ B
print("Addition:\n", C)
print("Multiplication:\n", D)
3. The Inverse of the Matrix
The inverse of a square matrix \(A\) is denoted \(A^{-1}\), where:
\(I\) is the identity matrix.
Formula for 2x2 Matrix
For \(A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}\):
Code Example
# Define a matrix
A = np.array([[4, 7], [2, 6]])
# Compute the inverse
A_inv = np.linalg.inv(A)
print("Inverse:\n", A_inv)
4. Characterizations of Invertible Matrices
A square matrix \(A\) is invertible if:
- \(\det(A) \neq 0\).
- \(A\) has full rank.
- The rows or columns of \(A\) are linearly independent.
5. Partitioned Matrices
Partitioned matrices divide a matrix into smaller submatrices for easier computations.
Example
For \(A\):
This structure is useful for block multiplication and solving systems of equations.
6. Matrix Factorizations
Matrix factorizations decompose matrices into simpler forms:
LU Factorization
\(A = LU\), where:
- \(L\): Lower triangular matrix.
- \(U\): Upper triangular matrix.
QR Factorization
\(A = QR\), where:
- \(Q\): Orthogonal matrix.
- \(R\): Upper triangular matrix.
Code Example
from scipy.linalg import lu
# Define a matrix
A = np.array([[4, 3], [6, 3]])
# LU decomposition
P, L, U = lu(A)
print("L:\n", L)
print("U:\n", U)
7. The Leontief Input/Output Model
This economic model represents interdependencies between sectors:
Where:
- \(A\): Input-output matrix.
- \(d\): Final demand vector.
8. Applications of Matrix Algebra to Computer Graphics
Matrices are essential in transforming coordinates in computer graphics:
Translation
Rotation
Code Example
# Define a 2D rotation matrix
import math
angle = math.pi / 4 # 45 degrees
R = np.array([[math.cos(angle), -math.sin(angle)],
[math.sin(angle), math.cos(angle)]])
# Rotate a point
point = np.array([1, 0])
rotated_point = R @ point
print("Rotated Point:", rotated_point)
9. Subspaces of \(\mathbb{R}^n\)
Subspaces are subsets of \(\mathbb{R}^n\) closed under addition and scalar multiplication.
Examples
- Column space: Set of all linear combinations of columns.
- Null space: Set of all solutions to \(A\mathbf{x} = 0\).
10. Dimension and Rank
The dimension of a subspace is the number of vectors in its basis. The rank of a matrix is the dimension of its column space.
Rank-Nullity Theorem
Code Example
# Define a matrix
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Compute rank
rank = np.linalg.matrix_rank(A)
print("Rank:", rank)
This guide covers fundamental concepts, practical examples, and Python implementations to help you master matrix algebra.