       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'

Here is an example which shows this:

In:=
A = {{1, I, 0}, {0, 1, -I}};

In:=
b = Transpose[A].MatrixPower[A.Transpose[A], -1]
Out=
{{0, -I}, {-I, 1}, {-1, 0}}

In:=
c = PseudoInverse[A]
Out=
2    I       I   1      1   2 I
{{-, -(-)}, {-(-), -}, {-(-), ---}}
3    3       3   3      3    3

In:=
A.b
Out=
{{1, 0}, {0, 1}}

In:=
A.c
Out=
{{1, 0}, {0, 1}}

On the other hand if A is a real matrix both methods give the same answer,
e.g.

In:=
Clear[A];A = {{1, 2, 3}, {4, 5, 6}}
Out=
{{1, 2, 3}, {4, 5, 6}}

In:=
Transpose[A].MatrixPower[A.Transpose[A], -1]
Out=
17   4      1   1    13    2
{{-(--), -}, {-(-), -}, {--, -(-)}}
18   9      9   9    18    9

In:=
PseudoInverse[A]
Out=
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:=
d = {{-(11/3), 5/3}, {16/3, -(7/3)}, {-2, 1}};

In:=
A.d
Out=
{{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. 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 takes too long for my patience. So
> here I will just show what happens in the case of a 2x3 matrix:
> In:=
> A = {{a, b, c}, {d, e, f}};
> In:=
> B = Transpose[A].MatrixPower[A.Transpose[A], -1] // Simplify
> Out=
>                                               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:=
> A.B // Simplify
> Out=
> {{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.
>>