Using inv(A)*B instead of A\B
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to solve some differential equations numerically. I followed the steps in this documentation
So, I got the 'M' and the 'F' matrices. There are 33 equations, and they are quite long in length. Dimensions of M are 33x33, those of F are 33x1. I am stuck at the step
f = M\F;
I think due to long expressions and many variables, my Matlab stops responding. However, I read in the 'mldivide,\' documentation that
'If A is a square matrix, then A\B is roughly equal to inv(A)*B, but MATLAB processes A\B differently and more robustly.'
I tried doing f = inv(M)*F, and it took almost no time. I got my results pretty quick.
I wanted to know if changing that step would have any major consequences on the results. Can I use 'inv(M)*F' instead of 'M\F', if the former one gives me results faster? Since I don't really know what the results should look like, I have no way of validating whether they are correct. I just want to know if changing this step does not alter the result majorly.
Thank you
댓글 수: 2
Walter Roberson
2018년 6월 4일
Are either M or F symbolic instead of numeric? In particular is M numeric but F symbolic?
채택된 답변
Walter Roberson
2018년 6월 5일
In the case where you know that M is the square identity matrix with the same number of columns as F has rows, then you can skip f = M\F and go directly to f = F; . That is because in the case of a square matrix the definition of the M\F operator is "as if" inv(M)*F except with higher numeric precision, and you can be sure that inv() of an identity matrix is the same as the identity matrix, leaving you the identity matrix times F, which is going to be just F.
I will create a support case to recommend an improvement to the detection algorithm to make this situation faster.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!