Function Repository Resource:

LinearlyIndependent

Source Notebook

Determine whether a set of vectors is linearly independent

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["LinearlyIndependent"][{vect1,vect2,}]

returns the conditions under which the given vectors are mutually linearly independent.

Details

For numeric input, ResourceFunction["LinearlyIndependent"] will return True or False. For symbolic input, the result may be a ConditionalExpression.

Examples

Basic Examples (4) 

Test some two-dimensional vectors for linear independence:

In[1]:=
ResourceFunction["LinearlyIndependent"][{{1, 2}, {3, 7}}]
Out[1]=

Test some three-dimensional vectors for linear independence:

In[2]:=
ResourceFunction[
 "LinearlyIndependent"][{{1, 2, 4}, {3, 5, 7}, {7, 8, 9}}]
Out[2]=

This set of vectors is linearly dependent:

In[3]:=
ResourceFunction[
 "LinearlyIndependent"][{a = {1, 3, -2}, b = {2, 1, -3}, c = {0, 5, -1}}]
Out[3]=

Confirm that the third vector can be written as a linear combination of the first two:

In[4]:=
2 a - b == c
Out[4]=

LinearlyIndependent works with any number of vectors of any dimension:

In[5]:=
ResourceFunction["LinearlyIndependent"][{{4, 2, 8, 3}, {3, 7, 1, 1}}]
Out[5]=

Scope (3) 

For vectors with symbolic parameters, LinearlyIndependent may return a ConditionalExpression:

In[6]:=
ResourceFunction[
 "LinearlyIndependent"][{{1, 3, -1}, {-1, -5, 5}, {4, 7, h}}]
Out[6]=
In[7]:=
ResourceFunction[
 "LinearlyIndependent"][{{a, b, c}, {d, e, f}, {g, h, i}}]
Out[7]=

A True/False result may be obtained by giving values to the parameters:

In[8]:=
ResourceFunction["LinearlyIndependent"][{{1, x, x}, {3, x, x}}]
Out[8]=
In[9]:=
% /. {x -> 2}
Out[9]=

LinearlyIndependent accepts vectors with complex components:

In[10]:=
ResourceFunction["LinearlyIndependent"][{{1, 2 + I}, {I, -1}}]
Out[10]=

Properties and Relations (6) 

A set of vectors is linearly independent if and only if the rank of the row matrix composed of the vectors equals the length of the vectors:

In[11]:=
mat = IdentityMatrix[5];
ResourceFunction["LinearlyIndependent"][mat]
Out[12]=
In[13]:=
MatrixRank[mat] == Dimensions[mat][[2]]
Out[13]=

A set of vectors is linearly independent if and only if the rank of the row matrix composed of the vectors has a zero-dimensional null space:

In[14]:=
mat = HilbertMatrix[3];
ResourceFunction["LinearlyIndependent"][mat]
Out[15]=
In[16]:=
ResourceFunction["Nullity"][mat]
Out[16]=

Or, alternatively:

In[17]:=
Length[NullSpace[mat]]
Out[17]=

A set of vectors is linearly independent if and only if the rank of the row matrix composed of the vectors has a nonzero determinant:

In[18]:=
mat = ToeplitzMatrix[4];
ResourceFunction["LinearlyIndependent"][mat]
Out[19]=
In[20]:=
Det[mat] == 0
Out[20]=

A set of vectors is linearly independent if and only if its row-reduced form has a no zeros along its diagonal:

In[21]:=
mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
res = RowReduce[mat];
res // MatrixForm
Out[22]=
In[23]:=
Diagonal[res]
Out[23]=
In[24]:=
ResourceFunction["LinearlyIndependent"][mat]
Out[24]=

The zero vector is linearly dependent on every other vector:

In[25]:=
ResourceFunction["LinearlyIndependent"][{{0, 0}, {a, b}}]
Out[25]=

LinearlyIndependent will not evaluate if the vectors do not all have the same length:

In[26]:=
ResourceFunction["LinearlyIndependent"][{{1, 2}, {3, 7, 8}, {2, 5}}]
Out[26]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 3.0.0 – 23 March 2023
  • 2.1.0 – 11 May 2021
  • 2.0.0 – 24 January 2020
  • 1.0.0 – 03 October 2019

Related Resources

License Information