[SciPy-user] solving linear equations ?

Hoyt Koepke hoytak@cs.ubc...
Wed Nov 5 15:18:59 CST 2008


I'm also interested, so I hope it's okay to jump in here.

Correct me if I'm wrong, but I thought that MATLAB's  \ operator uses
Gaussian elimination to solve the system as does solve().   You get
the least squares approach in MATLAB by invoking the pinv() function;
i.e. to solve Ax = b, you could use either:

1.  x = A \ b, which gives you a solution unless there isn't any, even
if it's not unique (in the case of an undetermined system).

2.  x = pinv(A)*b, if you want the least squares approach.   This
performs least squares via an SVD decomposition and could thus give
you a better solution than the first in the
overconstrained/underconstrained case.   The Gaussian elimination
approach is an order of magnitude faster, and works in most
situations, so that's what the shorthand does.

I always assumed linalg.solve paralleled the first and linalg.lstsqr
did the second, but I may be wrong.  Also, I'm not clear on what
happens with either solve or matlab's \ if it's not a square matrix.
Could someone clarify?

Thanks!
--Hoyt


+++++++++++++++++++++++++++++++++++
Hoyt Koepke
University of Washington, Department of Statistics
http://www.stat.washington.edu/~hoytak
hoytak@gmail.com
+++++++++++++++++++++++++++++++++++


More information about the SciPy-user mailing list