"Roger Stafford" wrote in message <k6msmk$l8l$1@newscl01ah.mathworks.com>...
> "Ha" wrote in message <k6mp64$9uj$1@newscl01ah.mathworks.com>...
> > >>inv(A'*A)
> > >> T=A'; inv(T*A)
> > Look, it's funny that the two results are different. How can that be?
> >
> > Then, I tried
> > >> A'*A-T*A
> > not equals to zero.
> - - - - - - - - - - -
> I will make a guess here. When the matlab compiler sees the expression A'*A it realizes that the result must be Hermitian and for better computation efficiency calls on a different routine than with T*A. Due to the different algorithm used the roundoff errors will differ, hence the very small differences you observed after subtraction. Since both results are nearly singular their two inverses would likely be quite large as you observed in this case.
>
> Roger Stafford
Correct. For the expression A'*A, MATLAB will call a symmetric BLAS matrix multiply routine, whereas the expressions T = A' and subsequently T*A will end up calling the generic BLAS matrix multiply routine. The results will be close but not exactly the same.
James Tursa
> "Ha" wrote in message <k6mp64$9uj$1@newscl01ah.mathworks.com>...
> > >>inv(A'*A)
> > >> T=A'; inv(T*A)
> > Look, it's funny that the two results are different. How can that be?
> >
> > Then, I tried
> > >> A'*A-T*A
> > not equals to zero.
> - - - - - - - - - - -
> I will make a guess here. When the matlab compiler sees the expression A'*A it realizes that the result must be Hermitian and for better computation efficiency calls on a different routine than with T*A. Due to the different algorithm used the roundoff errors will differ, hence the very small differences you observed after subtraction. Since both results are nearly singular their two inverses would likely be quite large as you observed in this case.
>
> Roger Stafford
Correct. For the expression A'*A, MATLAB will call a symmetric BLAS matrix multiply routine, whereas the expressions T = A' and subsequently T*A will end up calling the generic BLAS matrix multiply routine. The results will be close but not exactly the same.
James Tursa