Skip to content

Determinant and check for singular matrices #4687

@HansOlsson

Description

@HansOlsson
  1. Currently a test of the type Modelica.Math.Matrices.det(L)>=epsilon is used in two cases, Modelica.Electrical.Polyphase.Basic.MutualInductor and Modelica.Electrical.QuasiStatic.Polyphase.Basic.MutualInductor. As noted in Prefer warning instead of print message #4685 that is problematic for several reasons, and not normally used in numerical analysis.

These are in fact the only uses of the determinant function inside MSL, and should likely be replaced based on the updated recommendations from the next item. (The description of epsilon might also be updated for these models.)

  1. The recommendation for not using Modelica.Math.Matrices.det in its documentation should be updated:
  • The current documentation says: "Usually, this function should never be used, because there are nearly always better numerical algorithms as by computing the determinant." I believe "as" is a common German false-friend-error and should be "than". Additionally "Usually ... should never..." seems odd, and I would prefer "Usually... should not...".
  • It recommends replacing det(A)=0 by rank(A)<size(A,1), but I wouldn't recommend using Modelica.Math.Matrices.rank as it involves singular-value-decomposition which is even more expensive and still has some scaling issues, but instead recommend using Modelica.Math.Matrices.rcond (which completely avoids the scaling issue).
  • It also recommends using solve instead of using det to solve systems of equations. I obviously agree with the recommendation, but even mentioning that you could use the determinant in that way seems weird to me.

So perhaps something like:
Use Modelica.Math.Matrices.solve(A,b) to solve systems of equations and Modelica.Math.Matrices.rcond(A)>=epsilon to check that the system is well-conditioned and not singular.

Metadata

Metadata

Assignees

No one assigned

    Labels

    L: Electrical.PolyphaseIssue addresses Modelica.Electrical.PolyhaseL: Electrical.QuasiStaticIssue addresses Modelica.Electrical.QuasiStaticL: MathIssue addresses Modelica.Math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions