Re: Re: PseudoInverse for exact matrices: Comments...
- To: mathgroup at smc.vnet.net
- Subject: [mg25217] Re: [mg25187] Re: PseudoInverse for exact matrices: Comments...
- From: "Mark Harder" <harderm at ucs.orst.edu>
- Date: Fri, 15 Sep 2000 02:21:51 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Mark, Gianluca, & everybody, (1.) I once tried to perform a pseudoinverse of a (more or less) 15-element matrix (elements were nonlinear functions of exponential functions of symbolic variables) with Mathematica (vsn4.0.1) on my Pent.II,266MHz, WinNT4 machine, and after 12hrs it was still crunching away, no crashes, no error msgs., but no signs of progress either. (I didn't bother to tell the system that the symbols were real. See (2.) below regarding this.) However, I decided that it was just too slow to be practical, and never tried to do symbolic pseudoinverses again until today. If anyone out there knows that Mathematica *should* have handled this problem faster than this, I'd like to know, so I can debug what I was doing; until then, I'm assuming the procedure is just too slow to be practical. Then again, maybe I should try implementing some variant of mark Mark Fisher's pseudoinverse, altered for symbolic matrices (?). (2.) Speaking of which, I succeeded in repeating Mark's results on my system: IN: mn = {{1 + I, 1}}; psmn = PseudoInverse[mn] OUT: {{1/3 - I/3}, {1/3}} IN: Simplify[psmn.mn] OUT: {{2/3, 1/3 - I/3}, {1/3 + I/3, 1/3}} IN: Simplify[Transpose[psmn.mn ] ] OUT: {{2/3, 1/3 + I/3}, {1/3 - I/3, 1/3}} As Mark pointed out there is a serious discrepancy here, since psmn.mn and its Transpose should be the same IF the matrix being transposed is real. The problem is that Mathematica's Transpose doesn't automatically conjugate elements when it transposes them (for good reasons, I think); so it gives the wrong answer in case of complex exact expressions and also with symbolic expressions not declared to be Real. (NB. the anti-symmetric relationships in the signs of the imaginary parts of the off diagonal elements of psmn.mn and its "Transpose".) What we need here is a ConjugateTranspose function for complex matrices, and Mathematica doesn't give us one; even the examples I found in the LinearAlgebra`MatrixManipulation documentation constructs one, so lets make our own ConjugateTranspose function: IN: ConjugateTranspose[x_List?MatrixQ] := Transpose[Conjugate[x] ]; and now IN: Simplify[ConjugateTranspose[psmn.mn] ] OUT: {{2/3, 1/3 - I/3}, {1/3 + I/3, 1/3}} ,which == psmn.mn . SO, the problem lies with using the built-in Transpose function. When ConjugateTransposition is used instead, PseudoInverse proves to be O.K. BTW, similar results are obtained when m={{1+x,1}}, and x is not declared real. Try this for yourself. A suggestion for future Mathematica vsns.: add an option to Transpose which enables Conjugate transposition!! -Mark Harder harderm at ucs.orst.edu -----Original Message----- From: Mark Fisher <mark.fisher at atl.frb.org> To: mathgroup at smc.vnet.net Subject: [mg25217] [mg25187] Re: PseudoInverse for exact matrices >I don't know much about pseudoinverses, but I do know that >myPseudoInverse gives a result different from what Mathematica's PseudoInverse >gives. > >(* copied from original email *) >myPseudoInverse[m_List?MatrixQ /; Precision[m] === Infinity] := > Module[{n = NullSpace[m]}, > n = If[n === {}, {Table[0, {Length[First[m]]}]}, n]; > Inverse[Transpose[m].m + Transpose[n].n].Transpose[m]]; > > >In[69]:= >p = PseudoInverse[m = {{1 + I, 1}}] > >Out[69]= >{{1/3 - I/3}, {1/3}} > >In[70]:= >pp = myPseudoInverse[m] > >Out[70]= >{{3/5 - I/5}, {1/5 - (2*I)/5}} > >In "Further Examples" from the help listing for PseudoInverse, it says >that the pseudoinverse satisfies four conditions: > >In[72]:= >{m.p.m == m, p.m.p == p, p.m == Transpose[p.m], m.p == Transpose[m.p]} > >Out[72]= >{True, True, False, True} > >In[73]:= >{m.pp.m == m, pp.m.pp == pp, pp.m == Transpose[pp.m], m.pp == >Transpose[m.pp]} > >Out[73]= >{True, True, True, True} > >Well it appears as though Mathematica's built in PseudoInverse has failed the >tests, whereas myPseudoInverse has passed. Is this a bug or have I done >something wrong? > >-- Mark >Mark Fisher >Economic Advisor >Research Department >Federal Reserve Bank of Atlanta >Atlanta, GA 30303 >404-521-8757 (voice) >404-521-8810 (fax) >mark.fisher at atl.frb.org > >personal web page: www.markfisher.net > >