I have complicated expressions involving traces, for example tr[a]
, tr[a^2]
, tr[a]^2
, tr[a]tr[a^2]
, and so on. I would like to solve equations where the prefactors of the traces are automatically matched. Consider the following simple example:
$$\frac{2}{N} (\text{tr}\, a)^2 = \alpha_1 + \alpha_2 \sqrt{\frac{2}{N}} \text{tr}\, a - \alpha_3 \frac{(N^2-2\, \text{tr}\, (a^2))}{\sqrt{2}N} - \alpha_4 \frac{(N-2\, (\text{tr}\, a)^2)}{\sqrt{2}N}\,, \tag{1}$$
for which the solution is:
$$\alpha_1 = 1\,, \quad \alpha_2 = 0\,, \quad \alpha_3 = 0\,, \quad \alpha_4 = \sqrt{2}\,. \tag{2}$$
However the naive application of Solve
does not produce this solution:
Solve[(2 tr[a]^2)/N == \[Alpha][1] + (Sqrt[2] tr[a] \[Alpha][2])/Sqrt[N] - ((N^2 - 2 tr[a^2]) \[Alpha][3])/(Sqrt[2] N) - ((N - 2 tr[a]^2) \[Alpha][4])/(Sqrt[2] N), {\[Alpha][1], \[Alpha][2], \[Alpha][3], \[Alpha][4]}]
(*{{\[Alpha][4] -> (2 Sqrt[2] tr[a]^2)/(-N + 2 tr[a]^2) + (Sqrt[2] N \[Alpha][1])/(N - 2 tr[a]^2) + (2 Sqrt[N] tr[a] \[Alpha][2])/(N - 2 tr[a]^2) - ((N^2 - 2 tr[a^2]) \[Alpha][3])/(N - 2 tr[a]^2)}}*)
How can I tell Solve
to match the traces, or alternately to produce solutions independent of the traces?
tr[a]tr[a^2]
, but the solution should also be able to understand that prefactors oftr[a^2]
and prefactors oftr[a]tr[a^2]
are independent. $\endgroup$Coefficient[...,{tr[a], tr[a^2], tr[a]^2}]
to get the equations $\endgroup$Coefficient[2 tr[a] tr[a^2], {tr[a], tr[a^2], tr[a] tr[a^2]}]
. $\endgroup$