Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!nx02.iad01.newshosting.com!newshosting.com!140.99.99.194.MISMATCH!news-in-02.newsfeed.easynews.com!easynews.com!easynews!sn-xt-sjc-03!sn-xt-sjc-06!sn-post-sjc-01!supernews.com!news.supernews.com!not-for-mail
From: Randy Yates <yates@ieee.org>
Newsgroups: comp.soft-sys.matlab,comp.dsp
Subject: Re: Is a QR Decomposition Better than B \ A?
Date: Mon, 16 Jul 2007 11:38:11 -0400
Organization: The Universal Church of Christ
Message-ID: <m34pk42wbg.fsf@ieee.org>
References: <m3zm21orrv.fsf@ieee.org> <beKdnfxrAJqp7wfbnZ2dnUVZ_oa3nZ2d@comcast.com>
User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.20 (linux)
Cancel-Lock: sha1:JC1gzf0s/4H8nRV/0VXwNuCSoiI=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@supernews.com
Lines: 52
Xref: news.mathworks.com comp.soft-sys.matlab:419347 comp.dsp:225470



"Robert E. Beaudoin" <rbeaudoin@comcast.net> writes:

> Randy Yates wrote:
>> If we have a system of equations Ax=b, then we can solve it using
>>   x = A \ b or   x = pinv(A'*A)*A'*b
>> or
>>   [Q,R] = qr(A);
>>   x = inv(R)*Q'*b;
>> Which is best? Also, I thought a QR decomposition always produced a
>> nonsingular R
>> matrix [meyer, p.313], but Matlab is returning a non-square
>> matrix. Why?
>> --Randy
>> @BOOK{meyer,
>>   title = "{Matrix Analysis and Applied Linear Algebra}",
>>   author = "{Carl~D.~Meyer}",
>>   publisher = "Society for Industrial and Applied Mathematics",
>>   year = "2000"}
>>
>
> Which alternative is "best" will likely depend on your application.
> The matlab function reference pages for mldivide, pinv, and qr will
> give you excruciating detail about the differences (and similarities)
> between the three.  In a nutshell, backslash-division will try to
> intelligently select a solution algorithm based on e.g. whether A is
> square or not, and sparse or not (and for non-square matrices it uses
> the QR decomposition) and will produce a solution with the minimum
> number of non-zero entries.  Using pinv (in the form  x = pinv(A) * b;
> the equation you give works too but why bother with the extra
> operations?) will give a solution with minimum norm.  Unless you know
> you want this I'd suggest using \ and letting Matlab do the thinking
> about which algorithm to use.
>
> As to your second question, it is the Q matrix which is guaranteed to
> be non-singular (even better, orthogonal).  R must always have the
> same size as A, and be singular if and only if A is.

Hello Robert,

Thank you for your help. I took another look at the matlab help page
for qr and I don't see any discussion of the differences or similarities.
the mldivide page does have some information. Perhaps I'm using an older
version than you (6.1.0.450 (R12.1))?

What I'm trying to ask is, which method gives me the minimum
squared error (minimum norm of residual)?
-- 
%  Randy Yates                  % "Remember the good old 1980's, when 
%% Fuquay-Varina, NC            %  things were so uncomplicated?"
%%% 919-577-9882                % 'Ticket To The Moon' 
%%%% <yates@ieee.org>           % *Time*, Electric Light Orchestra
http://home.earthlink.net/~yatescr