1
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ Note that I chose a simple example above that does not contain products such as e.g. tr[a]tr[a^2], but the solution should also be able to understand that prefactors of tr[a^2] and prefactors of tr[a]tr[a^2] are independent. $\endgroup$
    – Pxx
    Mar 31, 2021 at 12:10
  • $\begingroup$ Try Coefficient[...,{tr[a], tr[a^2], tr[a]^2}] to get the equations $\endgroup$ Mar 31, 2021 at 12:29
  • $\begingroup$ @UlrichNeumann I don' t think that works for the case I mentioned in my comment. Try Coefficient[2 tr[a] tr[a^2], {tr[a], tr[a^2], tr[a] tr[a^2]}]. $\endgroup$
    – Pxx
    Mar 31, 2021 at 12:32

1 Answer 1

1
$\begingroup$

Generic advice: N is a protected system symbol with a built-in meaning; don't use it. In fact, avoid all capital letters and starting your symbol names with a capital.

The functionality you are looking for is given by SolveAlways. You have to have an equation that can be put in the form of a polynomial in the "variables"; here they are {tr[a], tr[a^2], $n}, where $n is my substitute for Sqrt[N].

SolveAlways[(2 tr[a]^2)/
    N == α[1] + (Sqrt[2] tr[a] α[2])/
     Sqrt[N] - ((N^2 - 2 tr[a^2]) α[3])/(Sqrt[
        2] N) - ((N - 2 tr[a]^2) α[4])/(Sqrt[2] N) /. N -> $n^2,
 {tr[a], tr[a^2], $n}]

(*  {{α[1] -> 1, α[2] -> 0, α[3] -> 0, α[4] -> Sqrt[2]}}  *)
$\endgroup$
1
  • $\begingroup$ Awesome, thanks! $\endgroup$
    – Pxx
    Apr 1, 2021 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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