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

37 次查看(过去 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
Walter Roberson 2018-6-4
Are either M or F symbolic instead of numeric? In particular is M numeric but F symbolic?
Tejas Adsul
Tejas Adsul 2018-6-4
The workspace shows M and F both to be symbolic. But M is just the identity matrix. F indeed is symbolic.

请先登录,再进行评论。

采纳的回答

Walter Roberson
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 个评论
Walter Roberson
Walter Roberson 2018-6-5
(I created the support case and referenced this Question)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by