# RowReduce: Solving for the resource vector (a, b, c) in Augmented Matrix

Here are two examples:

RowReduce[{{3, 1, a}, {2, 1, b}}]


evaluates to

{{1, 0, a - b}, {0, 1, -2 a + 3 b}}


but

RowReduce[{{1, 2, 3, a}, {4, 5, 6, b}, {7, 8, 9, c}}]


evaluates to

{{1, 0, -1, 0}, {0, 1, 2, 0}, {0, 0, 0, 1}}


The result is independent of a, b and c.

Since I want to know the steps of reduction, I add a, b and c for bookkeeping. But it does not work in the second example. Is anything wrong or is any way to keep track of the steps of reduction?

• Here's a hint: Solve[{x + 2 y + 3 z == a, 4 x + 5 y + 6 z == b, 7 x + 8 y + 9 z == c}, {x, y, z}] results in {}. Dec 13, 2012 at 18:30

I'm not sure if your ultimate goal is a record of all of the row operations required to put a matrix in reduced row echelon form or if you want to figure out for what right-hand sides $\mathbf{b}=(a,b,c)$ does $A\mathbf{x}=\mathbf{b}$ have a solution.

For the latter,

RowReduce[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}]


which results in

{{1, 0, -1}, {0, 1, 2}, {0, 0, 0}}


Thus, $z$ is a free variable, $y=-2z$, and $x=z$. So only right-hand sides of the form $\mathbf{b}=\begin{bmatrix}1\\-2\\1\end{bmatrix}d$ where $d$ is any constant will work.

For the former, that is a different conversation altogether. The LU decomposition of $A$ deals with this.

• Thanks JohnD I think I try to solve something like x+2y+3z==Integers 4x+5y+6z==Integers 7x+8y+9z==Integers I do the Gaussian elimination without normalizing the leading coefficient in each row to 1 and get {{1,2,3},{0,-3,-6},{0,0,0}} So I will have x+2y+3z==Integers 3(y+2z)==Integers But RowReduce[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}] will result in {{1, 0, -1}, {0, 1, 2}, {0, 0, 0}} That is why I include {a,b,c} to keep track to the multiplicative constants. Do you know how to do rowreduce without normalizing each equation or ways to solve equations up to integers by mathematica? Dec 13, 2012 at 19:53
• So you want to solve equations where the right-hand side is constrained to integer values or when the unknowns (here, $x,y,z$) are constrained to integer values? Dec 13, 2012 at 20:27
• The right-hand side is integer valued. No constraints on variables. Dec 13, 2012 at 20:30
• Well, from the answer above, $A\mathbf{x}=\mathbf{b}$ is only solvable for right-hand sides of the form $\mathbf{b}=(1,-2,1)d$, $d\in\mathbb{R}$. So if you only want integer right-hand sides, take $d\in\mathbb{Z}$. Dec 13, 2012 at 20:49
• If you want to work over the integers use HermiteDecomposition instead of RowReduce. Your example: {uu, hh} = HermiteDecomposition[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}] {{{1, 0, 0}, {4, -1, 0}, {1, -2, 1}}, {{1, 2, 3}, {0, 3, 6}, {0, 0, 0}}} The first part of the result gives the transformation matrix. Dec 13, 2012 at 20:55

I know this question is very old, but I stumbled across it while working on a similar problem and thought this might be of some use to someone in the future.

I think the OP intended the given matrix

{{1, 2, 3, a}, {4, 5, 6, b}, {7, 8, 9, c}}

to be taken as an augmented matrix with reduced row echelon form

{{1, 0, -1, 1/3 (-5 a + 2 b)}, {0, 1, 2, 1/3 (4 a - b)}, {0, 0, 0, a - 2 b + c}}

But

RowReduce[{{1, 2, 3, a}, {4, 5, 6, b}, {7, 8, 9, c}}]

knows nothing of the augmentation and continues the reduction by taking a - 2 b + c as the next pivot and gives

{{1, 0, -1, 0}, {0, 1, 2, 0}, {0, 0, 0, 1}}

## A Workaround (Add a "Dummy" Column Vector)

A workaround that I came up with is to just add a "dummy" column vector Transpose[{{0, 0, 1}}] to the augmented matrix in the next-to-last column to absorb the pivot. Then

R = RowReduce[{{1, 2, 3, 0, a}, {4, 5, 6, 0, b}, {7, 8, 9, 1, c}}]


gives

{{1, 0, -1, 0, 1/3 (-5 a + 2 b)}, {0, 1, 2, 0, 1/3 (4 a - b)}, {0, 0, 0, 1, a - 2 b + c}}


You can then either simply ignore the dummy column in the result or, if desired, do

Drop[R, None, {-2}]


which gives

{{1, 0, -1, 1/3 (-5 a + 2 b)}, {0, 1, 2, 1/3 (4 a - b)}, {0, 0, 0, a - 2 b + c}}