Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Decompose a vector into a linear combination of a set of vectors
ResourceFunction["LinearCombination"][{u},{vi}] returns a list of coefficients that express u as a linear combination of the basis vectors vi. | |
ResourceFunction["LinearCombination"][{u}, {vi}, type] returns the given representation type that express u as a linear combination of the vi. |
Express a vector as a combination of two vectors:
In[1]:= | ![]() |
Out[1]= | ![]() |
Express the output as an Association:
In[2]:= | ![]() |
Out[2]= | ![]() |
Display the linear combination as an Inactive expression:
In[3]:= | ![]() |
Out[4]= | ![]() |
Verify the decomposition is correct:
In[5]:= | ![]() |
Out[5]= | ![]() |
Express a matrix in terms of a set of matrices:
In[6]:= | ![]() |
Out[6]= | ![]() |
Verify the decomposition is correct:
In[7]:= | ![]() |
Out[7]= | ![]() |
If no linear combination is found, LinearCombination returns unevaluated:
In[8]:= | ![]() |
Out[8]= | ![]() |
If the basis set is not linearly independent, LinearCombination will return one combination from the infinite set of possibilities:
In[9]:= | ![]() |
Out[9]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License