Find the inverse of a Matrix in MATLAB, is inv(A) or A\eye(size(A)) more precise? -
this question has answer here:
- why matlab's inv slow , inaccurate? 3 answers
the title explains already. if need find inverse of matrix, there reason should use a\eye(size(a))
instead of inv(a)
? , before ask: yes, need inverse, not calculations.
ps:
isequal(inv(a), a\eye(size(a))) ans = 0
so 1 more precise?
update: question closed appeard duplicate of question "why inv in matlab slow , inaccurate". question here differs not addressing speed, nor accuarcy of function inv
difference of inv
, .\eye
calculate true inverse of matrix.
if need inverse, should use inv
.
the inverse calculated via lu decomposition, whereas backslash operator mldivide
calculates solution linear system using different methods depending on properties of matrix a
(see https://scicomp.stackexchange.com/a/1004), can yield less accurate results inverse.
it should noted if want solve linear system, calculation going faster , more accurate using mldivide
(\
). matlab documentation of inv
1 big warning not use inv
solve linear systems.
Comments
Post a Comment