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

particular symbolic eval used to work, but acts differently in ver 15? stuck

ptc-4379937
1-Newbie

particular symbolic eval used to work, but acts differently in ver 15? stuck

Strange issue with maybe a simple explanation. I have a MCAD file that used to work with version 12, but with ver 15 gives a different (incorrect) result. I suspect issues with global versus local interpretation of arguments, but all I know is that it used to work fine. I didn't see anythign in th help that jumped out at me relative to why this would have used to work, but will not now.

Any pointers would be appreciated.

thanks,

Brian

1 ACCEPTED SOLUTION

Accepted Solutions

Here is a Sensitivity function which you can use the same way as you could yours in Mathcad 12 without having to rewrite the functions.

View solution in original post

11 REPLIES 11

They have changed the symbolic processor in the meantime. In MC12 we had Maple, now in MC15 we have muPad. These behave very differently in many situations.

Find attached some workarounds which may be of interest.

Thanks WE, that is astounding. That V15 shortcoming is really unfortunate. I was hoping to be able to arbirarily pick the variable by which I'd like the Sensitivity calcualted against, but it looks like these workarounds require a specific order to "trick" the function-passing.

I wonder if there are any other ways to do this that somehow retain the ability to pass an arbirary function along with the variable against which the Sensitivity is to be calcaulated. The latter is such a useful thing I hope that there is some way to make it work. But maybe there is not .

Here's a slightly more flexible version.

Alan

Here's a generalisation for more complicated functions.

Alan

Thanks Alan. Yeah I saw the same issue you did when I experimented with making the wo function more complicated. I was going to respond to your first post asking about that but you beat me to it. I'm trying to follow the program, as I'm not sure why it works. In the first line of your program I didn't understand why z (an undefined variable) was loaded into xn, rather than the other way around. I don't get why it works. But if I change it to the latter, it gives the same wrong result I was getting before the first way I was doing it. Do you know why it sometimes returns the result as a function of z?

brian poindexter wrote:

.... In the first line of your program I didn't understand why z (an undefined variable) was loaded into xn, rather than the other way around. I don't get why it works. But if I change it to the latter, it gives the same wrong result I was getting before the first way I was doing it. Do you know why it sometimes returns the result as a function of z?

Mathcad needs a "name" as the variable it's differentiating with respect to, and it doesn't consider a component of a vector to be a "name", so we have to replace the component of interest by a "name" (z in the worksheet). Because the vector, x, being passed to the Sensitivity program doesn't originally have a z in it, we need to put it there. The derivative can then be calculated ok. Of course, the resulting expression for the sensitivity will have z everywhere we want the original xn (unless it happens to cancel out, as it does for wo), so we need to use the Substitute command to replace the desired variable when calling the program.

Although z is undefined in the program, this only matters if we try a numerical evaluation of Sensitivity. The symbolic processor doesn't mind.

Alan

You may consider letting the Sensitivity function do the symbolic substitute and simplify.

If you want to retype that function you will have to type the last line with the symbolic eval at some emtpy space in your worksheet and copy it from there (inclusive the "-->0" part) to its final position in the sensitivity function.

Thanks for the suggestions guys- I will study these more. If you have any other insight let me know, and I share anything I figure out.

Here is a Sensitivity function which you can use the same way as you could yours in Mathcad 12 without having to rewrite the functions.

Sorry for late reply- I've been pretty busy this mroning. Well this works as good as anything I've seen and seems like a good workaround. So then essentially the trick is to get MCad to evaluate y symbolically, within the program, prior to trying to do the derivative. I have no idea why that works, other than perhaps it makes everything flattly local in scope within the program and so that makes it happy. Is there a better explanation that I just gave as to why it works?

The straightforward approach would be to pass the expression and the variable in question, let both be parameters of a function which hands them over to the derivative operator. But Mathcad would not accept the derivative variable to be a parameter - it has to be the same once you write it and would not be substituted for the parameter with the same name - thats the reason for your original routine returning zero every time.

So I did it the other way round and chose a dummy variable for the derivative which I guess would nobody choses as variable for his expression and substitute the variable passed to the function for that dummy. So mathcad can make the derivative to the same variable all the time and is happy. After that we have to resubstitute, of course.

Not sure if that's a better explanation 😉

Top Tags