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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

7-Bedrock

## Variable not defined. Mathcad 3.0

Somebody Knows why I can not give r11 to the function A?

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:hegel)

The reason is, as Fred already said, the (unneccessary) use of the symbolics.

The symbolics always traces back to the root of the definition of a variable and uses this for its calculations.

In your example the root is the "root" command (pun intended) and unfortunately "root" is only for numeric evaluation and can't be evaluated symbolically. So when the symbolics tries to go back to the definition of r11 it also tries to evaluate the root command, fails and that way r11 remains undefined for the symbolics.

What Valery found is not a bug but just a way to break that tracing back of the symbolics. Its called numeric inline evaluation. When you write r11:=root(f,g,x)=0.974 this is treated as a simple value assignment. The symbolics does not see the root command anymore and takes the numeric value at the end as value of r11.

You can achieve the very same effect if you use the (on first sight meaningless) assignment r11:=r11=...

BTW, are you aware that there is a second way to use the root command? You can use it without having to define a guess value first but simply provide limits for the looked for value -> r11:=root(f,g,x,0,2)=0.974

Interestingly the symbolics behaves a bit different (but still not as expected) if the values are calculated that way.

5 REPLIES 5
24-Ruby IV
(To:hegel)

7-Bedrock
(To:ValeryOchkov)

OK. But Im interested to know what happened with my programm.  I would like to know why he/she (the programm) doesn´t like it.

Omar

23-Emerald I
(To:hegel)

@hegel wrote:

OK. But Im interested to know what happened with my programm.  I would like to know why he/she (the programm) doesn´t like it.

Omar

Mathcad symbolics are very challenging to use.  You're using symbolics to do what you should be doing numerically.

24-Ruby IV
(To:hegel)

A bug?

24-Ruby V
(To:hegel)

The reason is, as Fred already said, the (unneccessary) use of the symbolics.

The symbolics always traces back to the root of the definition of a variable and uses this for its calculations.

In your example the root is the "root" command (pun intended) and unfortunately "root" is only for numeric evaluation and can't be evaluated symbolically. So when the symbolics tries to go back to the definition of r11 it also tries to evaluate the root command, fails and that way r11 remains undefined for the symbolics.

What Valery found is not a bug but just a way to break that tracing back of the symbolics. Its called numeric inline evaluation. When you write r11:=root(f,g,x)=0.974 this is treated as a simple value assignment. The symbolics does not see the root command anymore and takes the numeric value at the end as value of r11.

You can achieve the very same effect if you use the (on first sight meaningless) assignment r11:=r11=...

BTW, are you aware that there is a second way to use the root command? You can use it without having to define a guess value first but simply provide limits for the looked for value -> r11:=root(f,g,x,0,2)=0.974

Interestingly the symbolics behaves a bit different (but still not as expected) if the values are calculated that way.

Announcements
Top Tags