1
$\begingroup$

I have a matrix whose rows are components of vectors and I wish to find the set of linearly independent vectors while at the same time find what linear combination of the basis vectors gives the dependent ones. Is it possible to do so in mathematica ? I tried

In: Arr = {{1, 2, 3, x}, {7, 8, 9, y}, {5, 6, 6, z}}

In: RowReduce[Arr]

\begin{array}{cccc}
 1 & 0 & 0 & -x+y-z \\
 0 & 1 & 0 & \frac{1}{2} (x-3 y+4 z) \\
 0 & 0 & 1 & \frac{1}{3} (x+2 y-3 z) \\
\end{array}

which is good as I get all the performed operations. However as soon as the vectors become linearly dependent,the output is wrong.

Arr = {{1, 2, 3, x}, {7, 8, 9, y}, {6, 6, 6, z}} 

\begin{array}{cccc}
1 & 0 & -1 & 0 \\
0 & 1 & 2 & 0 \\
0 & 0 & 0 & 1 \\
\end{array}

Is it possible to extend the preceding approach to the case of linearly dependent vectors ? Also for some reason the editor in stackexchange is not treating the latex code correctly. Sorry for the poor presentation

$\endgroup$
  • $\begingroup$ Related: (133408) $\endgroup$ – anderstood Mar 22 '17 at 20:35
  • $\begingroup$ Can't you use Solve? $\endgroup$ – anderstood Mar 22 '17 at 20:38
  • $\begingroup$ My problem is to find the basis of the set of vectors and then express the dependent vectors in terms of the basis. I do not need to solve any linear system of equation. Also my question above is why RowReduce gives me symbolic output in one case and numeric in the latter ? $\endgroup$ – Abhishek Pal Mar 22 '17 at 20:41
  • $\begingroup$ You seem to be coding a mathematica problem in TeX. I have no idea what it is being shown. $\endgroup$ – Daniel Lichtblau Mar 22 '17 at 21:10
  • $\begingroup$ I am sorry for the presentation. I do not know of any other way of writing a matrix in this editor. If you do then Please let me know so that I can improve the presentation $\endgroup$ – Abhishek Pal Mar 22 '17 at 21:12
4
$\begingroup$

Augment with an identity matrix on the right before row reducing. The result will contain the reduced echelon form in the unaugmented part, and the multipliers in the augmented part.

mat = {{1, 2, 3, x}, {7, 8, 9, y}, {5, 6, 6, z}};
red = RowReduce[Join[mat, IdentityMatrix[Length[mat]], 2]];
reducedMat = red[[All, 1 ;; Length[mat[[1]]]]]
mults = red[[All, Length[mat[[1]]] + 1 ;; -1]]

(* Out[10]= {{1, 0, 0, -x + y - z}, {0, 1, 0, 1/2 (x - 3 y + 4 z)}, {0, 
  0, 1, 1/3 (x + 2 y - 3 z)}}

Out[11]= {{-1, 1, -1}, {1/2, -(3/2), 2}, {1/3, 2/3, -1}} *)

Check:

Expand[mults.mat - reducedMat]

(* Out[14]= {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}} *)
$\endgroup$
  • $\begingroup$ The above code is brilliant. Thank you. $\endgroup$ – Abhishek Pal Mar 22 '17 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.