Derivative of quadratic form in NCAlgebra

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:

$$\frac{d}{dx}x^TAx=(A+A^T)x$$

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

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


which returns

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

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