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 PTC Community Badges. Engage with PTC and see how many you can earn! X

"Solve" command turns for ever

FB_10651590
4-Participant

"Solve" command turns for ever

In this case I want  to allocate a result of substitution to Eq1, 

It seems to works for the substitution but  then Eq1 seems undefined. What happens?

 

Then it might be the reason why the 2nd substitution is endless.

 

 

However, when i try to make 2 substitution in the same execution command, it is endless too.

What happens  ?  Is there a relation between those 2 cases ?

 

Option calculation for constant unit with symobilc math is set.

PTC MathCAD prime 9.0.0.0.0

21 REPLIES 21
Werner_E
25-Diamond I
(To:FB_10651590)

You try to evaluate Eq1 numerically (the normal equal sign). Here Prime throws an error because of the derivative of the unknown and probably undefined function Theta.

Numeric evaluation will only return numeric values, not generic functions or their derivatives.

Not sure what may cause the "endless" calculation. Its hard to impossible to debug just a picture ...

FB_10651590
4-Participant
(To:Werner_E)

Thank you for your answer.

 

I now try another approach:

1-define completely the symbolic formula

2- then i will define numerical values of known parameters

 

I expect so to see the formula with some numerical values.

 

In the following  formula, the result seems unknown, as I would have expect on 2nd line to have the same than 1st line.

2024-04-17_09h18_28.png

Werner_E
25-Diamond I
(To:FB_10651590)

You must realize the difference between numeric evaluation (=) and symbolic evaluation (->)

Werner_E_0-1713347219149.png

 

Here some remarks using a simpler example

Werner_E_1-1713347299096.png

BTW, even in the last approach a derivative won't work (IMHO it should, but maybe its because Prime would have to do the numeric derivation at definition time which it can't  because the function is unknown at that time?)

Werner_E_2-1713347429505.png

nor that way

Werner_E_3-1713347464074.png

 

 

 

LucMeekes
23-Emerald III
(To:Werner_E)

Hmm, one more thing broken.

Mathcad 11 does:

LucMeekes_0-1713348350282.png

(But would not allow:

LucMeekes_1-1713348430305.png

)

 

Luc

 

Werner_E
25-Diamond I
(To:LucMeekes)

It look like its a new Prime 10 bug!

It still works OK in Prime 9

 

Prime 9:

Werner_E_0-1713349948744.png

 

Prime 10:

Werner_E_3-1713350173928.png

 

Error message means "A function or variable name is needed".

I can see no meaningful reason why f2 should fail but f1 would work OK.

 

Cornel
19-Tanzanite
(To:Werner_E)

Can You try in prime 10 this: f2():=a+f1(), and then evaluating f2 function to see If in this way it works?

Werner_E
25-Diamond I
(To:Cornel)


@Cornel wrote:

Can You try in prime 10 this: f2():=a+f1(), and then evaluating f2 function to see If in this way it works?


Yes, that's a workaround but it should not be necessary to do so.
I still consider the behaviour in Prime 10 to be a newly introduced bug which should be fixed by PTC!

 

Fortunately this bug seems to not affect the main question in this thread.

Latest status is that there are unit problems. See https://community.ptc.com/t5/Mathcad/quot-Solve-quot-command-turns-for-ever/m-p/944882/highlight/true#M211387

 

FB_10651590
4-Participant
(To:Werner_E)

example are intersting, but it is not exactly the need.

 

From a complex symbolic equation, i need to fill with numerical data some fixed parameters,

but i would like to keep the symbolic formula which representation will be simplified with some numerical values.

 

At the end, I need to see better which are preponderant terms of the formula and understand better how it behaves.

Werner_E
25-Diamond I
(To:FB_10651590)

Again - any expressions. either typed in or derived by a symbolic operation like "solve" is static in the sense, that variables defined later will not be replaced in that expression if you evaluate it.

Only way out is to define it as a function.

As already shown you may define variables and functions but make them inaccessible for the symbolic engine.

That way you can make an expression evaluate numerically using the numeric evaluation (=) and still have the symbolic result at hand if you evaluate it symbolically.

Werner_E_0-1713355254877.png

 

LucMeekes
23-Emerald III
(To:FB_10651590)

"At the end, I need to see better which are preponderant terms of the formula and understand better how it behaves."

Exactly for this purpose it is MUCH better if you define a function with parameters. Elaborating on Werner's example with:

LucMeekes_0-1713374348160.png

you can have the numerical result:

LucMeekes_1-1713374393018.png

or another one:

LucMeekes_2-1713374412413.png

AND you can see how a specific variable is handled, such as a:

LucMeekes_3-1713374456373.png

or b:

LucMeekes_4-1713374478989.png

And if you do NOT clear the symbolic for f:

LucMeekes_5-1713374573862.png

Success!
Luc

 

 

FB_10651590
4-Participant
(To:LucMeekes)

Thank you for your proposal.

I am currently trying it but facing a simple issue to build the final formula:

 

 

2024-04-18_12h35_04.png

Werner_E
25-Diamond I
(To:FB_10651590)

In your example the value of k would not only depend on a1, a2, b1 and b2, but also on the value given by function f. I call this value F in the screenshot below.

You could do as follows:

Werner_E_0-1713437474176.png

 

FB_10651590
4-Participant
(To:Werner_E)

again thank you very much for your answer

 

I try to follow your example, but very quickly it says there is no solution, although I am sure  there is one

 

2024-04-18_16h41_04.png

Werner_E
25-Diamond I
(To:FB_10651590)

Don't ask me why, but Prime fails because of the function Load.axial in the parameter list.

Maybe because the solutions does not directly depend on that function, but the logic behind that failure is not really clear to me at the moment.

But anyway, once you delete Load.axial from the parameter list of your function get_LoadPinch..., Prime is happy and returns a result:

Werner_E_0-1713456600675.png

 

EDIT: OK, I guess a have a logical explanation for Primes failing when you apply the function name as a parameter. Doing so would you enable to provide different functions Load.axial. But Prime tries right ahead to find a solution even though now the function Load.axial is unknown. But this function has the variable you want to solve for as an argument and because Prime does not know what the function looks like its quite clear that it can't give a symbolic solution.

We would need some kind of late evaluation which triggers the symbolics only when the function is called with a specific function Load.axial as its argument, but this is not an option in Prime.

Here a simplified example

Werner_E_0-1713461622495.png

 

FB_10651590
4-Participant
(To:Werner_E)

Interesting point, thanks a lot.

 

Now I come almost to the end.

I have my symbolic formula.

I define some numerical values

 

I would like to get 'simplfied' formula where all calculation that be done and simplified appear done

and ideally with a factor or the symbol "I" 

2024-04-18_21h04_26.png

What should be used as keywords to get a kind of clean and understandable equation ?

 

Werner_E
25-Diamond I
(To:FB_10651590)

The problem here seems that you still have undefined variables in the expression (probably only I) and so you have to use the symbolic evaluation.

On the other hand you run into the inability of the symbolics to deal with units and so it can't simplify expression with different units, which actually may cancel or can be collected.

Can you post the sheet so we  can see if we could find a workaround?

 

You could try to (re)define some units at the top of the sheet - maybe in a collapsed region.

E.g. the symbolics does not know about "deg", but if you define deg:=pi/180 (deg should be labelled as unit), the symbolics will numerically evaluate the cos(20 deg).

Same applies to lengths units. When you define mm:=10^-3 m (mm again should be labeled as unit), the symbolics will simplify all lengths to meter. If you define m := 10^3 mm it will default to mm.

Doing so may help Prime to arrive at a simpler expression. You may also use the modifier "float, 8" to limit the precison to 8 significant digits (rather than the default 20). But you have to be aware that this not only effects the display but also the precision of the whole calculation. So the "float" modifier should be used with care.

 

Instead of defining mm:=10^-3 m at the top of the sheet you may also use "substitute, mm=10^-3 m" as a modifier in the symbolic evaluation. But you would have to write this in every symbolic evaluation where you'd like it to be respected, so I guess the assignment in front may be the better solution.

 

 

FB_10651590
4-Participant
(To:Werner_E)

Here the complete sheet, 

it seems "subsitute" does not help, nor the definiton of "mm:=10^-3m".

 

You will at the bottom the final "simplified " formula which is expected.

 

I hope there is a way as we are so close to the end (at least I thing so).

Werner_E
25-Diamond I
(To:FB_10651590)

I had a quick look but actually I am lost as of the large expressions because of your huge long variable names. 

Maybe I'll have a second look tomorrow if times allows.

EDIT:

I had a quick second look and moved the unit (re)definitions to the front of the sheet, where they belong (in front of any variable definition) and also labeled then as units (see the bold blue type face).

I also added gm := 10^-3 kg

See attached file

If you need more unit simplification you have to tell the symbolics so likewise.

 

The last expression yields something like sin(function) and I tried to find out where this may stem from but I got completely lost in your (for me) much too large expressions with all those lengthy variable and function names. All I could see is that this strange expression also occurs in the definition of your function get_LoadPinch but I was not able to trace any further.

I guess I can't be of help anymore here...

 

EDIT2: OK, I couldn't resist 😉

Found the root of the problem:

Werner_E_0-1713541607983.png

 

Here some thoughts which may help tiding up the worksheet, making the expression a bit shorter and maybe better readable:

Werner_E_3-1713542123747.png

 

Werner_E_2-1713542112483.png

You may of course combine the methods, create a function with two or three vector arguments, etc. - whatever seems appropriate.

 

 

 

Werner_E
25-Diamond I
(To:Werner_E)

After fixing the aforementioned problem with gamma we get a symbolic result, but there are one or two unit problems you'll have to fix!

Werner_E_2-1713626120210.png

Prime 9 sheet attached

FB_10651590
4-Participant
(To:Werner_E)

Great! thank you so much!

 

I am new to Prime  but finding the error seems a litttle complex,

the case of the 3 arguments of Gamma was not easy to find as not clue from Prime.
Anyway thank you for your patience. 

Now I need to find this unit problem.

Werner_E
25-Diamond I
(To:FB_10651590)


@FB_10651590 wrote:

Great! thank you so much!

 

I am new to Prime  but finding the error seems a litttle complex,

the case of the 3 arguments of Gamma was not easy to find as not clue from Prime.
Anyway thank you for your patience. 

Now I need to find this unit problem.


It wasn't easy for me, too because of the large expressions and variable names.

Prime's symbolics can't give any clue because it doesn't see it as an error.

If you define a function and evaluate just the function name, all information you will get is that its a function.

Werner_E_0-1713643097090.png

This is exactly what happened when you used just the function name gamma.

Only when you provide function arguments the symbolic will evaluate the function using the definition

Werner_E_1-1713643200934.png

 

One idea to make the expressions in your sheet a bit smaller would be to make all functions only dependent on the few arguments you need.

It looks like you just want the result be dependent on the four arguments I, Acc.Mot, Fr.Axial and K0.

So you could define the other variables at the top and then define all functions only dependent on those four variables.

 

According the unit mismatch I can't help. Its either in the formulas you used or in the variable definition (or both). Good luck!

 

 

Announcements

Top Tags