questions about solving a linear equations ( \ vs pinv vs least-square)

6 visualizaciones (últimos 30 días)
Chen ChingChuan
Chen ChingChuan el 12 de Oct. de 2016
Editada: Massimo Zanetti el 12 de Oct. de 2016
I wonder why the answer with using \ is different to solutions with pinv or least-square.
X = [13.5, 6.75, 6.75;6.75,6.75,0;6.75,0,6.75];
y = [0.62;0.31;0.31];
X\y % [-0.0791, 0.125, 0.125]
pinv(X) * y % [0.0306, 0.0153, 0.0153]
pinv(X * X') * X' * y % [0.0306, 0.0153, 0.0153]
I use MatLab R2016a in Windows 7 SP1 64bit.

Respuestas (1)

Massimo Zanetti
Massimo Zanetti el 12 de Oct. de 2016
Editada: Massimo Zanetti el 12 de Oct. de 2016
Your matrix X has full rank, so the difference between the two methods shouldn't be so high. Running it on my pc I indeed obtain:
X = [13.5, 6.75, 6.75;6.75,6.75,0;6.75,0,0]
y = [0.62;0.31;0.31];
format long
a1=X\y
a2=pinv(X)*y
a1 =
0.045925925925926
0
0
a2 =
0.045925925925926
0.000000000000000
-0.000000000000000
They are the same. Differences among the two methods show up when the matrix X has not full rank. Then, if y does not belong to R(X), the range space of X, then pinv method returns the orthogonal projection of y onto R(X). While other methods triggered by \ operator return different approximations, depending on which one is triggered. The collection of methods that \ can trigger (depending on properties of matrix X) is listed here (bottom of the page):
  2 comentarios
Chen ChingChuan
Chen ChingChuan el 12 de Oct. de 2016
Sorry, I have a typo. The last element of X is 6.75 not 0.
Massimo Zanetti
Massimo Zanetti el 12 de Oct. de 2016
Editada: Massimo Zanetti el 12 de Oct. de 2016
Then your matrix
X = [13.5, 6.75, 6.75;6.75,6.75,0;6.75,0,6.75]
is exactly rank(X)=2, so rank is NOT FULL (any row is a linear combination of the other two). Fore instance, row1=row2+row3.
As a consequence the solutions of the two methods are different, because of what I sayd before.

Iniciar sesión para comentar.

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by