Mathematica Asked on May 18, 2021
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?
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]}} *)
Correct answer by Michael E2 on May 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP