Re: Rank of a matrix depending on a
- To: mathgroup at smc.vnet.net
- Subject: [mg122041] Re: Rank of a matrix depending on a
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Mon, 10 Oct 2011 04:28:04 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <26711112.27416.1318065689598.JavaMail.root@m06>
- Reply-to: drmajorbob at yahoo.com
Brilliant! As usual, David's package allows us to "eschew obfuscation". Bobby On Sun, 09 Oct 2011 02:51:29 -0500, David Park <djmpark at comcast.net> wrote: > The problem here is that RowReduce is at once more general and less > general > than needed. It is more general in incorporating sophisticated numerical > techniques, but less general in the ability to confine its operation to a > submatrix of a larger matrix but carry the row operations over to all > columns. > > Nevertheless, there is a simple way to do this in regular Mathematica. > > (A = {{1, 0}, {2, 0}}) // MatrixForm > (B = {{a}, {2}}) // MatrixForm > > Calculate the null space of the transpose of A and then apply this to B. > To > be consistent all of the resupting elements must be set to zero so this > gives a set of equations in the parameters. > > NullSpace[Transpose@A] > %.B > {{-2, 1}} > {{2 - 2 a}} > > giving the equation 2 - 2 a == 0. > > A second method is to use GroebnerBasis. Let the variable symbols be x1 > and > x2. We then write the equations as polynomials that are equal to zero and > find a Groebner basis on x1 (x2 doesn't enter). > > GroebnerBasis[{x1 - a, 2 x1 - 2}, {x1}] > {-1 + a, -1 + x1} > > giving a == 1 and x == 1 for the solution. > > This is fine and good if one understands NullSpace and the fact that one > has > to use the Transpose of the A matrix, or if one is into Groebner bases. > > Another approach can be used with the Students Linear Equations section > of > the Presentations application. This allows us to set up a matrix > structure > representing linear equation, with named rows and columns and dividers. > The > matrix structure can be displayed in a separate window (or in the > notebook) > and manipulated step by step. The following does your example. There are > routines to compose a matrix structure, operate on it and extract various > parts. > > Unfortunately I can't easily copy the matrix structure display form into > the > email. A PDF and Mathematica notebook showing the complete solutions > will be > posted at the archive site Pete Lindsay at the St. Andrews Mathematics > department keeps for me, perhaps with a day or so delay. > > http://home.comcast.net/~djmpark/DrawGraphicsPage.html > > Here is the code for one method using a null space. > > 1) Define case1 as a matrix structure with 2 rows and 3 columns. > 2) Insert column names, which can actually be variable symbols or > constants. > 3) Add a divider after the second row. > 4) Insert matrix A starting at row 1, column1. > 5) Insert matrix B starting at row 1, column 3. > 6) Display the structure. > > << Presentations` > > case1 = LECreate[2, 3]; > LEInsertColumnNames[case1, 1, {x1, x2, 1}] > LEColumnDividers[case1, {2}] > LEInsertMatrix[case1, {1, 1}, A] > LEInsertMatrix[case1, {1, 3}, B] > LEPrint[case1] > > (This displays a matrix with row and column names and dividers.) > > The following prints the equations: Notice that the expressions are > obtained > by dotting the row of column names with the row of elements. > > LERowExpression[case1, #, 1 ;; 2] == > LERowExpression[case1, #, 3 ;; 3] & /@ Range[2] // > Column[#, Alignment -> "=="] & > > X1 == a > 2 x2 == 2 > > The following reduces the lhs matrix and carries the row operations over > to > the rhs without attempting to carry the reduction into the rhs. We then > scale the last row to remove a common factor of 2. (The matrix itself is > the > first part of case1.) > > LEMakeEchelonForm[case1, {1, 1}, {2, 2}] > LERowDividers[case1, {1}] > LEScaleRow[case1, 1/2, 2]; case1 = MapAt[Expand, case1, 1]; > LEPrint[case1] > > (Again a display of the reduced matrix structure.) > > The all zero rows on the lhs generate the null space. For a solution to > exist the corresponding rhs entries must be zero, which supplies the > condition on the parameter(s). Writing the equations again, we obtain: > > LERowExpression[case1, #, 1 ;; 2] == > LERowExpression[case1, #, 3 ;; 3] & /@ Range[2] > Solve[%][[1]] > > {x1 == a, 0 == 1 - a} > {a -> 1, x1 -> 1} > > Student's Linear Equations has routines for composing matrix structures, > routines for row operations on the structure, routines for extracting > sub-matrices, row or column expressions in equation form, and routines > for > displaying the matrix structure in the notebook, or in a separate window > where it is dynamically updated. Row, column or element positions can be > pasted into the notebook from the displays. By using row and column names > the matrices are displayed in a context. There are also routines for > displaying rows as reaction equations for use in chemical stoichiometry > and > operations for basic linear programming. It also has provision for > covariant > (the usual) and contravariant columns. The capability is useful for > didactic > purposes and for solving small to medium size problems where one wishes > to > see the steps. > > > David Park > djmpark at comcast.net > http://home.comcast.net/~djmpark/ > > > > > > > From: Mikel [mailto:ketakopter at gmail.com] > > > Hi, > > A bit of background for my problem: I'm trying to solve a linear system > of > equations in matrix form, A.x==B. I have the A matrix, which is square > and singular. I also have the B vector, which depends on some parameters > (or > variables, I'm not sure how to call it). I'm looking for the value of the > parameters, so there exists solution to the system. In other words, I > want > the rank of the augmented matrix AB to be equal to the rank of A. > > I thought about using the MatrixRank function, but it does not support > parameters, it seems. Then I tried RowReduce, but even though in the > first > example of the help page the result is given with parameters, I only get > numbers. > > Here's an example to try: > > ============ > > Clear[a] > A = {{1, 0}, {2, 0}}; > B = {{a}, {2}}; > AB = ArrayFlatten[{{A, B}}]; > MatrixRank[A] > MatrixRank[AB] > RowReduce[AB] > > a = 1; > MatrixRank[A] > MatrixRank[AB] > RowReduce[AB] > > ============ > > As can be seen, the rank does depend on the value of the "a" parameter, > but > RowReduce just outputs a numeric value. > > So, the questions are: > 1) Why does RowReduce not give a parameter in the result? Is this a bug? > 2) Is there any other way to solve the problem, i.e. to get the rank of > AB > as a function of the "a" variable? > > I'm using Mathematica 7, Student version, for what is worth. > > -- DrMajorBob at yahoo.com