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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Determinat of a Matrix Mathcad Prime 8 Strange Result

Cornel
19-Tanzanite

Determinat of a Matrix Mathcad Prime 8 Strange Result

Hello,

 

CornelBejan_0-1674463934154.png

CornelBejan_1-1674463944323.png

 

Mathematica result:

CornelBejan_3-1674464026036.png

 

Maple result:

CornelBejan_4-1674464068837.png

 

Mathcad 11 result:

CornelBejan_5-1674464192543.png

 

Mathcad 15 result:

CornelBejan_6-1674464370601.png

 

Mathcad Prime 8 result:

CornelBejan_2-1674463970608.png

 

Why does Mathcad Prime give such a result when calculating the determinant of that matrix? Is this some bug from prime? or?


Mathcad Prime 8 file attached.

15 REPLIES 15
Werner_E
25-Diamond I
(To:Cornel)

In Maple you have a typo - first row, second column

Cornel
19-Tanzanite
(To:Werner_E)

CornelBejan_0-1674479226785.png

Did not influence pretty much...

Anyway, strange how Mathcad Prime calculates this determinant...

Werner_E
25-Diamond I
(To:Cornel)

still quite a large difference compared to the other solution! Look at the coefficients of s and s^2. All other programs get 4.2 and 11.3 but the result of Maple significantly differs!

 

In P8 you may try modifiers like "collect,s", "expand" or even just "simplify".

Cornel
19-Tanzanite
(To:Werner_E)

"In P8 you may try modifiers like "collect,s", "expand" or even just "simplify"."
I already tried and nothing...
And I don't really see what else to do, because we simply have the matrix and apply the determinate (| |) to it...

 

Is this not a bug or something in Prime, because it calculates like this?

Cornel
19-Tanzanite
(To:Werner_E)

A function like this (to do these kinds of calculations) should be created I think:
https://www.mathsisfun.com/algebra/matrix-determinant.html

CornelBejan_0-1674484513673.png

But this function should also be valid for calculating the determinant of a matrix larger than 3x3 as in the example above...
@Werner_E @LucMeekes
Does anyone know how to make a function like this?

Cornel
19-Tanzanite
(To:Cornel)

@Werner_E @LucMeekes @ttokoro @Fred_Kohlhepp 

 

Mathcad Prime 8 result (as shown above):

CornelBejan_0-1674485464011.png

 

Calculation with the formula above (hand calculation):

CornelBejan_1-1674485506419.png

CornelBejan_2-1674485518255.png

CornelBejan_3-1674485534573.png

 

CornelBejan_4-1674485625001.png

 

CornelBejan_5-1674485652594.png

 

Werner_E
25-Diamond I
(To:Cornel)

Yeah, you sure could write something like the Lagrange expansion using recursion, but chances are that symbolical evaluation still fails or explains that the result is too large, etc. I would say that writing a working function to symbolically calculate the determinant of a matrix is a job for the development team at PTC.
Did you already report your various problems with the symbolic calculation to PTC support?

Cornel
19-Tanzanite
(To:Werner_E)

"Did you already report your various problems with the symbolic calculation to PTC support?"

No, I don't know how to do this.

Werner_E
25-Diamond I
(To:Cornel)


@Cornel wrote:

"Did you already report your various problems with the symbolic calculation to PTC support?"

No, I don't know how to do this.


Maybe @VladimirN  or @DJNewman  can provide information about the current way to do so.

DJNewman
17-Peridot
(To:Werner_E)

  1. You need to have a support agreement with PTC (a normal subscription licence includes this; Mathcad via a perpetual licence requires being up-to-date with maintenance payments) to access the case logger: https://www.ptc.com/support/case-logger
  2. Follow directions; it's a whole series of interactive drop-down menus and text boxes. Don't check the sensitive data checkbox unless it's sensitive intellectual property you wouldn't share on the community
  3. Be sure to scroll down past the suggestions that you look through existing documentation and community resources and click to open a case with PTC
  4. You'll need your SCN (Service Contract Number); you can find it in various places, including within Mathcad itself in the window where you configure your licence (the "Service Contact #")
  5. Be sure to attach the worksheets

