Most matrix properties can be extended to empty matrices. You have to check the definitions carefully with vacuous truth in mind to see what they should be, though.
On Tue, Mar 8, 2016 at 9:16 AM, Aravind Reddy <[email protected]> wrote: > Sir, > > I found from issue 10701 that using is_nilpotent() function for checking > whether a matrix is nil potent or not is giving error for empty matrices. So > what I have found and thought are commented there in the issue itself. So as > suggested by argriffing(git hub name, I don't know his original name :P ), I > would like to discuss with sympy devs about this issue. During this work I > also have found that the same error being given when tried to use > eigenvals() and eigenvects() for finding eigen values and eigen vectors > respectively for an empty matrix. I have some ideas here for which I need > some guidance from the devs. > > 1) To return an empty dict as result for eigenvals() when it is applied on > an empty matrix. This sounds right. From Wikipedia: "If v is a vector that is not zero, then it is an eigenvector of a square matrix A if Av is a scalar multiple of v". The definition doesn't state it, but A should be n x n and v should be n x 1. If n = 0, then v is 0 x 1. A vector v is zero if every element of v is 0. If v is 0 x 1, then this is vacuously true because it has no elements. Hence, there are no nonzero vectors v of shape 0 x 1, so the empty matrix has no eigenvectors (and hence no eigenvalues). > 2) For eigenvects(), to return an empty list for an empty matrix. > 3) And for is_nilpotent(), to return False for which I have mentioned some > reasons there on the link provided. This is trickier. I believe it should be True, since the empty matrix is itself zero, by the above argument, and SymPy itself shows this In [4]: Matrix(0, 0, []).is_zero Out[4]: True The definition of nilpotent is that A is nilpotent if there is some positive integer n such that A^n = 0. If n = 1 and A is empty, then A^n = A = 0. I think the arguments against this are false generalizations of nonempty matrix properties. You have to be very careful and look at the definitions, and use those to determine properties of empty matrices. For instance, to quote Wikipedia, "No nilpotent element can be a unit (except in the trivial ring {0}, which has only a single element 0 = 1)." Note that the ring of empty square matrices is the trivial ring. Weird things happen in the trivial ring because of this odd property (0 = 1). For instance, on the issue you argue that the empty matrix [] cannot be zero because det([]) = 1 (see https://github.com/sympy/sympy/issues/10383#issuecomment-171347976 for an argument of why this is in fact the case) and the determinant of zero matrices should be 0. But think how you might prove that the determinant of a zero matrix is 0. You might think of the determinant formula, but that only goes to 0 because there are actual entries in the matrix that are 0--the empty matrix has no entries. Another trick is to use det(0) = det(0*X) = det(0)*det(X), so det(0)*(det(X) - 1) = 0. This holds for any X, so det(0) must be 0. But this trick only works if det(X) can be different from 1. In the case of 0x0 matrices, det(X) is always 1, so the formula still works. Any method you might use to prove that det(0) = 0 uses the fact that the zero matrix is nonempty. Similarly, the "fact" that nilpotent matrices have a single eigenvalue of 0 requires the possibility of eigenvectors (i.e., nonzero vectors), which, as I argued above, don't exist in the empty case. Aaron Meurer > > For all these ideas I have mentioned, to implement them, we have to check > that the given matrix is an empty matrix to do some extra work for that. And > to do that easily, I think we need a routine which takes a matrix as input, > returns True if it is empty, returns False if it isn't. is_empty sounds useful, although it would be simple @property def is_empty(self): return 0 in self.shape > > So please anyone look into this and please provide your valuable inputs to > correct me or even make the statement more clear and standard. > > Thank you, > Aravind > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/a19aec4a-f030-461a-ba51-4dd5ca48268d%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6KEeXhF8s6U-Jk6x8u9vVT0F%2BFgFRzM%2B%2BBjhyqPhiag2Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
