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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Minimize mathcad prime

TR_9781963
9-Granite

Minimize mathcad prime

I converted worksheet from 15 to prime having minimize keyword. Giving different result after conversion are there any changes that is required to do in worksheet. 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:TR_9781963)


@TR_9781963 wrote:

Yes it gets the result but later when evaluated for x it does not give answer as 15. How to make this work in prime as 15?


Not sure what you mean.

As written above, the minimize function seems to be broken in Prime for some cases where it worked OK in Mathcad.
I added some explanation to my answer above.
It looks that you can't do anything to make minimize work OK in Prime other than reporting the bug/inability to PTC support and hoping for a fix in a future version.

 

The three workarounds using the root function or the solve blocks work OK, but of course you would have to assign their result to a variable if you want to use it later in your calculations:

Werner_E_0-1689622277747.png

 

BTW, if you use root, find or minerr, you may, but you must not use the absolute value when defining the function f_min.

 

You may also notice the the result of the root function is even more accurate than the result of minimize in Mathcad 15, where the values at the end do not match up to the displayed accuracy but just to eight decimals:

Werner_E_1-1689622751027.png

Actually using minimize is not a good choice for this task anyway (nonetheless its a bug that Prime fails here).

View solution in original post

3 REPLIES 3
Werner_E
25-Diamond I
(To:TR_9781963)

Can you provide de MC15 sheet?

 

I am not sure why minimize fails in Prime (I am using the current version 9 and can confirm that it does) and returns the guess value unchanged.

Different guess values return different results but not near the one you expect. Also "weighting" the expression you's like to minimize gives a result nearer the expected one, but this sure should not be necessary

Werner_E_0-1689619089577.png

I also tried to decrease the system variables TOL and CTOL, but without success.

PTC sure has changed quite some algorithms and this may be a limitation or bug and you may consider reporting it to PTC support.

 

Solving with the root function

Werner_E_1-1689619337105.png

or with a solve block with "find"

Werner_E_2-1689619363357.png

return the expected result without problems as does a solve block with "minerr"

Werner_E_3-1689619416431.png

 

Addendum: When you search this forum you will find quite a lot of threads dealing with problems in Prime with minimize and maximize. Some problems are due to user errors, but some are due to the changed algorithm. Prime is using the KNITRO solver while Mathcad was using the good old Conjugate Gradient algorithm, similar to Levenberg-Marquardt which as I guess is still used in Prime for minerr(). You see the difference 😉  In Mathcad you could also switch algorithms using the right-click context menu, but usually the default algorithm was a good choice anyway.
Many problems with minimize in Prime also stem from the usage of units, because Prime internally uses the default units (Pa in your case) and so minimize runs into a scaling problem. In your case this seems only be part of the problem (I tried it unitless). In your case I guess that the absolute value used in the function is also part of the problem as this results in a non-continuous derivative at the position you are looking for.

Anyway - in case of your example the old algorithm used in Mathcad sure is much superior over the new algorithm in Prime and maybe PTC should know about. However, I cannot say whether they are actually interested in it.

 

Yes it gets the result but later when evaluated for x it does not give answer as 15. How to make this work in prime as 15?

Werner_E
25-Diamond I
(To:TR_9781963)


@TR_9781963 wrote:

Yes it gets the result but later when evaluated for x it does not give answer as 15. How to make this work in prime as 15?


Not sure what you mean.

As written above, the minimize function seems to be broken in Prime for some cases where it worked OK in Mathcad.
I added some explanation to my answer above.
It looks that you can't do anything to make minimize work OK in Prime other than reporting the bug/inability to PTC support and hoping for a fix in a future version.

 

The three workarounds using the root function or the solve blocks work OK, but of course you would have to assign their result to a variable if you want to use it later in your calculations:

Werner_E_0-1689622277747.png

 

BTW, if you use root, find or minerr, you may, but you must not use the absolute value when defining the function f_min.

 

You may also notice the the result of the root function is even more accurate than the result of minimize in Mathcad 15, where the values at the end do not match up to the displayed accuracy but just to eight decimals:

Werner_E_1-1689622751027.png

Actually using minimize is not a good choice for this task anyway (nonetheless its a bug that Prime fails here).

Announcements

Top Tags