I know PTC employees may have a little different workflow than what normal customers have, but the above should suffice.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Cornel
19-Tanzanite
(To:Werner_E)

Until then...I think we can use your function of calculation of minors of a matrix also for calculating the determinant of a matrix.

CornelBejan_10-1674497128557.png

 

Here also calculate minors, but instead of putting the common element to be 1 as it is in the above function, the common element must be that number when we want to calculate the determinant of a matrix.

 

So, for example, if we have a matrix:

CornelBejan_1-1674496407144.png

And if we want to calculate the minor:

CornelBejan_2-1674496606795.png

 

With your function we get:

CornelBejan_0-1674497871914.png

CornelBejan_7-1674497014414.png

 

Classically we get:

CornelBejan_4-1674496774026.png


But if we want also to do this:

CornelBejan_11-1674497346714.png

 

We have to multiply that minor by the common element (and ignore the sign, because the InvElement function already takes its sign into account), so not by 1 as it is in your function.
So, with the above example, we should have:

CornelBejan_1-1674497951831.png

CornelBejan_8-1674497042790.png

CornelBejan_9-1674497067605.png

How can we do this in the above InvElement() function?

 

And at the end, the sum of each element multiplied by its minor must be made, but now let's see if it is possible to do what I said first/above, and then step 2 is to make the respective sums.

Cornel
19-Tanzanite
(To:Cornel)

@Werner_E 

This is my first implementation...

CornelBejan_0-1674501563443.png

 

Cornel
19-Tanzanite
(To:Cornel)

@Werner_E 

 

CornelBejan_0-1674505206872.png

 

CornelBejan_1-1674505214153.png

CornelBejan_2-1674505227959.png

CornelBejan_3-1674505239003.png

How do I make it so that when I put instead of the matrix, a function to which I assign a matrix, to get the result as in the first case when I put a matrix? (this is for symbolic computation. Numeric computation is ok as seen from the previous post)

 

Another thing:

CornelBejan_1-1674506245859.png
CornelBejan_0-1674506229470.png

CornelBejan_2-1674506255959.png

CornelBejan_5-1674506286350.png

CornelBejan_3-1674506268217.png

CornelBejan_4-1674506276395.png

 

CornelBejan_4-1674505463615.png

CornelBejan_7-1674505524578.png

 

CornelBejan_6-1674505484339.png

CornelBejan_8-1674505536342.png

CornelBejan_9-1674505550853.png

CornelBejan_10-1674505559231.png

 

CornelBejan_14-1674505685959.png

CornelBejan_0-1674506712457.png

CornelBejan_15-1674505852610.png

 

Werner_E
25-Diamond I
(To:Cornel)

Here is my attempt for a function to calculate the determinant of a square matrix.

First we define utility functions to delete rows and columns of a matrix

Werner_E_0-1674526543977.png

Then the determinant is calculated by Lagrange expansion after the first column - done recursive until we arrive at an 1x1 matrix

Werner_E_1-1674526616732.png

I haven't tested thoroughly, but it seems to work quite well, BUT ... its VERY SLOW when evaluated symbolically!!

Furthermore something like "simplify" or "expand" is necessary as otherwise the result isn't really nice 😉

Werner_E_2-1674526755351.png

 

Have fun and use at your own risk!

 

EDIT: Added an alternative function to delete rows (and columns) which avoids the slow "submatrix" function but it did not speed up the calculation.

Cornel
19-Tanzanite
(To:Werner_E)

CornelBejan_0-1675173085112.png

CornelBejan_1-1675173101348.png

CornelBejan_3-1675173506833.png

CornelBejan_2-1675173120197.png

How can that fraction be made to stop appearing? Is it possible to do that, somehow? Because we see that the numerator tends to 0...each variable s of numerator is multiplied by at least 10^-10, and at the final of the fraction we get the correct answer of the determinat.

 

Or would the only option be to manually extract the correct result of the determinant?

 

 

Announcements

Top Tags