Gaussian Elimination

Author

Eric W. Weisstein
October 20, 2005

This notebook downloaded from http://mathworld.wolfram.com/notebooks/LinearAlgebra/GaussianElimination.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/GaussianElimination.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

GaussianElimination[m_List?MatrixQ,v_List?VectorQ]:=Last/@RowReduce[Flatten/@Transpose[{m,v}]]

Example

m=Partition[Table[Random[Integer,{1,9}],{9}],3]

m={{9,3,4},{4,3,4},{1,1,1}};

v=Table[Random[Integer,{1,9}],{3}]

v={7,8,3};

x=Inverse[m].v

m.x

vars={x1,x2,x3};

Solve[m.vars==v,vars]

Solve[{{1,1,1},{4,3,4},{9,3,4}}.vars=={3,8,7},vars]

Flatten/@Transpose[{m,v}]

RowReduce[Flatten/@Transpose[{m,v}]]

Last/@%

GaussianElimination[m,v]