Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-317

Span Membership 3D

Problem

Decide whether a vector v lies in the span of a list of 3D vectors.

Build the augmented matrix with the spanning vectors as columns and v as the last column, then row reduce. Return False if an inconsistent row (all zeros except the last entry) appears, and True otherwise.

Hint

v is in the span exactly when the augmented system is consistent.

Test cases

case 1
in: [[[1,0,0],[0,1,0]],[0,0,1]]
expected: false
case 2
in: [[[1,1,0],[0,0,1]],[2,2,5]]
expected: true
case 3
in: [[[1,1,0],[0,0,1]],[1,0,1]]
expected: false
case 4
in: [[],[0,0,0]]
expected: true
case 5
in: [[[1,2,3],[2,4,6]],[3,6,9]]
expected: true
Starter codePython
def span_membership_3d(vectors, v):
    # Your code here
    pass

5 test cases · run your code against them in the editor