Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Inverse of a Matrix
Date: Tue, 2 Oct 2007 19:54:47 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 98
Message-ID: <fdu7m7$ijo$1@fred.mathworks.com>
References: <fdsglc$6b7$1@fred.mathworks.com> <fdt3n2$kej$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-06-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1191354887 19064 172.30.248.36 (2 Oct 2007 19:54:47 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 2 Oct 2007 19:54:47 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1132064
Xref: news.mathworks.com comp.soft-sys.matlab:431077



John and others,

Thanks for your replies. I am not in a position to avoid
using matrix inversion. pinv really seems to give some
erratic answers for some of the test cases I have. I would
like to if there is a method to calculate the inverse using
Cholesky decomposition and if so, whether it would be better
than the inv operation in MATLAB?



"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fdt3n2$kej$1@fred.mathworks.com>...
> "Ravi " <vioravis.nospam@gmail.com> wrote in message
<fdsglc$6b7
> $1@fred.mathworks.com>...
> > Are there any methods available for finding approximate
> > inverse for nearly singular matrices using MATLAB? Is there
> > a way to avoid this?
> 
> As Duane points out, why do you want the inverse at all?
> 
> If you are using it to solve a system of equations, then
> its a very poor choice.
> 
> A pseudo-inverse, as provided by pinv will be a good
> choice however. It uses the svd to survive the singularity,
> and your result will be as stable as is numerically possible.
> For example:
> 
> A = ones(2);
> A(1,1) = 1+eps;
> 
> 
> inv(A)
> Warning: Matrix is close to singular or badly scaled.
>          Results may be inaccurate. RCOND = 5.551115e-17.
> ans =
>    4.5036e+15  -4.5036e+15
>   -4.5036e+15   4.5036e+15
> 
> 
> pinv(A)
> ans =
>          0.25         0.25
>          0.25         0.25
> 
> 
> A*pinv(A)
> ans =
>           0.5          0.5
>           0.5          0.5
> 
> 
> A*inv(A)
> Warning: Matrix is close to singular or badly scaled.
>          Results may be inaccurate. RCOND = 5.551115e-17.
> ans =
>      1     0
>      0     1
> 
> 
> However, perturb A only by a tiny bit and see how
> much the inverse changes. 
> 
> B = A;
> B(2,2) = 1-eps;
> 
> inv(B)
> Warning: Matrix is singular to working precision.
> ans =
>    Inf   Inf
>    Inf   Inf
> 
> 
> Or instead, try this:
> 
> 
> B*inv(A)
> Warning: Matrix is close to singular or badly scaled.
>          Results may be inaccurate. RCOND = 5.551115e-17.
> ans =
>             1            0
>             1            0
>  
> 
> Whereas pinv(B) is still the same stable result.
> 
> 
> pinv(B)
> ans =
>          0.25         0.25
>          0.25         0.25
> 
> HTH,
> John
>