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

3 vues (au cours des 30 derniers jours)
Tejas Adsul
Tejas Adsul le 4 Juin 2018
Commenté : Tejas Adsul le 5 Juin 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 commentaires
Walter Roberson
Walter Roberson le 4 Juin 2018
Are either M or F symbolic instead of numeric? In particular is M numeric but F symbolic?
Tejas Adsul
Tejas Adsul le 4 Juin 2018
The workspace shows M and F both to be symbolic. But M is just the identity matrix. F indeed is symbolic.

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by