Inactive Tutor answered 03/22/24
Tutor
New to Wyzant
import numpy as np
import sympy
"""
We can approach this problem by using a matrix
which consists of the vectors given in the problem
as the columns, then we use python to find the RREF
of the resulting matrix and its corresponoding rank.
"""
# Defining the vectors from the problem
v1 = np.array([2, 1, 1, 3])
v2 = np.array([3, 2, 0, 1])
v3 = np.array([1, 0, 2, 5])
v4 = np.array([-1, -1, 1, 2])
v5 = np.array([3, 2, 0, 0])
v6 = np.array([13, 8, 2, 8])
# Create a matrix with the vectors as its columns
T = np.array([v1, v2, v3, v4, v5, v6]).T
# Calculate the rank of T to determine the number
# of linearly independent vectors
rank_T = np.linalg.matrix_rank(T)
# Perform row reduction to get the RREF
U, pivots = sympy.Matrix(T).rref()
# Extract the linearly independent vectors from T
# using the pivot columns
S = T[:, pivots]
# Output the results
print("Linearly independent subset S of T:")
print(S)
# Check if T spans R^4
spans_R4 = rank_T == 4
print(f"Does T span R^4? {'Yes' if spans_R4 else 'No'}")
"""
You should get the following output upon running this code:
Linearly independent subset S of T:
[[2 3 3]
[1 2 2]
[1 0 0]
[3 1 0]]
Does T span R^4? No
"""