Ask Your Question
2

Row echelon form of a matrix containing symbolic expresssions

asked 2011-10-16 17:23:18 +0100

trk gravatar image

updated 2011-10-16 17:24:54 +0100

Hi,

I want to find out the row echelon form of this matrix:

$ \left(\begin{array}{rrrr} 1 & 1 & 2 & b_{1} \\ 1 & 0 & 1 & b_{2} \\ 2 & 1 & 3 & b_{3} \end{array}\right) $

By manually performing elementary row operations on paper, I get this answer:

$ \left(\begin{array}{rrrr} 1 & 1 & 2 & b_{1} \\ 0 & 1 & 1 & b_{1} - b_{2} \\ 0 & 0 & 0 & -b_{1} - b_{2} + b_{3} \end{array}\right) $

I thought I can do the following in sage:

var('b_1,b_2,b_3')
A=matrix(SR,[[1,1,2,b_1],[1,0,1,b_2],[2,1,3,b_3]])
show(A)
A.echelon_form()

But I get:

$ \left(\begin{array}{rrrr} 1 & 0 & 1 & 0 \\ 0 & 1 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right) $

What is the correct function and/or parameters I should use to get the expected answer?

Thank you.

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
5

answered 2011-10-17 16:59:19 +0100

Jason Grout gravatar image

This is typical---it is assumed that you can divide and things aren't zero. This happens in other math software systems too. The Maple chapter of the Handbook of Linear Algebra discusses this (p. 72-10) and refers to these two references:

  • R.M. Corless and D.J. Jeffrey. Well... it isn’t quite that simple. SIGSAM Bull., 26(3):2–6, 1992.
  • R.M. Corless and D.J. Jeffrey. The Turing factorization of a rectangular matrix. SIGSAM Bull., 31(3):20–28, 1997.

That HLA chapter suggests using LU decomposition to do this, but apparently LU decomposition doesn't work too well for our symbolic matrix.

HOWEVER: You can do this in Sage if you use a different base ring for the matrices:

sage: R.<b1,b2,b3>=QQ[]
sage: A=matrix([[1,1,2,b1],[1,0,1,b2],[2,1,3,b3]])
sage: A.echelon_form()
[            1             0             1            b2]
[            0             1             1       b1 - b2]
[            0             0             0 -b1 - b2 + b3]

Note that rref still gives the answer you got before since rref works over the fraction field:

sage: A.rref()
[1 0 1 0]
[0 1 1 0]
[0 0 0 1]
sage: parent(A)
Full MatrixSpace of 3 by 4 dense matrices over Multivariate Polynomial Ring in b1, b2, b3 over Rational Field
sage: parent(A.echelon_form())
Full MatrixSpace of 3 by 4 dense matrices over Multivariate Polynomial Ring in b1, b2, b3 over Rational Field
sage: parent(A.rref())
Full MatrixSpace of 3 by 4 dense matrices over Fraction Field of Multivariate Polynomial Ring in b1, b2, b3 over Rational Field
edit flag offensive delete link more
2

answered 2011-11-10 12:36:58 +0100

malb gravatar image
sage: P.<b1,b2,b3> = QQ[]
sage: A = Matrix(P, 3, 4, [[1,1,2,b1], [1,0,1,b2], [2,1,3,b3]])
sage: A
[ 1  1  2 b1]
[ 1  0  1 b2]
[ 2  1  3 b3]
sage: A.echelon_form('row_reduction')
[            1             0             1            b2]
[            0             1             1       b1 - b2]
[            0             0             0 -b1 - b2 + b3]
edit flag offensive delete link more
2

answered 2011-10-17 12:47:10 +0100

Xaver gravatar image

I think your 'expected answer' is not the expected answer.

The definition of the echelon form of a matrix requires (amongst others) that the first non-zero element on each row be a 1. So, from your results the next step is to multiply the last row by 1/(-b1-b2+b3) which leads to

[[1,1,2,   b1]
 [0,1,1,b1-b2]
 [0,0,0,   1]]

and then, you can subtract the last row times (b1-b2) and times b1 from the 2nd and the 1st row, leading to

[[1,1,2,0]
 [0,1,1,0]
 [0,0,0,1]]

finally you can subtract the 2nd from the 1st row leading to

   [[1,0,1,0]
    [0,1,1,0]
    [0,0,0,1]]

So, everything is ok.

B.t.w.: the reason why you can completely wipe out your 'variables' b1...b3 is because the cols/rows of the rest of the matrix are linearly dependent. You will experience the same thing for any other case where this holds because one of the rows of your matrix will contain only zeros up to the row which contains the variables.

edit flag offensive delete link more
1

answered 2011-10-17 18:12:24 +0100

Xaver gravatar image

@Jason Grout: 1) "..it is assumed that you can divide and things aren't zero...". Yes. Exactly that is what happens.

2) "..This happens in other math software systems too..". Yes again, eg. also in Mathematica:

In[4]:= RowReduce[{{1, 1, 2, b1}, {1, 0, 1, b2}, {2, 1, 3, b3}}]
Out[4]= {{1, 0, 1, 0}, {0, 1, 1, 0}, {0, 0, 0, 1}}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2011-10-16 17:23:18 +0100

Seen: 10,031 times

Last updated: Nov 10 '11