Chapter 8: Advanced Theory of Determinants
Chapter 8: Advanced Theory of Determinants
- Deeply understand the properties of determinants
- Master row and column expansion of determinants
- Understand algebraic cofactors of determinants
- Master Cramer’s rule
- Understand the relationship between determinants and volume
Geometric Meaning of Determinants
Two-Dimensional Case: Area
For a matrix:
The determinant represents the signed area of the parallelogram formed by vectors and .
Three-Dimensional Case: Volume
For a matrix, the determinant represents the signed volume of the parallelepiped formed by three vectors.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patches as patches
# Demonstrate the geometric meaning of determinants
fig = plt.figure(figsize=(15, 5))
# 2D case: Parallelogram area
ax1 = fig.add_subplot(131)
A = np.array([[3, 1], [1, 2]])
det_A = np.linalg.det(A)
# Draw vectors and parallelogram
origin = [0, 0]
v1 = A[:, 0] # [3, 1]
v2 = A[:, 1] # [1, 2]
# Four vertices of the parallelogram
vertices = np.array([[0, 0], v1, v1 + v2, v2, [0, 0]])
ax1.plot(vertices[:, 0], vertices[:, 1], 'b-', linewidth=2)
ax1.fill(vertices[:-1, 0], vertices[:-1, 1], alpha=0.3, color='lightblue')
ax1.arrow(0, 0, v1[0], v1[1], head_width=0.1, head_length=0.1, fc='red', ec='red')
ax1.arrow(0, 0, v2[0], v2[1], head_width=0.1, head_length=0.1, fc='green', ec='green')
ax1.set_xlim(-1, 5)
ax1.set_ylim(-1, 4)
ax1.grid(True)
ax1.set_title(f'2D: Area = det(A) = {det_A:.2f}')
ax1.set_xlabel('x')
ax1.set_ylabel('y')
# 3D case: Parallelepiped volume
ax2 = fig.add_subplot(132, projection='3d')
B = np.array([[2, 1, 0], [0, 2, 1], [1, 0, 2]])
det_B = np.linalg.det(B)
# Draw three vectors
origin = [0, 0, 0]
v1_3d = B[:, 0]
v2_3d = B[:, 1]
v3_3d = B[:, 2]
ax2.quiver(0, 0, 0, v1_3d[0], v1_3d[1], v1_3d[2], color='red', arrow_length_ratio=0.1)
ax2.quiver(0, 0, 0, v2_3d[0], v2_3d[1], v2_3d[2], color='green', arrow_length_ratio=0.1)
ax2.quiver(0, 0, 0, v3_3d[0], v3_3d[1], v3_3d[2], color='blue', arrow_length_ratio=0.1)
ax2.set_xlim(0, 3)
ax2.set_ylim(0, 3)
ax2.set_zlim(0, 3)
ax2.set_title(f'3D: Volume = |det(B)| = {abs(det_B):.2f}')
# Sign meaning of determinants
ax3 = fig.add_subplot(133)
# Positive and negative orientation examples
A_pos = np.array([[2, 1], [1, 3]])
A_neg = np.array([[2, 1], [3, 1]])
det_pos = np.linalg.det(A_pos)
det_neg = np.linalg.det(A_neg)
x = ['Positive Orientation', 'Negative Orientation']
y = [det_pos, det_neg]
colors = ['green' if d > 0 else 'red' for d in y]
ax3.bar(x, y, color=colors, alpha=0.7)
ax3.axhline(y=0, color='black', linestyle='-', linewidth=0.5)
ax3.set_ylabel('Determinant Value')
ax3.set_title('Sign Meaning of Determinant')
ax3.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
print(f"2×2 matrix determinant = {det_A:.2f}")
print(f"3×3 matrix determinant = {det_B:.2f}")
print(f"Positive orientation determinant = {det_pos:.2f}")
print(f"Negative orientation determinant = {det_neg:.2f}")
Properties of Determinants
Basic Properties
- Transpose property:
- Product property:
- Inverse property: (when is invertible)
- Triangular matrices: The determinant of an upper or lower triangular matrix equals the product of diagonal elements
Row Operation Properties of Determinants
import numpy as np
def demonstrate_determinant_properties():
"""Demonstrate various properties of determinants"""
# Original matrix
A = np.array([[2, 1, 3],
[1, 4, 2],
[3, 2, 1]], dtype=float)
print("Original matrix A:")
print(A)
print(f"det(A) = {np.linalg.det(A):.4f}")
print()
# Property 1: Swapping two rows changes the sign of determinant
A1 = A.copy()
A1[[0, 1]] = A1[[1, 0]] # Swap row 1 and row 2
print("Swapping row 1 and row 2:")
print(A1)
print(f"det(A1) = {np.linalg.det(A1):.4f}")
print(f"det(A1) = -det(A)? {np.isclose(np.linalg.det(A1), -np.linalg.det(A))}")
print()
# Property 2: Multiplying a row by constant k multiplies determinant by k
A2 = A.copy()
k = 3
A2[0] = k * A2[0] # Multiply row 1 by 3
print(f"Multiplying row 1 by {k}:")
print(A2)
print(f"det(A2) = {np.linalg.det(A2):.4f}")
print(f"det(A2) = {k} × det(A)? {np.isclose(np.linalg.det(A2), k * np.linalg.det(A))}")
print()
# Property 3: Adding k times a row to another row doesn't change determinant
A3 = A.copy()
A3[1] = A3[1] + 2 * A3[0] # Add 2 times row 1 to row 2
print("Adding 2 times row 1 to row 2:")
print(A3)
print(f"det(A3) = {np.linalg.det(A3):.4f}")
print(f"det(A3) = det(A)? {np.isclose(np.linalg.det(A3), np.linalg.det(A))}")
print()
# Property 4: If two rows are the same, determinant is 0
A4 = A.copy()
A4[1] = A4[0] # Row 2 equals row 1
print("Row 2 equals row 1:")
print(A4)
print(f"det(A4) = {np.linalg.det(A4):.4f}")
demonstrate_determinant_properties()
Algebraic Cofactors and Minors
Definition
For an matrix , the algebraic cofactor of element is defined as:
where is the determinant of the submatrix obtained by deleting row and column .
Row Expansion Formula
Column Expansion Formula
def cofactor_expansion_demo():
"""Demonstrate algebraic cofactors and row/column expansion"""
A = np.array([[2, 1, 3],
[0, 4, 2],
[1, 2, 1]])
print("Matrix A:")
print(A)
print(f"Standard calculation: det(A) = {np.linalg.det(A):.4f}")
print()
# Expansion along row 1
print("Expansion along row 1:")
det_row1 = 0
for j in range(3):
# Calculate algebraic cofactor
minor = np.delete(np.delete(A, 0, axis=0), j, axis=1)
cofactor = ((-1)**(0+j)) * np.linalg.det(minor)
term = A[0, j] * cofactor
det_row1 += term
print(f"a_{1}{j+1} × A_{1}{j+1} = {A[0, j]} × {cofactor:.4f} = {term:.4f}")
print(f"Result from row 1 expansion: {det_row1:.4f}")
print()
# Expansion along column 2 (contains more zero elements)
print("Expansion along column 2:")
det_col2 = 0
for i in range(3):
minor = np.delete(np.delete(A, i, axis=0), 1, axis=1)
cofactor = ((-1)**(i+1)) * np.linalg.det(minor)
term = A[i, 1] * cofactor
det_col2 += term
print(f"a_{i+1}2 × A_{i+1}2 = {A[i, 1]} × {cofactor:.4f} = {term:.4f}")
print(f"Result from column 2 expansion: {det_col2:.4f}")
cofactor_expansion_demo()
Cramer’s Rule
For the linear system , when , the system has a unique solution:
where is the matrix obtained by replacing the -th column of with vector .
def cramers_rule_demo():
"""Demonstrate Cramer's rule"""
# Linear system: 2x + y + 3z = 9
# x + 4y + 2z = 16
# 3x + 2y + z = 10
A = np.array([[2, 1, 3],
[1, 4, 2],
[3, 2, 1]], dtype=float)
b = np.array([9, 16, 10])
print("Linear system Ax = b:")
print("2x + y + 3z = 9")
print("x + 4y + 2z = 16")
print("3x + 2y + z = 10")
print()
det_A = np.linalg.det(A)
print(f"det(A) = {det_A:.4f}")
if abs(det_A) > 1e-10:
print("det(A) ≠ 0, system has unique solution")
print()
# Solve using Cramer's rule
solution_cramer = np.zeros(3)
for i in range(3):
# Construct matrix A_i
A_i = A.copy()
A_i[:, i] = b
det_A_i = np.linalg.det(A_i)
solution_cramer[i] = det_A_i / det_A
print(f"A_{i+1} (column {i+1} replaced with b):")
print(A_i)
print(f"det(A_{i+1}) = {det_A_i:.4f}")
print(f"x_{i+1} = det(A_{i+1})/det(A) = {solution_cramer[i]:.4f}")
print()
# Verify solution
solution_numpy = np.linalg.solve(A, b)
print("Cramer's rule solution:", solution_cramer)
print("NumPy solution:", solution_numpy)
print("Verify Ax =", A @ solution_cramer)
print("Original b =", b)
else:
print("det(A) = 0, system has no unique solution")
cramers_rule_demo()
Determinants of Special Matrices
Block Matrix Determinants
def block_matrix_determinant():
"""Calculate determinants of block matrices"""
# For block matrix [[A, B], [0, D]], det = det(A) × det(D)
A = np.array([[2, 1], [1, 3]])
B = np.array([[1, 2], [0, 1]])
C = np.array([[0, 0], [0, 0]]) # Zero matrix
D = np.array([[4, 1], [2, 3]])
# Construct block matrix
block_matrix = np.block([[A, B], [C, D]])
print("Block matrix:")
print(block_matrix)
print()
det_full = np.linalg.det(block_matrix)
det_A = np.linalg.det(A)
det_D = np.linalg.det(D)
print(f"Full matrix determinant: {det_full:.4f}")
print(f"det(A) = {det_A:.4f}")
print(f"det(D) = {det_D:.4f}")
print(f"det(A) × det(D) = {det_A * det_D:.4f}")
print(f"Formula verified: {np.isclose(det_full, det_A * det_D)}")
block_matrix_determinant()
Computational Techniques for Determinants
Using Row Operations to Simplify Calculation
def efficient_determinant_calculation():
"""Efficient method for calculating determinants"""
A = np.array([[1, 2, 3, 4],
[2, 1, 4, 3],
[3, 4, 1, 2],
[4, 3, 2, 1]], dtype=float)
print("Original matrix:")
print(A)
print(f"Direct calculation: det(A) = {np.linalg.det(A):.4f}")
print()
# Manual Gaussian elimination process
A_work = A.copy()
det_multiplier = 1 # Track the effect of row operations on determinant
print("Gaussian elimination process:")
for i in range(4):
# Select pivot
pivot_row = i + np.argmax(np.abs(A_work[i:, i]))
if pivot_row != i:
# Swap rows
A_work[[i, pivot_row]] = A_work[[pivot_row, i]]
det_multiplier *= -1 # Row swap changes sign
print(f"Swapping row {i+1} and row {pivot_row+1}, determinant changes sign")
# Elimination
for j in range(i+1, 4):
if A_work[i, i] != 0:
factor = A_work[j, i] / A_work[i, i]
A_work[j] = A_work[j] - factor * A_work[i]
print(f"After elimination step {i+1}:")
print(A_work)
print()
# Determinant of upper triangular matrix is product of diagonal elements
det_triangular = np.prod(np.diag(A_work)) * det_multiplier
print(f"Product of diagonal elements of upper triangular matrix: {np.prod(np.diag(A_work)):.4f}")
print(f"Determinant after considering row swaps: {det_triangular:.4f}")
# Verify using LU decomposition
from scipy.linalg import lu
P, L, U = lu(A)
det_lu = np.linalg.det(P) * np.prod(np.diag(U))
print(f"LU decomposition result: {det_lu:.4f}")
efficient_determinant_calculation()
Applications of Determinants
Area and Volume Calculations
def area_volume_applications():
"""Applications of determinants in area and volume calculations"""
# 1. Triangle area
# Three vertices: A(1,2), B(4,6), C(7,2)
vertices = np.array([[1, 2, 1],
[4, 6, 1],
[7, 2, 1]])
triangle_area = 0.5 * abs(np.linalg.det(vertices))
print(f"Triangle area = 1/2 × |det| = {triangle_area:.2f}")
# 2. Tetrahedron volume
# Four vertices: O(0,0,0), A(1,2,1), B(2,1,3), C(1,3,2)
tetrahedron = np.array([[1, 2, 1],
[2, 1, 3],
[1, 3, 2]])
tetrahedron_volume = abs(np.linalg.det(tetrahedron)) / 6
print(f"Tetrahedron volume = |det|/6 = {tetrahedron_volume:.2f}")
# 3. Visualization
fig = plt.figure(figsize=(12, 5))
# Triangle
ax1 = fig.add_subplot(121)
triangle_x = [1, 4, 7, 1]
triangle_y = [2, 6, 2, 2]
ax1.plot(triangle_x, triangle_y, 'b-o', linewidth=2, markersize=8)
ax1.fill(triangle_x[:-1], triangle_y[:-1], alpha=0.3, color='lightblue')
ax1.set_title(f'Triangle Area = {triangle_area:.2f}')
ax1.grid(True)
ax1.set_xlabel('x')
ax1.set_ylabel('y')
# Geometric meaning of cross product
ax2 = fig.add_subplot(122)
v1 = np.array([3, 2]) # Vector from A to B
v2 = np.array([2, -1]) # Another vector from some point
# Draw vectors
ax2.quiver(0, 0, v1[0], v1[1], angles='xy', scale_units='xy', scale=1, color='red', width=0.005)
ax2.quiver(0, 0, v2[0], v2[1], angles='xy', scale_units='xy', scale=1, color='blue', width=0.005)
# Magnitude of cross product equals parallelogram area
cross_product = v1[0] * v2[1] - v1[1] * v2[0]
vertices_para = np.array([[0, 0], v1, v1 + v2, v2, [0, 0]])
ax2.plot(vertices_para[:, 0], vertices_para[:, 1], 'g-', alpha=0.7)
ax2.fill(vertices_para[:-1, 0], vertices_para[:-1, 1], alpha=0.2, color='green')
ax2.set_title(f'Cross Product = {cross_product:.2f}')
ax2.grid(True)
ax2.set_xlabel('x')
ax2.set_ylabel('y')
ax2.set_xlim(-1, 4)
ax2.set_ylim(-2, 3)
plt.tight_layout()
plt.show()
area_volume_applications()
Chapter Summary
Key Concepts Review
| Concept | Definition | Geometric Meaning |
|---|---|---|
| Determinant | Signed volume of n-dimensional parallelepiped | |
| Algebraic Cofactor | Used for row/column expansion | |
| Cramer’s Rule | Explicit solution for linear systems |
Summary of Calculation Methods
Application Domains
- Geometric applications: Area, volume, cross product calculations
- Linear systems: Cramer’s rule for solutions
- Matrix theory: Invertibility testing, eigenvalue calculation
- Calculus: Jacobian determinant, variable substitution
- Physics: Angular momentum, magnetic fields, fluid mechanics
Determinants are a core concept in linear algebra, providing not only computational tools but more importantly revealing the essential characteristics of linear transformations. Mastering determinant theory lays a solid foundation for subsequent study of advanced topics such as eigenvalues and linear transformations.