Suppose that we have an expression (expr in the code below) and replace a long term with a new parameter (K).
For a simple example;
expr = (5 I (Subscript[a, 1] - Sqrt[
Subscript[a, 1] (6 + Subscript[a, 1])]) x)/(3 y \[Alpha]);
newVariables = {(Subscript[a, 1] - Sqrt[
Subscript[a, 1] (6 + Subscript[a, 1])]) -> K};
expr //. newVariables
After some calculations, we derive a new expression (expr2 in the code below). What is the best and most reliable method for automatically back-substituion K to expr2? (instead of manually applying expr2//.K->(Subscript[a, 1] - Sqrt[Subscript[a, 1] (6 + Subscript[a, 1])])
)
expr2 = K^2 + 5 I K x
expr2 /. Reverse /@ newVariables
? $\endgroup$