Re: Re: Inverting a non-square matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg20266] Re: [mg20239] Re: [mg20201] Inverting a non-square matrix
- From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
- Date: Sun, 10 Oct 1999 01:27:26 -0400
- Sender: owner-wri-mathgroup at wolfram.com
I forgot to add that for non-square matrices a left or right inverse, (when
they exist) are not unique. For example,for a matrix with complex entries my
method below will in general produce a different right inverse from
Mathematica's built-in PseudoInverse function (I did not know of its
existence when I wrote my reply and learned about it only from David Reiss'
message in this thread).
Here is an example which shows this:
In[1]:=
A = {{1, I, 0}, {0, 1, -I}};
In[2]:=
b = Transpose[A].MatrixPower[A.Transpose[A], -1]
Out[2]=
{{0, -I}, {-I, 1}, {-1, 0}}
In[3]:=
c = PseudoInverse[A]
Out[3]=
2 I I 1 1 2 I
{{-, -(-)}, {-(-), -}, {-(-), ---}}
3 3 3 3 3 3
In[3]:=
A.b
Out[3]=
{{1, 0}, {0, 1}}
In[5]:=
A.c
Out[5]=
{{1, 0}, {0, 1}}
On the other hand if A is a real matrix both methods give the same answer,
e.g.
In[6]:=
Clear[A];A = {{1, 2, 3}, {4, 5, 6}}
Out[6]=
{{1, 2, 3}, {4, 5, 6}}
In[7]:=
Transpose[A].MatrixPower[A.Transpose[A], -1]
Out[7]=
17 4 1 1 13 2
{{-(--), -}, {-(-), -}, {--, -(-)}}
18 9 9 9 18 9
In[8]:=
PseudoInverse[A]
Out[8]=
17 4 1 1 13 2
{{-(--), -}, {-(-), -}, {--, -(-)}}
18 9 9 9 18 9
Of course even for real non-square matrices a right (or left) inverse is not
unique, for example here is another one for the above case:
In[11]:=
d = {{-(11/3), 5/3}, {16/3, -(7/3)}, {-2, 1}};
In[12]:=
A.d
Out[12]=
{{1, 0}, {0, 1}}
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp
----------
>From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net
>Subject: [mg20266] [mg20239] Re: [mg20201] Inverting a non-square matrix
>Date: Fri, 8 Oct 1999 18:30:16 -0400
>
> First there is no such thing as the "inverse" of a non-square matrix. Only a
> square matrix can possibly have an inverse. A non-square matrix can have at
> best have a left-inverse or a right inverse. (And in fact it can't have
> both). Your matrix can have only a right inverse, i.e. a matrix 4x3 B such
> that A.B=IdenittyMatrix[3]. Here is a formula which presumably gives what
> you wanted:
>
> B = Transpose[A].MatrixPower[A.Transpose[A], -1]
>
> However a word of warning. Mathematica will compute this for your matrix but
> you will get an awful expression and applying Simplify will take for ages.
> Even verifying that A.B=IdentityMatrix[3] takes too long for my patience. So
> here I will just show what happens in the case of a 2x3 matrix:
> In[1]:=
> A = {{a, b, c}, {d, e, f}};
> In[2]:=
> B = Transpose[A].MatrixPower[A.Transpose[A], -1] // Simplify
> Out[2]=
> 2 2
> -b d e - c d f + a (e + f )
> {{--------------------------------------------------------------------------
> ,
> 2 2 2 2 2 2 2 2 2
> c (d + e ) - 2 a c d f - 2 b e (a d + c f) + b (d + f ) + a (e + f )
>
> 2
> b d - a b e + c (c d - a f)
>
> --------------------------------------------------------------------------},
> 2 2 2 2 2 2 2 2 2
> c (d + e ) - 2 a c d f - 2 b e (a d + c f) + b (d + f ) + a (e + f
> )
>
> 2 2
> -e (a d + c f) + b (d + f )
>
> {--------------------------------------------------------------------------,
> 2 2 2 2 2 2 2 2 2
> c (d + e ) - 2 a c d f - 2 b e (a d + c f) + b (d + f ) + a (e + f
> )
>
> 2
> -a b d + a e + c (c e - b f)
>
> --------------------------------------------------------------------------},
> 2 2 2 2 2 2 2 2 2
> c (d + e ) - 2 a c d f - 2 b e (a d + c f) + b (d + f ) + a (e + f
> )
>
> 2 2
> c (d + e ) - (a d + b e) f
>
> {--------------------------------------------------------------------------,
> 2 2 2 2 2 2 2 2 2
> c (d + e ) - 2 a c d f - 2 b e (a d + c f) + b (d + f ) + a (e + f
> )
>
> 2
> -a c d + a f + b (-c e + b f)
>
> --------------------------------------------------------------------------}}
> 2 2 2 2 2 2 2 2 2
> c (d + e ) - 2 a c d f - 2 b e (a d + c f) + b (d + f ) + a (e + f
> )
> In[3]:=
> A.B // Simplify
> Out[3]=
> {{1, 0}, {0, 1}}
> --
> Andrzej Kozlowski
> Toyama International University
> JAPAN
> http://sigma.tuins.ac.jp
> http://eri2.tuins.ac.jp
>
>
> ----------
>>From: Nicolas Bardou <nicolas.bardou at at.siemens.fr>
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
>>To: mathgroup at smc.vnet.net
>>Subject: [mg20266] [mg20239] [mg20201] Inverting a non-square matrix
>>Date: Thu, Oct 7, 1999, 10:06
>>
>
>> Hi all,
>>
>> I learnt a bit of Mathematica when I was student and I need a formal
>> calculation of the inverse of a non square matrix. But we do not have
>> the software in my department.
>> Can anyone say me if it is possible, and what are the formulas?
>> My matrix is:
>> A =
>> [a b c d]
>> [e f g h]
>> [i j k l]
>> and all the parameters are variable.
>>
>> Thank you by advance!
>>
>>
>