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

Translate the entire conversation x

Symbolic function error

pannus0
10-Marble

Symbolic function error

Hi, I'm having trouble finding the value of a variable using symbolic operations. Let me explain:
I want to find the variable (theta) of a symbolic function within a range of values

pannus0_0-1763029785126.png

I'm using Mathcad 11

ACCEPTED SOLUTION

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

Prime's symbolic engine is not as capable as you would like it to be.

It simply is not capable enough to solve your equation the way its defined and that has nothing to do with the "assume" modifier (which is ignored by the symbolics ever so often anyway).

It also can't solve the equation if you try to do it before defining the variables (which would be a justification for using the symbolics and not a numeric method) and it can't solve it after the variable definitions if the variables are defined with units (even though your equation only requires to cancel unit "m" on both sides).

It also does not help to turn on the calculation option "Units/Constants in Symbolics" (which always should be done anyway).

But Prime is at least capable to solve the equation if you remove the units yourself manually:

Werner_E_0-1763044646568.png

But I fully agree with Alan that symbolic "solve" is the wrong tool use here. It's not just because your problem simply doesn't require a symbolic solution, but also because the symbolic in Prime is not capable enough.

For example is 1.4575 the only solution the symbolics ever will find. It is unable to find, let's say, a solutions greater than 2:

Werner_E_1-1763045028542.png

let alone all solutions

Werner_E_2-1763045661480.png

 

Alan already had shown the way to go. For finding a numerical solution you should use a numerical method.  In Prime, this is either a solve block with “find,” the ‘root’ function with a guess value, or the “root” function with an interval provided..

Alan just made a sign error when defining the function f which is the reason his function has no solution in the interval [1; 2]

Werner_E_3-1763045843970.png

When providing an interval  the interval limits must be chosen carefully, as the function values at these points must have different signs.
To get the solution 4.2..., the interval [4; 5] is therefore unsuitable, but using [4; 4.5] works.

Werner_E_1-1763046716379.png

 

If you use the "root" function with a guess, there is no guarantee that the solution found is always near the guess value

Werner_E_0-1763047474396.png

 

When using a solve block with "find" you also have to provide a guess. A solve block takes up more space and looks quite ugly in Prime, but it has the advantage that you can use the equation as it is and furthermore you can add constraints like 1<=theta<2 which may (!, no guarantee) give you the desired solution even if you provide an inappropriate guess value

Werner_E_1-1763047699792.png

 

 

View solution in original post

7 REPLIES 7
AlanStevens
19-Tanzanite
(To:pannus0)

You can see from the graphs below that there is no solution in the range from 1 to 2.  

Also, there is little point in using a symbolic solver for a purely numerical solution.

 

Graph.png

 

Alan

Werner_E
25-Diamond I
(To:pannus0)

Prime's symbolic engine is not as capable as you would like it to be.

It simply is not capable enough to solve your equation the way its defined and that has nothing to do with the "assume" modifier (which is ignored by the symbolics ever so often anyway).

It also can't solve the equation if you try to do it before defining the variables (which would be a justification for using the symbolics and not a numeric method) and it can't solve it after the variable definitions if the variables are defined with units (even though your equation only requires to cancel unit "m" on both sides).

It also does not help to turn on the calculation option "Units/Constants in Symbolics" (which always should be done anyway).

But Prime is at least capable to solve the equation if you remove the units yourself manually:

Werner_E_0-1763044646568.png

But I fully agree with Alan that symbolic "solve" is the wrong tool use here. It's not just because your problem simply doesn't require a symbolic solution, but also because the symbolic in Prime is not capable enough.

For example is 1.4575 the only solution the symbolics ever will find. It is unable to find, let's say, a solutions greater than 2:

Werner_E_1-1763045028542.png

let alone all solutions

Werner_E_2-1763045661480.png

 

Alan already had shown the way to go. For finding a numerical solution you should use a numerical method.  In Prime, this is either a solve block with “find,” the ‘root’ function with a guess value, or the “root” function with an interval provided..

Alan just made a sign error when defining the function f which is the reason his function has no solution in the interval [1; 2]

Werner_E_3-1763045843970.png

When providing an interval  the interval limits must be chosen carefully, as the function values at these points must have different signs.
To get the solution 4.2..., the interval [4; 5] is therefore unsuitable, but using [4; 4.5] works.

