Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
2

Row echelon form of a matrix containing symbolic expresssions

asked 13 years ago

trk gravatar image

updated 13 years ago

Hi,

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

(112b1101b2213b3)

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

(112b1011b1b2000b1b2+b3)

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:

(101001100001)

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

Thank you.

Preview: (hide)

4 Answers

Sort by » oldest newest most voted
5

answered 13 years ago

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
Preview: (hide)
link
2

answered 13 years ago

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]
Preview: (hide)
link
2

answered 13 years ago

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.

Preview: (hide)
link
1

answered 13 years ago

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}}
Preview: (hide)
link

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: 13 years ago

Seen: 10,898 times

Last updated: Nov 10 '11