0
$\begingroup$

I'm trying to compute derivatives of the form D[Tr[A],x] for A being a large polynomial in a single variable $x$. Mathematica always gets me the result with formal derivatives of the trace itself, that I don't want (Note that Tr[A]^2, Tr[A.A], ... all can happen). I was thinking, is there a way of extracting all the variables x from the linear function Tr? Say that, for example, A = B + x C, is it possible to tell Mathematica to first write the trace as Tr[B] + x Tr[C] and then take the derivative?

$\endgroup$
5
  • 1
    $\begingroup$ Please show a sample of the matrix $A$ as Mathematica code. $\endgroup$ Commented Mar 4 at 3:30
  • $\begingroup$ TR works on matrices. Tr[A] where A is a polynomial in x is not defined. $\endgroup$ Commented Mar 4 at 11:26
  • $\begingroup$ Hi all, thanks for your answers. $A$ here looks like $A = a + b x + c x^2$, where $a,b,c$ are unspecified matrices (now that I think about it, should I tell Mathematica that these are actually matrices? How do I do so without specifying them?) and $x$ is just a variable. $\endgroup$ Commented Mar 4 at 13:11
  • 3
    $\begingroup$ Are you trying to do something like this? $\endgroup$ Commented Mar 4 at 15:21
  • $\begingroup$ Since so far OP hasn't replied to ydd's comment, I'd say the question requires further clarification thus off-topic for now. Please edit your question to make it clearer. (Showing an example of expected input and output would be helpful. ) The question will be reopened once it meets the standard of the site. $\endgroup$ Commented Oct 10 at 11:50

1 Answer 1

2
$\begingroup$

Since OP couldn't provide an example, I provided one myself. For such a concrete matrix, Mathematica works just as expected:

SeedRandom[12345];
A = RandomInteger[{-5, 5}, {3, 3, 3}] . {1, x, x^2}; 
A // MatrixForm

0

MatrixForm /@ CoefficientList[A, x]

1

D[Tr[A], x]

3

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.