Rank: Newbie
Groups: Registered
Joined: 28/10/2022(UTC) Posts: 4 Location: Alabama
|
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,356 Was thanked: 815 time(s) in 516 post(s)
|
Hi David. The difference in the values may be due to whether one of the versions has an implicit eval() and the other does not. To verify that it would be necessary to see the original matrix K. In any case, to know if there are going to be differences in the calculation, the condition numbers are used, available in mathcad, but I don't know if they are in any SMath plugin. Best regards. Alvaro.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 28/10/2022(UTC) Posts: 4 Location: Alabama
|
Thanks, Alvaro. I've attached a screenshot of part of the K matrix in case that will spark any thoughts, but not sure if that will be helpful. I could upload the .sm file as well if that would be easier. When you say one of the versions, you mean 'K^-1 =' vs 'Kinv = K^-1; Kinv = '. If it was a condition number problem, would you expect that to show up simply because we've defined a variable rather than evaluating without a new variable definition? I'm just specifically confused as to why: K^-1 = one answer Kinv = K^-1; Kinv = a different answer. Is something happening related to the condition number when saving the inverse as a variable that doesn't happen when evaluating directly? Thanks again for your thoughts.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,356 Was thanked: 815 time(s) in 516 post(s)
|
Hi. Condition numbers are for check if a problem involving some matrix is a problem with a low condition number is said to be well-conditioned, while a problem with a high condition number is said to be ill-conditioned. What the inverse() SMath's function do is a numerical procedure, not a symbolic matrix inversion. So, it could have a lot of different issues. This are the available condition numbers in Mathcad. If you attach the smath dile someone here can tell you more about. Notice that there are some plugins that have the matrix inversion procedures too. For instance dn_MatrixInverse, but there are others, I think. What I say about eval() is about an SMath function that make some round-up and truncation errors. In your case you need to check if you get the same different result with KK := submatrix(K,1,20,1,20) and KK := eval( submatrix(K,1,20,1,20) ) Finally, your K matrix is of the type 'sparce'. Some programs can detect that and use some specific algorithms for such cases, like matlab. Best regards. Alvaro. PD. Perhaps the condition number requires some explanation. Suppose you solved a purely resistive electrical circuit by direct calculation, either nodes or meshes. If you see it from a simple theoretical point of view, you could have used Kramer's rule to solve it, since it is a linear system. And you know well that for there to be a unique solution, the determinant of the matrix of the system has to be different from zero. But we are talking about a real circuit. And the resistors are not exact, they come with a 10% error, for example. So how do I know if the circuit I designed is going to be stable or a mess? You justify by calculating some of the condition numbers to the system matrix. So you say that the problem you solved is well conditioned because you got a low value for that number, which is going to indicate that there are going to be no problems using that matrix in a linear system. That is, you never provide only one solution to a practical problem. You also have to study its stability. Condition numbers are suitable for linear systems with matrices. For differential equations there are also methods to study the stability of the proposed solutions. Edited by user 28 October 2022 08:07:30(UTC)
| Reason: Notes added.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/12/2009(UTC) Posts: 246 Location: Cali, Colombia Was thanked: 85 time(s) in 65 post(s)
|
Originally Posted by: David R Thanks, Alvaro. I've attached a screenshot of part of the K matrix in case that will spark any thoughts, but not sure if that will be helpful. I could upload the .sm file as well if that would be easier. When you say one of the versions, you mean 'K^-1 =' vs 'Kinv = K^-1; Kinv = '. If it was a condition number problem, would you expect that to show up simply because we've defined a variable rather than evaluating without a new variable definition? I'm just specifically confused as to why:
K^-1 = one answer
Kinv = K^-1; Kinv = a different answer.
Is something happening related to the condition number when saving the inverse as a variable that doesn't happen when evaluating directly?
Thanks again for your thoughts.
Hi David, From my point of view, your matrix looks like a stiffness matrix from a Finite Elements Method approach, if that is the case, I was working on that some time ago, and I found some issues trying to solve the equation [x]=[K]^-1*[F]. My solution was to use Gauss elimination or a solver for a banded version of [K]. Anyway, as mention Alvaro, it would be great if you attach your .sm file to check it. Best, Oscar Edited by user 28 October 2022 15:20:12(UTC)
| Reason: Not specified
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: Jean Giraud Please, attach the document, mostly the matrix creation. Page3 MatrixForum.sm (47kb) downloaded 7 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 28/10/2022(UTC) Posts: 4 Location: Alabama
|
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,356 Was thanked: 815 time(s) in 516 post(s)
|
|
1 user thanked Razonar for this useful post.
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: David R When inverting a matrix, I get a different output between (1) evaluating the inverse of a matrix and (2) defining a new variable as the inverse of the original matrix and evaluating the new variable Set your matrix inversion to NUMERIC ...yellow in there. Page3 MatrixForum.sm (100kb) downloaded 14 time(s).
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 28/10/2022(UTC) Posts: 4 Location: Alabama
|
Originally Posted by: Jean Giraud Originally Posted by: David R When inverting a matrix, I get a different output between (1) evaluating the inverse of a matrix and (2) defining a new variable as the inverse of the original matrix and evaluating the new variable Set your matrix inversion to NUMERIC ...yellow in there. Page3 MatrixForum.sm (100kb) downloaded 14 time(s). That worked perfectly. Thank you! Is there an Explain It Like I'm 5 as to why we need to specify the numeric solver rather than symbolic to get the right answer?
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: David R That worked perfectly. Thank you! Is there an Explain It Like I'm 5 as to why we need to specify the numeric solver rather than symbolic to get the right answer? By default, everything you define in Smath is symbolic. Matrix inverse are numeric from libraries [mostly Cholesky] Thus, specify inverse as numeric to comply with Smath plugins. Will you sleep better ! Jean.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.