Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
PTC Mathcad Prime 8.0.0.0
I have a function that depends on several variables, and I want to compute the partial derivative with respect to each variable and store the results in a matrix.
For example, the variables R1,R2,R3,R4,R5,R6,R7, and R8 are known.
F(R1, R2, R3, R4, R5, R6, R7, R8)=R5*R4/(R3+R4) +(R7-R8/2)*R1+R6/R2
I would like to create a matrix A_dif such that:
A_dif(1)= dF/dR1
A_dif(2)= dF/dR2
………………..
A-dif (8)=dF/dR8
Can this be done so we do not need to repeat the operation 8 times.
You can. It's a lot of typing!.
I had this as a solution, but I was expecting something that uses a for‑statement, because sometimes my functions have 100 variables. I would like to automate the process.
A function with 100 arguments?
So these arguments better are provided via an input vector instead of listing them individually.
As an example the same demo function with three arguments as posted before
P.S.: I am not sure if the gradient operator already exists in Prime 8, though.
EDIT: I just check and it seems that the gradient operator was not present in Prime 8
See: Solved: Representing Del Operations [curl(u), div(u), grad... - PTC Community
The operator actually was introduced in Prime 9.
Any chance you can upgrade your version of Prime?
This is what the Nabla/Gradient operator is to be used for. Can be used symbolically but also numerically
Hi Werner,
I have PTC Mathcad Prime 8.0.0.0 which does not have this operator that you suggested.
I have done the same way what was suggested by Fred but I want no to copy and pass 100 time if I have bigger function.
@TG_14487572 wrote:
Hi Werner,
I have PTC Mathcad Prime 8.0.0.0 which does not have this operator that you suggested.
I have done the same way what was suggested by Fred but I want no to copy and pass 100 time if I have bigger function.
Yes, I later noticed that the gradient operator was only introduced in Prime 9. See also my second answer above and the link provided there.
I'm afraid that there will be no convenient option in your version of Prime, as Prime does not provide all the necessary features—it does not allow vector elements as derivative variables and, unlike the old, genuine Mathcad, it does not allow symbolic evaluations within a program.
So if you don't have the option of upgrading to a newer version of Prime, it will probably be difficult or rather impossible to achieve.
As a supplement to what was shown earlier: If partial differentiation is to be performed for all variables, it is not necessary to list all variables individually in the Nabla operator; instead, the corresponding placeholder can be left empty in this case:
Hi Werner,
my colleagues had used gradient before but after upgrading to PTC Mathcad Prime 8.0.0.0 it disappeared. I never expect that a new version will not open an old one and will have smaller capability, but ... C'est la vie!
Thank you for your time!
@TG_14487572 wrote:
Hi Werner,
my colleagues had used gradient before but after upgrading to PTC Mathcad Prime 8.0.0.0 it disappeared. I never expect that a new version will not open an old one and will have smaller capability, but ... C'est la vie!
Thank you for your time!
To the best of my knowledge no Prime version below version 9 provided gradient operator.
But of course legacy Mathcad did. But switching from legacy Mathcad to Prime is not an upgrade but rather a downgrade in usability and functionality 😞
OK, I gave it a try and here is my best approach to automatically get all partial derivatives without using the gradient operator.
The method sure has its drawbacks and if ever possible you should switch to Prime 9 or higher where the gradient operator is available.
The attached file is in Prime 11 format as I don't have Prime 8 installed. However, you can certainly follow it based on the screenshot.
Hope it works OK in Prime 8 and can be of help.
Werner's file converted to Prime 8. I had to take the gradients out, as they wouldn't convert.
Success!
Luc
