cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Symbolic Calculation of Determinant

Cornel
18-Opal

Symbolic Calculation of Determinant

Hello,

 

CornelBejan_0-1681108431874.png

CornelBejan_1-1681108439076.png

 

CornelBejan_2-1681108470915.png

CornelBejan_3-1681108489320.png

CornelBejan_4-1681108938946.png

 

I think that I reached the full capability of Mathcad Prime 8 regarding the symbolic calculation. Or I am wrong?

 

Can somebody run this sol2 determinant in Mathcad Prime 9 to see the result?

 

Mathcad Prime 8 file attached.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Cornel)

Here is what I see in Prime 9 when I recalculate your sheet.
As you can see the result for the determinant is much nicer, the one for the inverse seems to be as ugly than what you got in P8.

Werner_E_1-1681131340502.png

 

Using 0.8 forces the symbolics in some sort of numeric/floating point mode (unfortunately).

If possible its always worth a try to change float numbers to fractions with integers.
You may use the "float" modifier yourself if appropriate

Werner_E_2-1681131486799.png

Experimenting with the number of significant digits in "float" can give unexpected results

Werner_E_3-1681131617545.png

Not sure where the factors 1.0 stem from. Most of them go away if we omit the "collect" modifier - strange!

Werner_E_4-1681132294515.png

 

 

 

View solution in original post

18 REPLIES 18

My Mathcad

ValeryOchkov_0-1681110652338.png

 

Uh, I do not understand Russian language, but I think it is the same result that my above result, right? And your Mathcad is Mathcad Prime 9?

Werner_E
24-Ruby V
(To:Cornel)


 

Can somebody run this sol2 determinant in Mathcad Prime 9 to see the result?

 

 


Very same effect in Prime 9, too.

Prime allows to display the numerator of the first element, but the denominator is too large in the opinion of Prime.

Actually its not a limitation of the symbolics itself as you get a result which you could assign a function (with 25 arguments) which then could be used for further calculations.
Its just an artificial display limitation as the developers thought that it would not make much sense to see an expression that huge and decided to save the memory which would otherwise needed for displaying the result.

Werner_E_1-1681125937316.png

 

 

Here with less typing efforts:

Werner_E_0-1681125684222.png

 

You may also use this for a more compact display (up to a 9x9 matrix)

Werner_E_2-1681126495446.png

 

I am wondering: what is the possible solutions to this thing? Some workarounds exist?

Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:

I am wondering: what is the possible solutions to this thing? Some workarounds exist?


For me its not a problem which needs a solution.

If its a problem for you, you may contact PTC support and open a support case. Tell them why its a problem and talk them into modifying Prime so that larger results could be displayed  on screen (maybe like it could be done in Mathcad 11 by using a registry entry).

 

As I see it you have four options

  1. Wait for Prime to be modified accordingly (I won't hold my breath)
  2. Get somehow access to an older version of Mathcad (version 11) and use it
  3. Use a different program with more capable symbolic and display options (not sure if Maple, Mathematica, MatLab, ... could fulfill your needs)
  4. Think about what the benefit of seeing such huge expressions displayed on screen actually would be and maybe come to the conclusion, that its not worth bothering anyway ;-).

 

Hi,

I think that I reached the full capability of Mathcad Prime 8 regarding the symbolic calculation. Or I am wrong?

Answer is Prime will do a larger matrix, but why reinvent the wheel.  You can just use the inbuilt function in Prime that can handle any matrix size!

Capture.JPG

The definition of the function sol2 as well as its symbolic evaluation is rather useless with this approach, isn't it? The last region in your screen should would be all thats needed. But your function shows what I tried to explained in my previous answer - its not a limitation of the symbolics itself as it returns a valid result which can be assigned a function and used numerically.

 

I, too, don't understand why @Cornel  insists on displaying such huge expressions but obviously, for reasons unknown to us, the goal of his attempts is to get the general symbolic result displayed on screen, not a numeric one. I guess he knows that he always can get a numeric result for much larger matrices if needed.


@Werner_E wrote:

I guess he knows that he always can get a numeric result for much larger matrices if needed.


Yes, I know that, but here the problem is how to calculate symbolically the DETERMINANT and INVERSE of the matrix, not how to calculate numerically the DETERMINANT and numerically INVERSE of a matrix.

 

For example, look:

CornelBejan_1-1681128298511.png

CornelBejan_2-1681128319190.png

CornelBejan_4-1681128647875.png

CornelBejan_7-1681129223576.png

 

 

Result of the determinat with Wolfram Mathematica:

1.png

 

Result of the inverse of that matrix with Wolfram Mathematica:

338411098_753057369832504_3961857906462980355_n.png

 

Do you see the differences? The results of the two (determinant and inverse of matrix) from the two software are not displayed the same.  

 

My question here: is it possible to see also in Mathcad Prime the same results of the determinant and inverse as it is shown in Wolfram Mathematica?

