Re: Decompose a matrix [message #57688] |
Wed, 19 December 2007 06:08 |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Dec 19, 12:15 pm, d.po...@gmail.com wrote:
> Folks
> I have a problem could anyone help me?
> Let:
> A = [[ 0,0,1], $
> [ 0,1,0], $
> [ 0,0,0]]
> B = [0.5,0.5,1]
>
> ; Decompose A
> SVDC, A, W, U, V
> ; Solve A.X=B
> X=SVSOL(U, W, V, B)
> new_B=A##X
> IDL> print,new_B
> 0.500000
> 0.500000
> 0.000000
> Why new_B is not equal to B' ?
> Thanks for any help in advance
> Cheers
> Dave
A simple workaround (read: cheat) is to make sure your Eigenvalues are
_close_ to zero rather than equal to zero. I guess it depends on how
accurate you need your results to be :-)
A*=1.0
A[0,2]+=0.01
SVDC, A, W, U, V
X=SVSOL(U, W, V, B)
PRINT,TRANSPOSE(A##X)
IDL> 0.500000 0.500000 1.00000
You'd probably want to do the whole thing in double precision so you
could use a smaller zero-offset.
Take care,
Chris
|
|
|
Re: Decompose a matrix [message #57689 is a reply to message #57688] |
Wed, 19 December 2007 05:16  |
jameskuyper
Messages: 79 Registered: October 2007
|
Member |
|
|
d.poreh@gmail.com wrote:
> Folks
> I have a problem could anyone help me?
> Let:
> A = [[ 0,0,1], $
> [ 0,1,0], $
> [ 0,0,0]]
> B = [0.5,0.5,1]
>
> ; Decompose A
> SVDC, A, W, U, V
> ; Solve A.X=B
> X=SVSOL(U, W, V, B)
> new_B=A##X
> IDL> print,new_B
> 0.500000
> 0.500000
> 0.000000
> Why new_B is not equal to B' ?
Because there is no value of X such that A.X=B. That's because one of
the eigenvalues of A is 0. What this means is that while the possible
values for X fill a three-dimensional universe, the possible values for
A.X only cover a flat two-dimensional plane within that universe.
Whenever B is not on that plane, A.X = B cannot be solved. Matrix
inversion fails in this case, because A doesn't have an inverse. What
SVD does in this case is calculate the value of X such that A.X comes as
close to B as possible while remaining on that flat plane. That is the
advantage of using SVD over ordinary matrix inversion techniques.
Of course, a better solution is to re-define your problem so an exact
solution is possible.
|
|
|