<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Matrix, partial derivate and 'for' loop in Mathcad</title>
    <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026143#M218049</link>
    <description>&lt;P&gt;Using "submatrix" as show above instead of the nested for-loops makes it a tiny bit shorter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is version which makes calculating the full 4x4 matrix a little bit easier using the gradient (Nabla) operator.&lt;/P&gt;
&lt;P&gt;Could not find a way to eliminate the repetition of the second derivatives.&lt;/P&gt;
&lt;P&gt;The approach does not make advantage of the symmetry of second derivatives (theorem of Schwarz, Clairot, Young).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1753284232918.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126051i14B3885FB5DE00C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Werner_E_0-1753284232918.png" alt="Werner_E_0-1753284232918.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Prime 11 sheet attached&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jul 2025 15:25:46 GMT</pubDate>
    <dc:creator>Werner_E</dc:creator>
    <dc:date>2025-07-23T15:25:46Z</dc:date>
    <item>
      <title>Matrix, partial derivate and 'for' loop</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026044#M218038</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;[using MP 11].&lt;/P&gt;&lt;P&gt;I'd like to build up a matrix (&lt;EM&gt;n&lt;/EM&gt; x &lt;EM&gt;n&lt;/EM&gt;, square and symmetric), with the help of a loop.&lt;/P&gt;&lt;P&gt;The problem is that each of the terms in this matrix is the second partial derivate of a function of &lt;EM&gt;n&lt;/EM&gt; variables . I couldn't find a way to include this in a program (Match of the variable and the loop counter)&lt;/P&gt;&lt;P&gt;My goal is to program in a way that I don't get any "red square" or "this variable is undefined" in the layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the enclosed sheet, the terms of the matrix are colour-highlighted. (The context is civil engineering, and the determination of the buckling factor of a column, here with a varying cross-section and varying compressive force).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eager to see any insightful idea! Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 09:52:00 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026044#M218038</guid>
      <dc:creator>CLE_MW</dc:creator>
      <dc:date>2025-07-23T09:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, partial derivate and 'for' loop</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026064#M218039</link>
      <description>&lt;P&gt;Prime capabilities are quite limited when it comes to matrix functions and derivatives with respect to vector arguments.&lt;/P&gt;
