Derivative of a trace with Hadamard division












1












$begingroup$


I am trying to solve the derivative:



$$frac{partial Tr,[AX'(X oslash B)]}{partial X},$$



where $oslash$ is the symbol used for the Hadamard division (or element-wise division) and A is a square matrix. I think that the derivative should be:



$$(XA + XA') oslash B,$$



but I couldn't find a reference to double check it and I recently started doing similar calculations. Any hints?










share|cite|improve this question









$endgroup$

















    1












    $begingroup$


    I am trying to solve the derivative:



    $$frac{partial Tr,[AX'(X oslash B)]}{partial X},$$



    where $oslash$ is the symbol used for the Hadamard division (or element-wise division) and A is a square matrix. I think that the derivative should be:



    $$(XA + XA') oslash B,$$



    but I couldn't find a reference to double check it and I recently started doing similar calculations. Any hints?










    share|cite|improve this question









    $endgroup$















      1












      1








      1





      $begingroup$


      I am trying to solve the derivative:



      $$frac{partial Tr,[AX'(X oslash B)]}{partial X},$$



      where $oslash$ is the symbol used for the Hadamard division (or element-wise division) and A is a square matrix. I think that the derivative should be:



      $$(XA + XA') oslash B,$$



      but I couldn't find a reference to double check it and I recently started doing similar calculations. Any hints?










      share|cite|improve this question









      $endgroup$




      I am trying to solve the derivative:



      $$frac{partial Tr,[AX'(X oslash B)]}{partial X},$$



      where $oslash$ is the symbol used for the Hadamard division (or element-wise division) and A is a square matrix. I think that the derivative should be:



      $$(XA + XA') oslash B,$$



      but I couldn't find a reference to double check it and I recently started doing similar calculations. Any hints?







      linear-algebra derivatives self-learning






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Jan 6 at 5:04









      merchmerch

      1082




      1082






















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

          Let's use a colon to denote the trace/Frobenius product, i.e.
          $$eqalign{A:B={rm Tr}(A^TB)}$$
          Properties of the trace give rise to rules for rearranging terms in a Frobenius product, such as
          $$eqalign{
          A:B &= B:A cr&= A^T!:!B^T cr
          A:BC &= B^TA:C cr&= AC^T:B cr
          }$$

          Also note that the Hadamard product commutes with itself and the Frobenius product
          $$eqalign{
          Aodot B &= Bodot A cr
          A:(Bodot C) &= (Aodot C):B cr&= (Bodot A):C cr
          }$$

          Instead of $B$ let's use its Hadamard inverse, and while we're at it, let's define a few other matrices.
          $$eqalign{
          C &= 1oslash B cr
          Y &= X^TA cr
          Z &= Xodot C = Xoslash B cr
          }$$

          to write the cost function. Then find its differential and gradient.
          $$eqalign{
          phi &= XA^T:Xodot C cr&= Y:Z cr
          dphi
          &= Z:dY + Y:dZ cr
          &= Z:dX,A^T + Y:dXodot C cr
          &= ZA:dX + Yodot C:dX cr
          &= (ZA + Yodot C):dX cr
          frac{partialphi}{partial X}
          &= ZA + Yodot C cr
          &= (Xoslash B)A + (XA^T)oslash B cr
          }$$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
            $endgroup$
            – merch
            Jan 6 at 19:22












          • $begingroup$
            @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
            $endgroup$
            – greg
            Jan 6 at 21:15










          • $begingroup$
            Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
            $endgroup$
            – merch
            Jan 6 at 23:47










          • $begingroup$
            @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
            $endgroup$
            – greg
            Jan 7 at 3:54













          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3063510%2fderivative-of-a-trace-with-hadamard-division%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1












          $begingroup$

          Let's use a colon to denote the trace/Frobenius product, i.e.
          $$eqalign{A:B={rm Tr}(A^TB)}$$
          Properties of the trace give rise to rules for rearranging terms in a Frobenius product, such as
          $$eqalign{
          A:B &= B:A cr&= A^T!:!B^T cr
          A:BC &= B^TA:C cr&= AC^T:B cr
          }$$

          Also note that the Hadamard product commutes with itself and the Frobenius product
          $$eqalign{
          Aodot B &= Bodot A cr
          A:(Bodot C) &= (Aodot C):B cr&= (Bodot A):C cr
          }$$

          Instead of $B$ let's use its Hadamard inverse, and while we're at it, let's define a few other matrices.
          $$eqalign{
          C &= 1oslash B cr
          Y &= X^TA cr
          Z &= Xodot C = Xoslash B cr
          }$$

          to write the cost function. Then find its differential and gradient.
          $$eqalign{
          phi &= XA^T:Xodot C cr&= Y:Z cr
          dphi
          &= Z:dY + Y:dZ cr
          &= Z:dX,A^T + Y:dXodot C cr
          &= ZA:dX + Yodot C:dX cr
          &= (ZA + Yodot C):dX cr
          frac{partialphi}{partial X}
          &= ZA + Yodot C cr
          &= (Xoslash B)A + (XA^T)oslash B cr
          }$$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
            $endgroup$
            – merch
            Jan 6 at 19:22












          • $begingroup$
            @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
            $endgroup$
            – greg
            Jan 6 at 21:15










          • $begingroup$
            Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
            $endgroup$
            – merch
            Jan 6 at 23:47










          • $begingroup$
            @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
            $endgroup$
            – greg
            Jan 7 at 3:54


















          1












          $begingroup$

          Let's use a colon to denote the trace/Frobenius product, i.e.
          $$eqalign{A:B={rm Tr}(A^TB)}$$
          Properties of the trace give rise to rules for rearranging terms in a Frobenius product, such as
          $$eqalign{
          A:B &= B:A cr&= A^T!:!B^T cr
          A:BC &= B^TA:C cr&= AC^T:B cr
          }$$

          Also note that the Hadamard product commutes with itself and the Frobenius product
          $$eqalign{
          Aodot B &= Bodot A cr
          A:(Bodot C) &= (Aodot C):B cr&= (Bodot A):C cr
          }$$

          Instead of $B$ let's use its Hadamard inverse, and while we're at it, let's define a few other matrices.
          $$eqalign{
          C &= 1oslash B cr
          Y &= X^TA cr
          Z &= Xodot C = Xoslash B cr
          }$$

          to write the cost function. Then find its differential and gradient.
          $$eqalign{
          phi &= XA^T:Xodot C cr&= Y:Z cr
          dphi
          &= Z:dY + Y:dZ cr
          &= Z:dX,A^T + Y:dXodot C cr
          &= ZA:dX + Yodot C:dX cr
          &= (ZA + Yodot C):dX cr
          frac{partialphi}{partial X}
          &= ZA + Yodot C cr
          &= (Xoslash B)A + (XA^T)oslash B cr
          }$$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
            $endgroup$
            – merch
            Jan 6 at 19:22












          • $begingroup$
            @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
            $endgroup$
            – greg
            Jan 6 at 21:15










          • $begingroup$
            Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
            $endgroup$
            – merch
            Jan 6 at 23:47










          • $begingroup$
            @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
            $endgroup$
            – greg
            Jan 7 at 3:54
















          1












          1








          1





          $begingroup$

          Let's use a colon to denote the trace/Frobenius product, i.e.
          $$eqalign{A:B={rm Tr}(A^TB)}$$
          Properties of the trace give rise to rules for rearranging terms in a Frobenius product, such as
          $$eqalign{
          A:B &= B:A cr&= A^T!:!B^T cr
          A:BC &= B^TA:C cr&= AC^T:B cr
          }$$

          Also note that the Hadamard product commutes with itself and the Frobenius product
          $$eqalign{
          Aodot B &= Bodot A cr
          A:(Bodot C) &= (Aodot C):B cr&= (Bodot A):C cr
          }$$

          Instead of $B$ let's use its Hadamard inverse, and while we're at it, let's define a few other matrices.
          $$eqalign{
          C &= 1oslash B cr
          Y &= X^TA cr
          Z &= Xodot C = Xoslash B cr
          }$$

          to write the cost function. Then find its differential and gradient.
          $$eqalign{
          phi &= XA^T:Xodot C cr&= Y:Z cr
          dphi
          &= Z:dY + Y:dZ cr
          &= Z:dX,A^T + Y:dXodot C cr
          &= ZA:dX + Yodot C:dX cr
          &= (ZA + Yodot C):dX cr
          frac{partialphi}{partial X}
          &= ZA + Yodot C cr
          &= (Xoslash B)A + (XA^T)oslash B cr
          }$$






          share|cite|improve this answer











          $endgroup$



          Let's use a colon to denote the trace/Frobenius product, i.e.
          $$eqalign{A:B={rm Tr}(A^TB)}$$
          Properties of the trace give rise to rules for rearranging terms in a Frobenius product, such as
          $$eqalign{
          A:B &= B:A cr&= A^T!:!B^T cr
          A:BC &= B^TA:C cr&= AC^T:B cr
          }$$

          Also note that the Hadamard product commutes with itself and the Frobenius product
          $$eqalign{
          Aodot B &= Bodot A cr
          A:(Bodot C) &= (Aodot C):B cr&= (Bodot A):C cr
          }$$

          Instead of $B$ let's use its Hadamard inverse, and while we're at it, let's define a few other matrices.
          $$eqalign{
          C &= 1oslash B cr
          Y &= X^TA cr
          Z &= Xodot C = Xoslash B cr
          }$$

          to write the cost function. Then find its differential and gradient.
          $$eqalign{
          phi &= XA^T:Xodot C cr&= Y:Z cr
          dphi
          &= Z:dY + Y:dZ cr
          &= Z:dX,A^T + Y:dXodot C cr
          &= ZA:dX + Yodot C:dX cr
          &= (ZA + Yodot C):dX cr
          frac{partialphi}{partial X}
          &= ZA + Yodot C cr
          &= (Xoslash B)A + (XA^T)oslash B cr
          }$$







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited Jan 6 at 21:13

























          answered Jan 6 at 16:26









          greggreg

          7,7951821




          7,7951821












          • $begingroup$
            Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
            $endgroup$
            – merch
            Jan 6 at 19:22












          • $begingroup$
            @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
            $endgroup$
            – greg
            Jan 6 at 21:15










          • $begingroup$
            Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
            $endgroup$
            – merch
            Jan 6 at 23:47










          • $begingroup$
            @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
            $endgroup$
            – greg
            Jan 7 at 3:54




















          • $begingroup$
            Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
            $endgroup$
            – merch
            Jan 6 at 19:22












          • $begingroup$
            @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
            $endgroup$
            – greg
            Jan 6 at 21:15










          • $begingroup$
            Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
            $endgroup$
            – merch
            Jan 6 at 23:47










          • $begingroup$
            @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
            $endgroup$
            – greg
            Jan 7 at 3:54


















          $begingroup$
          Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
          $endgroup$
          – merch
          Jan 6 at 19:22






          $begingroup$
          Thanks. Would you please clarify what do you mean with two colons in a row? (e.g., the right-hand side for $dphi$)
          $endgroup$
          – merch
          Jan 6 at 19:22














          $begingroup$
          @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
          $endgroup$
          – greg
          Jan 6 at 21:15




          $begingroup$
          @merch Hopefully the introduction of the matrices $(Y, Z)$ have clarified things.
          $endgroup$
          – greg
          Jan 6 at 21:15












          $begingroup$
          Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
          $endgroup$
          – merch
          Jan 6 at 23:47




          $begingroup$
          Thank you, it simplifies it a little. I understand the final result. However, I am still struggling with part of your notation. How do you re-write $Z:dY+Y:dZ$ via the trace operator?
          $endgroup$
          – merch
          Jan 6 at 23:47












          $begingroup$
          @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
          $endgroup$
          – greg
          Jan 7 at 3:54






          $begingroup$
          @merch From the 1st equation above, the Frobenius products correspond to $${Z:dY + Y:dZ = {rm Tr}(Z^TdY+Y^TdZ)}$$
          $endgroup$
          – greg
          Jan 7 at 3:54




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3063510%2fderivative-of-a-trace-with-hadamard-division%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          Npm cannot find a required file even through it is in the searched directory