Werner_E_1-1763046716379.png

 

If you use the "root" function with a guess, there is no guarantee that the solution found is always near the guess value

Werner_E_0-1763047474396.png

 

When using a solve block with "find" you also have to provide a guess. A solve block takes up more space and looks quite ugly in Prime, but it has the advantage that you can use the equation as it is and furthermore you can add constraints like 1<=theta<2 which may (!, no guarantee) give you the desired solution even if you provide an inappropriate guess value

Werner_E_1-1763047699792.png

 

 

Spoiler

 Dear Werner_E and Alan, thank you for your responses.

I understand that the best option is to perform the operation using a solver block; however, for this example, I wanted to find the value using a symbolic operation, which led me to the following question:

1.-In example 01, I perform this symbolic operation with its units, and the Prime program solves it.

pannus0_2-1763257017582.png

 I believe this is because in this example there is only one variable, D, that needs to be found.

2.-In example 02, I perform this symbolic operation and it shows me the error.

pannus0_5-1763258216822.png

3.0 I should add to Werner_E's answer that the units can be turned off using the SIUnitsOf(e) and SIUnitsOf(R) functions.

pannus0_3-1763257946375.png

 



 

Werner_E
25-Diamond I
(To:pannus0)

Spoiler?? Why?

And which "question" are you referring to? I can see no question in the picture you post.

Furthermore you should be very careful when using the "float" modifier. Its not just for display but it affects the precision of the whole calculation which is done just with rounded values!

Dear Werner_E and Alan, thank you for your responses.

I understand that the best option is to perform the operation using a solver block; however, for this example, I wanted to find the value using a symbolic operation, which led me to the following question:

1.-In example 01, I perform this symbolic operation with its units, and the Prime program solves it.

pannus0_0-1763262832489.png

 

 I believe this is because in this example there is only one variable, D, that needs to be found.

2.-In example 02, I perform this symbolic operation and it shows me the error.

pannus0_1-1763262832563.png

 

3.0 I should add to Werner_E's answer that the units can be turned off using the SIUnitsOf(e) and SIUnitsOf(R) functions.

pannus0_2-1763262832754.png

 

 

Werner_E
25-Diamond I
(To:pannus0)

???

As far as I can see that's exactly the same you already posted more than an hour before as a "spoiler".

 


however, for this example, I wanted to find the value using a symbolic operation, which led me to the following question:

I still can't see any question?????

 

BTW, the reason that Prime could solve your first equation is not because it only contains one variable or because this variable only occurs once in the equation. The reason is that this equation is a mathematical very simple equation that does not overwhelm Primes' limited capabilities.

Prime is clearly hopelessly overstretched with the second equation and the units.

The third one with the variable still inside of trigonometric functions but with stripped units is too difficult for Prime to solve completely and exact. It switches into float mode automatically and refuses to deliver any other solution than the one specific you show.

 

Her a simple example:

Werner_E_0-1763265739943.png

Prime is able to provide exact symbolic solutions and offers an (arbitrary ?) selection of three solutions out from the infinite number of solutions.

We can limit the range for x using "assume"

Werner_E_1-1763265868011.png

and we also can Prime talk into returning an expression for all possible solutions

Werner_E_2-1763265938378.png

The result looks ugly, but is correct. Older Mathcad versions did a better job here:

Werner_E_3-1763265979142.png

 

But as soon as we apply a small change, the equation gets too complicated for Prime and its not capable any more to find a symbolic solution. It switches into float mode, seems to apply some numeric approximation algorithm, ignores the "assume" modifier and of course is not able to provide an expression for all solutions. It looks like the approximation algorithm used uses always the same initial value and so comes up with the very same solution (here: two solutions) no matter which modifiers are applied.

Werner_E_4-1763266379291.png

 

The exact solutions for this equation have to be found by other means and are seen here

Werner_E_5-1763267554343.png

 

Uncle Wolfram is able to come up with the correct solutions:

Werner_E_6-1763267645128.png

 

 

 

 

 

 

AlanStevens
19-Tanzanite
(To:pannus0)

"Alan just made a sign error when defining the function f ..."

 

Oops! Apologies, that was careless!

 

Alan

Announcements

Top Tags