&lt;P&gt;So it looks to me that you already have found the most suitable workaround.&lt;/P&gt;
&lt;P&gt;The red error stems from the numeric engine and does not affect the ability of symbolic calculations, as you found out.&lt;/P&gt;
&lt;P&gt;To avoid the red error&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1753268333117.png" style="width: 282px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126016i0D21327664CAB5C0/image-dimensions/282x55?v=v2" width="282" height="55" role="button" title="Werner_E_0-1753268333117.png" alt="Werner_E_0-1753268333117.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You would have to define a function in ALL five arguments&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_1-1753268366888.png" style="width: 489px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126017i75ADFDC132BDAEE0/image-dimensions/489x66?v=v2" width="489" height="66" role="button" title="Werner_E_1-1753268366888.png" alt="Werner_E_1-1753268366888.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;as Primes numeric can't 'know' that function Pi is defined in a way so that all variables except k.EV cancel/fall out.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_2-1753268494734.png" style="width: 365px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126018iDDC779C881E81A19/image-dimensions/365x63?v=v2" width="365" height="63" role="button" title="Werner_E_2-1753268494734.png" alt="Werner_E_2-1753268494734.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You could use symbolic evaluation to come around this annoyance&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_3-1753268535884.png" style="width: 579px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126019i816623A82A2F208B/image-dimensions/579x68?v=v2" width="579" height="68" role="button" title="Werner_E_3-1753268535884.png" alt="Werner_E_3-1753268535884.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But the crucial point is that in order to automatically create your matrix we need the 0 and 1 in the variable name to be matrix indices.&amp;nbsp;And this is where Prime imposes a serious limitation, as Prime does not allow matrix elements to be defined as functions—not if we have to define the matrix itself as a function (as would be necessary here).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_4-1753268779912.png" style="width: 562px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126020i9EAE4D8C2AD02C0B/image-dimensions/562x66?v=v2" width="562" height="66" role="button" title="Werner_E_4-1753268779912.png" alt="Werner_E_4-1753268779912.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Prim moans that it does not understand the syntax. And, no, Prime won't even allow to type the matrix indices right after the function name "M" and in front of the argument parentheses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I guess&amp;nbsp; that you will have to stay with the way you already had chosen. You may hide the definitions with the red errors in a collapsed region if this is acceptable.&lt;/P&gt;
&lt;P&gt;BTW, you could create the final matrix also with the "submatrix" function, as M.C already is the full 4x4 matrix.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_6-1753269760780.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126028iE92D22DD01B52B7C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Werner_E_6-1753269760780.png" alt="Werner_E_6-1753269760780.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The red error can be avoided if you follow the definition by a symbolic evaluation&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_7-1753269837125.png" style="width: 791px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126029i39404B9260127B84/image-dimensions/791x87?v=v2" width="791" height="87" role="button" title="Werner_E_7-1753269837125.png" alt="Werner_E_7-1753269837125.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In case you need to see the matrix and its determinant for certain values of k.EV and would like to use numeric evaluation (maybe because of unit simplification), you may (re)define M.calc as a function (symbolic inline evaluation is mandatory here):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_8-1753270043842.png" style="width: 793px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126030i6A5397D08F835268/image-dimensions/793x361?v=v2" width="793" height="361" role="button" title="Werner_E_8-1753270043842.png" alt="Werner_E_8-1753270043842.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another idea could be to create an auxiliary function with a vector argument "u"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_5-1753268998363.png" style="width: 415px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126021iB9786D2454A349C3/image-dimensions/415x76?v=v2" width="415" height="76" role="button" title="Werner_E_5-1753268998363.png" alt="Werner_E_5-1753268998363.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and use this function in a program with nested for-loops to define the matrix without having to predefine the various matrix elements M.C.&lt;BR /&gt;But here we encounter another limitation of Prime as Prime won't allow to define a derivative with respect to a vector element.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I can't think of a more elegant and straight forward method to automatically create that matrix (actually a function of k.EV) based on the dimension variable n.t.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 11:27:45 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026064#M218039</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2025-07-23T11:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, partial derivate and 'for' loop</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026088#M218041</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/66934"&gt;@Werner_E&lt;/a&gt;&amp;nbsp; for quick reply and pointing the limits of MP11, You spotted well that "crucial point".&lt;/P&gt;&lt;P&gt;I conclude there's no "elegant" way to combine the partial derivation + the loops + the matrices. However, you pointed me to idea of a straightforward definition of the matrix as follows :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CLE_MW_1-1753273478802.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126033iFA3F44CA316F0557/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CLE_MW_1-1753273478802.png" alt="CLE_MW_1-1753273478802.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Including the symbolic evaluation to avoid the red tags.&lt;/P&gt;&lt;P&gt;Then I'll use a "for" loop to resize it as per the targeted level of precision, which works.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CLE_MW_2-1753273515533.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126034i30EAF261FAAEE6DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CLE_MW_2-1753273515533.png" alt="CLE_MW_2-1753273515533.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not as short as I would have wished, but fair enough for me.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 12:25:44 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026088#M218041</guid>
      <dc:creator>CLE_MW</dc:creator>
      <dc:date>2025-07-23T12:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, partial derivate and 'for' loop</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026143#M218049</link>
      <description>&lt;P&gt;Using "submatrix" as show above instead of the nested for-loops makes it a tiny bit shorter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is version which makes calculating the full 4x4 matrix a little bit easier using the gradient (Nabla) operator.&lt;/P&gt;
&lt;P&gt;Could not find a way to eliminate the repetition of the second derivatives.&lt;/P&gt;
&lt;P&gt;The approach does not make advantage of the symmetry of second derivatives (theorem of Schwarz, Clairot, Young).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1753284232918.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126051i14B3885FB5DE00C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Werner_E_0-1753284232918.png" alt="Werner_E_0-1753284232918.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Prime 11 sheet attached&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 15:25:46 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026143#M218049</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2025-07-23T15:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, partial derivate and 'for' loop</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026147#M218050</link>
      <description>&lt;P&gt;And here finally the shortest approach. Unfortunately at the cost of calculation time. Maybe using the Nabla operator isn't so efficient.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_1-1753285697588.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126052i3A027C821A232760/image-size/large?v=v2&amp;amp;px=999" role="button" title="Werner_E_1-1753285697588.png" alt="Werner_E_1-1753285697588.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Prime 11 sheet attached&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 15:49:13 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026147#M218050</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2025-07-23T15:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, partial derivate and 'for' loop</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026257#M218068</link>
      <description>&lt;P&gt;Waow, that's efficient! Thanks &lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/66934"&gt;@Werner_E&lt;/a&gt;&amp;nbsp;. I will test this on larger problem to check how longer is calculation time. Thanks for pointing me to the Nabla operator.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 07:28:49 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Matrix-partial-derivate-and-for-loop/m-p/1026257#M218068</guid>
      <dc:creator>CLE_MW</dc:creator>
      <dc:date>2025-07-24T07:28:49Z</dc:date>
    </item>
  </channel>
</rss>

