Once we have a vector space, we need a way to describe its contents efficiently. If a vector space is a “playground,” then Linear Independence and Span are the rules for how many “tools” (vectors) you actually need to build everything in that playground.
1. The Concept of Span
The Span of a set of vectors is the set of all possible linear combinations of those vectors.
Intuition: If you have two non-parallel arrows in a 2D plane, their span is the entire plane because you can reach any point by scaling and adding those two arrows.
Interactive Lab
import numpy as np
import matplotlib.pyplot as plt
v1 = np.array([1, 2])
v2 = np.array([2, 1])
# Generate random linear combinations (c1*v1 + c2*v2)
points = []
for _ in range(500):
c1, c2 = np.random.uniform(-1, 1, 2)
points.append(c1*v1 + c2*v2)
points = np.array(points)
plt.scatter(points[:,0], points[:,1], alpha=0.5, s=10)
plt.quiver([0,0], [0,0], [v1[0], v2[0]], [v1[1], v2[1]], color=['r','b'], scale=5)
plt.title("The Span of two non-parallel vectors (fills a 2D area)")
plt.grid(True)
plt.show()
python
1import numpy as np
2import matplotlib.pyplot as plt
3
4v1 = np.array([1, 2])
5v2 = np.array([2, 1])
6
7# Generate random linear combinations (c1*v1 + c2*v2)
16plt.title("The Span of two non-parallel vectors (fills a 2D area)")
17plt.grid(True)
18plt.show()
2. Linear Independence: Avoiding Redundancy
A set of vectors is linearly independent if none of the vectors can be written as a linear combination of the others. In other words, they are all “original” and provide “new directions.”
Formal Definition
Vectors are linearly independent if the equation has only the trivial solution .
If a vector can be built from others, the set is Dependent. We can test this by checking the Rank of the matrix formed by these vectors. If , they are dependent.
9print(f"Set 1 Rank: {rank1} (Independent if rank=3)")
10
11# Case 2: Dependent vectors
12u1 = np.array([1, 2, 3])
13u2 = np.array([4, 5, 6])
14u3 = u1 + u2 # Explicitly dependent
15mat2 = np.array([u1, u2, u3])
16rank2 = np.linalg.matrix_rank(mat2)
17print(f"Set 2 Rank: {rank2} (Dependent if rank < 3)")
3. Visualizing Dependency in 3D
Imagine three vectors in 3D space. If one is a combination of the others, they all lie on a single plane (2D), even though there are three vectors.
Knowledge Check
If a set of vectors contains the zero vector, is it linearly independent?
Answer: No, because 0 * v1 + 1 * 0 = 0 is a non-trivial solution.
Any set containing the zero vector is dependent because you can always use a non-zero coefficient for the zero vector to sum to 0.
If a set of vectors contains the zero vector, is it linearly independent?
4. Why Does It Matter?
Linear independence tells us if our data is redundant. If you have 100 sensors measuring the same physical phenomenon (e.g., temperature) and they are perfectly correlated, your “feature matrix” will be rank-deficient. You have 100 numbers, but effectively only 1 “dimension” of information.
Interactive Lab
import numpy as np
# Simulate 3 redundant sensors
temp = np.random.normal(25, 1, 100) # True temperature
s1 = temp + 0.1
s2 = 2 * temp - 5
s3 = temp * 0.5 + 10
data = np.vstack([s1, s2, s3]).T
rank = np.linalg.matrix_rank(data)
print(f"Data shape: {data.shape}")
print(f"Calculated Rank: {rank}")
print("Even though we have 3 sensors, the rank is 1 because they are all linear scalings of each other.")
python
1import numpy as np
2
3# Simulate 3 redundant sensors
4temp = np.random.normal(25, 1, 100)# True temperature
5s1 = temp +0.1
6s2 =2* temp -5
7s3 = temp *0.5+10
8
9data = np.vstack([s1, s2, s3]).T
10rank = np.linalg.matrix_rank(data)
11
12print(f"Data shape: {data.shape}")
13print(f"Calculated Rank: {rank}")
14print("Even though we have 3 sensors, the rank is 1 because they are all linear scalings of each other.")
5. Summary Check
Knowledge Check
If Rank(A) = n for n vectors in R^n, the vectors are:
Answer: Linearly Independent
If Rank(A) = n for n vectors in R^n, the vectors are: