Re: Trouble with inverting matrices

*To*: mathgroup at smc.vnet.net*Subject*: [mg33758] Re: Trouble with inverting matrices*From*: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>*Date*: Thu, 11 Apr 2002 02:14:15 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hi, can you post the complete code ? Because otherwise we can only use our phantasie to find the bug you have made. Regards Jens Wyvern wrote: > > Hi, > When I try to invert a matrix (as it happens, a matrix with the elements > described in #7 of Nick Trefethen's 10 challenges but of a much smaller > size) and store that inverse to a variable, I get this error: (for a 2x2 > case) > Inverse::"sing": "Matrix \!\({\(\({0, 0}\)\), \(\({0, 0}\)\)}\) is > singular." > > [and then the output of the for loop in which the operation is embedded, and > then another error:] > > Set::"write": "Tag Times in \!\(inv \\\\ Null \\\\ Null \\\\ Null > \\\\ \ > Null \\\\ Null \\\\ Null\) is Protected." > > inv is the variable to which I am trying to store the inverse. > > The bizarre part is that if I try to print the the inverses as they are > generated (my For loop increases the size of the mxm matrix by one each time > and sets the elements of the matrix and then calculates the inverse) then it > works fine, as in Print[MatrixForm[Inverse[theMatrix]]]. If I set > inv = Inverse[theMatrix] it gives the errors above. > Also, the matrix given in the error for Inverse is NOT the matrix that has > been passed to Inverse! In the 2x2 case, the matrix is {2,1}{1,3} which is > invertible. So where is Inverse coming up with this {0,0}{0,0} matrix which > it (correctly) claims is not invertible? Any help would be much appreciated. > > Marshall Pierce