Clear Filters
Clear Filters

Using inv(A)*B instead of A\B

37 views (last 30 days)
Tejas Adsul
Tejas Adsul on 4 Jun 2018
Commented: Tejas Adsul on 5 Jun 2018
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 Comments
Walter Roberson
Walter Roberson on 4 Jun 2018
Are either M or F symbolic instead of numeric? In particular is M numeric but F symbolic?
Tejas Adsul
Tejas Adsul on 4 Jun 2018
The workspace shows M and F both to be symbolic. But M is just the identity matrix. F indeed is symbolic.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 5 Jun 2018
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 Comments
Walter Roberson
Walter Roberson on 5 Jun 2018
(I created the support case and referenced this Question)
Tejas Adsul
Tejas Adsul on 5 Jun 2018
That's great! Thank you.

Sign in to comment.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!