These results in Mathcad Prime with those great powers in calculation of the determinant (x^17 at numerator and x^12 at denominator) and inverse of matrix (x^33 at numerator and x^34 at denominator) seems strange...and I do not know why it looks like this and why Mathcad Prime gives the results in this manner.

Werner_E
24-Ruby V
(To:Cornel)

Here is what I see in Prime 9 when I recalculate your sheet.
As you can see the result for the determinant is much nicer, the one for the inverse seems to be as ugly than what you got in P8.

Werner_E_1-1681131340502.png

 

Using 0.8 forces the symbolics in some sort of numeric/floating point mode (unfortunately).

If possible its always worth a try to change float numbers to fractions with integers.
You may use the "float" modifier yourself if appropriate

Werner_E_2-1681131486799.png

Experimenting with the number of significant digits in "float" can give unexpected results

Werner_E_3-1681131617545.png

Not sure where the factors 1.0 stem from. Most of them go away if we omit the "collect" modifier - strange!

Werner_E_4-1681132294515.png

 

 

 

Thank you, Werner.

 

Here I have another example from one of my past post: 

 

CornelBejan_0-1681132912571.png

 

CornelBejan_1-1681132924472.png

 

Determinat of s*identity(7)-Aa matrix:

 

Not Good

CornelBejan_2-1681133003181.png

 

Good

CornelBejan_3-1681133015556.png

 

 

Inverse of s*identity(7)-Aa matrix:

 

Not Good

CornelBejan_4-1681133210665.png

CornelBejan_5-1681133222286.png

 

Not Good

CornelBejan_6-1681133235689.png

CornelBejan_7-1681133244551.png

 

Good

CornelBejan_8-1681133271564.png

 

So, it is seems so far that the "problem" at Mathcad Prime is that he (Mathcad Prime) doesn't like calculation with decimal numbers...

 

Is there any method by which to convert Mathcad decimal numbers into fractional numbers automatically?

Or the only option here in this case is to look at each number in the matrix and manually change each number from decimal to fractional?

 

Werner_E
24-Ruby V
(To:Cornel)

I don't think that conversion from a float number to a fraction with integers can be automatized in a way so the symbolic would accept it.

 

To get an integer we could turn the number into a string, delete the decimal point and convert the resulting string back to a number, but the symbolic does not understand the necessary functions num2str and str2num.

 

We could multiply the number x with 10 so often until x=trunc(x), but the symbolics nonetheless would treat the result as a float number when input value contains a decimal point.

Look:

 

-0.811, -1.273 and 0.637 change further in the s*identity(7)-Aa matrix also the other values from the resulted matrix from integer numbers into decimal/float numbers (for example: 1 into 1.0 and 0 into 0.0 -> 1 and 0 are the only non-decimal numbers in Aa matrix, if there were other values the same thing would have happened).

CornelBejan_0-1681136045359.png

 

And now if we change in Aa matrix from the beginning -0.811 into -811/1000, -1.273 into -1273/1000 and  0.637 into 637/1000 then the result of determinant is changing also, and also the values of 1 and 0 in resulted  s*identity(7)-Aa matrix does not change into 1.0 and 0.0:

CornelBejan_2-1681136666780.png

 

 

 

Werner_E
24-Ruby V
(To:Cornel)

Its not clear to me what you want to show with this.

Using exact integer fractions gives an exact result, even though "float" is used, while using decimals results in floating point results which cannot be simplified, maybe because of inaccurate intermediate floating point results.

That was the reason why I suggested that you may try using exact fractions to get simpler results.

LucMeekes
23-Emerald III
(To:Cornel)

The symbolic output of Mathcad (and Prime is no different) is hard to control. With some tricks, this matrix:

LucMeekes_3-1681149240870.png

Has a determinant of:

LucMeekes_4-1681149265144.png

And its inverse is:

LucMeekes_5-1681149285084.png

 

Success!
Luc

Hi Luc, What do you mean more exactly  by "with some tricks..."? Because in the images you show you didn't apply any trick...Or?

LucMeekes
23-Emerald III
(To:Cornel)

Just one trick.

 

The 0.8 is not a number, but a variable. It is defined as:

0.8 := 8/10

But essentially that's al there is to it.

 

Success!

Luc

Werner_E
24-Ruby V
(To:Cornel)

The main trick possibly is the usage of Mathcad 11 🙂

At work so far I have to stick with Mathcad Prime...

 

And it is not so straight forward if someone needs to change between multiple math software in order to make some calculations. Then there are license discussion because for each extra software company must buy the license (and bosses, you know, do not really want to do that (that is money spent)).

 

And of course regardless of the money for licenses for multiple software, how can one feel when for example half of the calculations she/he have to do in one software and the other half of calculations in another software...?

 

Then it's a matter of accumulating over time different things that you have made in one software and then you use further those built things (functions, methods), and in the other software you no longer have them (or at least you don't have them all) or you need to create them again and again...

 

So, it is not so easy when someone urges you to use another software: "use that math software or that software".

 

Top Tags