Basis and Dimension
The concepts of basis and dimension provide a way to “measure” the size and complexity of a vector space.
Linear Independence and Spanning
A set of vectors is linearly independent if the only solution to is for all . The span of a set is the set of all possible linear combinations.
python
1import numpy as np
2
3def check_linear_independence(vectors):
4 matrix = np.array(vectors).T
5 rank = np.linalg.matrix_rank(matrix)
6 is_independent = rank == len(vectors)
7 return is_independent, rank
8
9# Test linearly independent vectors
10v1 = [1, 0, 0]
11v2 = [0, 1, 0]
12print(f"Independent: {check_linear_independence([v1, v2])}")
13
14# Test linearly dependent vectors
15v3 = [1, 1, 0]
16print(f"Independent with v3: {check_linear_independence([v1, v2, v3])}")
Definition of a Basis
A basis for a vector space is a set of vectors that:
- Is linearly independent.
- Spans .
How many vectors are in any basis of R^3?
Dimension
The dimension of a vector space , denoted , is the number of vectors in any basis for .
python
1import numpy as np
2
3def get_dimension(matrix):
4 # The dimension of the column space is the rank
5 return np.linalg.matrix_rank(matrix)
6
7A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
8print(f"Rank (Dimension of Col Space) of A: {get_dimension(A)}")
9print("A rank of 2 means the vectors are coplanar in R^3.")