Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 15 Jul 2007 14:15:00 -0500
Date: Sun, 15 Jul 2007 15:14:59 -0400
From: "Robert E. Beaudoin" <rbeaudoin@comcast.net>
Reply-To:  rbeaudoin@acm.org
User-Agent: Thunderbird 2.0.0.4 (X11/20070616)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab,comp.dsp
Subject: Re: Is a QR Decomposition Better than B \ A?
References: <m3zm21orrv.fsf@ieee.org>
In-Reply-To: <m3zm21orrv.fsf@ieee.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <beKdnfxrAJqp7wfbnZ2dnUVZ_oa3nZ2d@comcast.com>
Lines: 47
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 65.96.175.215
X-Trace: sv3-aPIm0ZJOIJqvIIwPzX/mnfgE/GaX8p8TcR0RUDskuD6gkpsYa+w/6GMi3/HaDKxY1JtEIu52fnyjp4p!J4hZWbUiCNZvZr4dJXldil2SyPRjH2TapFoOZ4XaRS56ZdXb5wFNg7b3zePc9D/J9RrwUI4O02Rs!1mi2CM7EBnqBpq9CprkKhNrqLSvFcQ==
X-Complaints-To: abuse@comcast.net
X-DMCA-Complaints-To: dmca@comcast.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.35
Bytes: 2886
Xref: news.mathworks.com comp.soft-sys.matlab:419233 comp.dsp:225434



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.

Robert E. Beaudoin