I installed the NCAlgebra package in the hope that it contains enough rules for symbolic work with most branch-matrix expressions.

<< NC`;
<< NCAlgebra`;
NCGrad[X^T ** A ** X, X]

The result obtained did not suit me.

A X + A T X

First, the package does not work with transposition. And secondly, it does not distinguish between vectors and matrices. What do I need to consider when working with it and how to get the correct result in the form:



1 Answer 1


As noted in the documentation of NCGrad:

IMPORTANT: The expression returned by NCGrad is the transpose or the
adjoint of the standard gradient. This is done so that no assumption
on the symbols are needed. The calculated expression is correct even
if symbols are self-adjoint or symmetric.

What you are looking for is therefore

tp[NCGrad[tp[X] ** A ** X, X]]

which returns

A ** X + tp[A] ** X

  • $\begingroup$ Thanks, I'll look into it. $\endgroup$
    – dtn
    May 10 at 5:47
  • $\begingroup$ Oh, I have one more little question. How, using the NCAlgebra, to differentiate an expression of the following form: Transpose[X].A[X].X $\endgroup$
    – dtn
    May 19 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.