topic Re: Partial Derivative with Matrix in PTC Mathcad
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604191#M185374
<P>I see a few problems, solving of which - may - help:</P>
<P>1.</P>
<P>You have (x3)^3 in your matrix X, guess that's not what you intended...</P>
<P>2.</P>
<P>X is a matrix (1 row, 4 columns), Vectorization may only work with a vector (4 rows, 1 column). It just might help to transpose X...</P>
<P>3.</P>
<P>Try symbolic evaluation, instead of numeric, and make sure x1 through x4 are not defined when differentiating. Don't define them in the first place, and/or make Partial a function of x1 through x4.</P>
<P> </P>
<P>This is done in Mathcad 11:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LM_20190401_PartialDiff.png" style="width: 534px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/15498iFA7DB4C0E53BE6B2/image-size/large?v=1.0&px=999" title="LM_20190401_PartialDiff.png" alt="LM_20190401_PartialDiff.png" /></span></P>
<P>The last two items:</P>
<P>f is differentiated to X (which as a symbol, is NOT a parameter of f), so the partial derivative is 0.</P>
<P> </P>
<P>Success!</P>
<P>Luc</P>
<P> </P>
<P> </P>Mon, 01 Apr 2019 19:19:29 GMTLucMeekes2019-04-01T19:19:29ZPartial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604187#M185373
<P>I tend to do a lot of partial differentiation in my analyses and how I currently do it is to hard code each partial to their own variable. This tends to clutter my analyses, since I deal with rather large multi-variable equations. I tried being slick today by defining a 1xn matrix (where n is the total number of variables and each element contains the variable names that I need to do partial derivatives on) and performing the partial derivatives on that matrix and vectorizing it. Mathcad doesn't flag an error, but what it's calculating isn't correct. I believe it's trying to do the differentiation on the value of the variable rather than seeing it as a variable by itself, because it always calculates the result as 0. Does anyone know how I can get mathcad to see these as variables or know I better way of going about this? I've attached an example of what I am attempting if it isn't clear in my writing. </P>Mon, 01 Apr 2019 18:35:58 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604187#M185373MrichCD2019-04-01T18:35:58ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604191#M185374
<P>I see a few problems, solving of which - may - help:</P>
<P>1.</P>
<P>You have (x3)^3 in your matrix X, guess that's not what you intended...</P>
<P>2.</P>
<P>X is a matrix (1 row, 4 columns), Vectorization may only work with a vector (4 rows, 1 column). It just might help to transpose X...</P>
<P>3.</P>
<P>Try symbolic evaluation, instead of numeric, and make sure x1 through x4 are not defined when differentiating. Don't define them in the first place, and/or make Partial a function of x1 through x4.</P>
<P> </P>
<P>This is done in Mathcad 11:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LM_20190401_PartialDiff.png" style="width: 534px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/15498iFA7DB4C0E53BE6B2/image-size/large?v=1.0&px=999" title="LM_20190401_PartialDiff.png" alt="LM_20190401_PartialDiff.png" /></span></P>
<P>The last two items:</P>
<P>f is differentiated to X (which as a symbol, is NOT a parameter of f), so the partial derivative is 0.</P>
<P> </P>
<P>Success!</P>
<P>Luc</P>
<P> </P>
<P> </P>Mon, 01 Apr 2019 19:19:29 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604191#M185374LucMeekes2019-04-01T19:19:29ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604192#M185375
<P>1. Correct, that was just a typo</P>
<P>2. I use vectorization on 1xn matrices all the time, it should just go through element by element. Either way, I have tried just transposing it and it still returns 0.</P>
<P>3. I am not following how I'd be able to do that? How would I set up a symbolic expression without defining my variables when I intend to use a matrix for those variables? Also, setting Partials as a function of the variables just flags an error. </P>Mon, 01 Apr 2019 19:15:01 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604192#M185375MrichCD2019-04-01T19:15:01ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604198#M185377
<P>Why would that flag an error (unless you're using an equals, that is, a numeric evaluation, at the end of the definition)?</P>
<P>My opinion: While it is supported, I think it is <STRONG>bad practice</STRONG> to append a numerical evaluation to a definition. We've had more users complaining about errors due to this. It results in errors because the numeric evaluator cannot handle undefined variables. (Important note: the symbolic processor and evaluator has no problems with undefined variables) So: Define, then do the numeric evaluation separately.</P>
<P> </P>
<P>Success!<BR />Luc</P>
<P> </P>Mon, 01 Apr 2019 21:36:08 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604198#M185377LucMeekes2019-04-01T21:36:08ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604219#M185379
<P>I guess this is an example of what you're trying to achieve:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LM_20190401_PartialDiffs.png" style="width: 666px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/15499iA9BBA5F88C45E0D7/image-size/large?v=1.0&px=999" title="LM_20190401_PartialDiffs.png" alt="LM_20190401_PartialDiffs.png" /></span></P>
<P>This was done in Mathcad 11. As far as I can tell, this same is NOT possible in any other version of Mathcad above or below 11, nor in any version of Prime.</P>
<P> </P>
<P>Luc</P>Mon, 01 Apr 2019 21:34:46 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604219#M185379LucMeekes2019-04-01T21:34:46ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604569#M185422
<BLOCKQUOTE><HR /><LI-USER uid="300784"></LI-USER> wrote:<BR />
<P>I tend to do a lot of partial differentiation in my analyses and how I currently do it is to hard code each partial to their own variable. This tends to clutter my analyses, since I deal with rather large multi-variable equations. I tried being slick today by defining a 1xn matrix (where n is the total number of variables and each element contains the variable names that I need to do partial derivatives on) and performing the partial derivatives on that matrix and vectorizing it. Mathcad doesn't flag an error, but what it's calculating isn't correct. I believe it's trying to do the differentiation on the value of the variable rather than seeing it as a variable by itself, because it always calculates the result as 0. Does anyone know how I can get mathcad to see these as variables or know I better way of going about this? I've attached an example of what I am attempting if it isn't clear in my writing. </P>
<HR /></BLOCKQUOTE>
<P>I wanted to try out your file and see if I could help out but I'm using MathCAD 15 and I cannot open mcdx files. I think that it would be best for you to write some of your own vectorization code. I did so for the modular arithmetic operator because the MathCAD programming team at PTC saw fit to ruin the vectorize operator in such a way that MathCAD docs created previously (in MathCAD 14 or earlier) now are erroneous when run using MathCAD 15. I will give it some thought, but it would help if you can export your file to a MathCAD 15 doc and upload that as well. The programming I'm, thinking of should not require that we use the same versions. Another way you can help me help you is to upload a screenshot or a PDF printout of your MathCAD Prime doc. </P>Wed, 03 Apr 2019 13:28:46 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604569#M185422draagekreik2019-04-03T13:28:46ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604574#M185424
<P>There is NO possibility to save a (.mcdx) Prime file in any (real) Mathcad (.mcd or .xmcd) format.</P>
<P>Actually there is also no means to save a Prime 5 file into Prime 4 (or less) format.</P>
<P>But you can install the free Prime Express (version 5 if you have a 64 bit OS, or any older version if you have a 32-bit OS) and open a Prime file on this forum. As a first time user/evaluator you can get the first 30 days of full functionality, after which the really cool features are gone.</P>
<P> </P>
<P>Success!<BR />Luc</P>Wed, 03 Apr 2019 13:45:29 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604574#M185424LucMeekes2019-04-03T13:45:29ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604576#M185426
<BLOCKQUOTE><HR /><LI-USER uid="14826"></LI-USER> wrote:<BR />
<P>There is NO possibility to save a (.mcdx) Prime file in any (real) Mathcad (.mcd or .xmcd) format.</P>
<P>Actually there is no means to save a Prime 5 file into Prime 4 (or less) format.</P>
<P>But you can install the free Prime Express (version 5 if you have a 64 bit OS, or any older version if you have a 32-bit OS) and open a Prime file on this forum. As a first time user/evaluator you can get the first 30 days of full functionality, after which the really cool features are gone.</P>
<P> </P>
<P>Success!<BR />Luc</P>
<HR /></BLOCKQUOTE>
<P>I don't want Prime or any of its variations. It is too different from the versions of MathCAD I use, and I don't want more clutter on my computers. I don't plan to use prime, I just want to see his doc, so a PDF will be preferred. </P>Wed, 03 Apr 2019 13:45:55 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604576#M185426draagekreik2019-04-03T13:45:55ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604577#M185427
<P>What is one "cool feature" of prime that I am missing by using MathCAD 15 or earlier?</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<BLOCKQUOTE><HR /><LI-USER uid="14826"></LI-USER> wrote:<BR />
<P>There is NO possibility to save a (.mcdx) Prime file in any (real) Mathcad (.mcd or .xmcd) format.</P>
<P>Actually there is also no means to save a Prime 5 file into Prime 4 (or less) format.</P>
<P>But you can install the free Prime Express (version 5 if you have a 64 bit OS, or any older version if you have a 32-bit OS) and open a Prime file on this forum. As a first time user/evaluator you can get the first 30 days of full functionality, after which the really cool features are gone.</P>
<P> </P>
<P>Success!<BR />Luc</P>
<HR /></BLOCKQUOTE>
<P> </P>Wed, 03 Apr 2019 13:47:15 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604577#M185427draagekreik2019-04-03T13:47:15ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604580#M185428
<P>Here you go:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LM_20190403_PartDiff.png" style="width: 501px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/15568iCA133806469A983A/image-size/large?v=1.0&px=999" title="LM_20190403_PartDiff.png" alt="LM_20190403_PartDiff.png" /></span></P>
<P>Success!</P>
<P>Luc</P>Wed, 03 Apr 2019 13:52:15 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604580#M185428LucMeekes2019-04-03T13:52:15ZRe: Partial Derivative with Matrix
https://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604799#M185441
<P>Mixed units in vectors and arrays. That's a feature of Prime, not supported by Mathcad (15 and below).</P>
<P>But that wasn't one of the 'cool features' that I was referring to.</P>
<P>If you install Prime without abought license you can get 30 days of full (licensed) functioning.</P>
<P>After that you lose the 'cool features':</P>
<P>symbolics, programming, solve blocks, referenced worksheets, and a lot of functions like:</P>
<P>polyroots, rkfixed, statistic distribution functions and a lot more, including mean, Re and Im.</P>
<P>With respect to that list of functions, some mending is possible, see <A href="https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216#M185378" target="_blank" rel="noopener">https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216#M185378</A>.</P>
<P> </P>
<P>Luc</P>Thu, 04 Apr 2019 16:30:21 GMThttps://community.ptc.com/t5/PTC-Mathcad/Partial-Derivative-with-Matrix/m-p/604799#M185441LucMeekes2019-04-04T16:30:21Z