I have a set of equations that I want to simplify using a list of rules:

I (ρ12'[t]+ρ21'[t])==ω1 (ρ12[t]-ρ21[t])+ω2 (-ρ12[t]+ρ21[t])+Ω23 (-ρ13[t]+ρ31[t])+Ω13 (-ρ23[t]+ρ32[t])+Ω24 (-ρ14[t]+ρ41[t])+Ω14 (-ρ24[t]+ρ42[t]),
I (ρ13'[t]+ρ31'[t])==Ω23 (-ρ12[t]+ρ21[t])+ω1 (ρ13[t]-ρ31[t])+ω3 (-ρ13[t]+ρ31[t])+Ω14 (-ρ34[t]+ρ43[t]),
I (ρ14'[t]+ρ41'[t])==Ω24 (-ρ12[t]+ρ21[t])+ω1 (ρ14[t]-ρ41[t])+ω4 (-ρ14[t]+ρ41[t])+Ω13 (ρ34[t]-ρ43[t]),
I (ρ23'[t]+ρ32'[t])==Ω13 (ρ12[t]-ρ21[t])+ω2 (ρ23[t]-ρ32[t])+ω3 (-ρ23[t]+ρ32[t])+Ω24 (-ρ34[t]+ρ43[t]),
I (ρ24'[t]+ρ42'[t])==Ω14 (ρ12[t]-ρ21[t])+ω2 (ρ24[t]-ρ42[t])+ω4 (-ρ24[t]+ρ42[t])+Ω23 (ρ34[t]-ρ43[t]),
I (ρ34'[t]+ρ43'[t])==Ω14 (ρ13[t]-ρ31[t])+Ω24 (ρ23[t]-ρ32[t])+Ω13 (ρ14[t]-ρ41[t])+Ω23 (ρ24[t]-ρ42[t])+ω3 (ρ34[t]-ρ43[t])+ω4 (-ρ34[t]+ρ43[t]),
I ρ12'[t]-I ρ21'[t]==ω2 (-ρ12[t]-ρ21[t])+ω1 (ρ12[t]+ρ21[t])+Ω23 (-ρ13[t]-ρ31[t])+Ω13 (ρ23[t]+ρ32[t])+Ω24 (-ρ14[t]-ρ41[t])+Ω14 (ρ24[t]+ρ42[t]),
I ρ13'[t]-I ρ31'[t]==Ω23 (-ρ12[t]-ρ21[t])+ω3 (-ρ13[t]-ρ31[t])+ω1 (ρ13[t]+ρ31[t])+Ω13 (-2 ρ11[t]+2 ρ33[t])+Ω14 (ρ34[t]+ρ43[t]),
I ρ14'[t]-I ρ41'[t]==Ω24 (-ρ12[t]-ρ21[t])+ω4 (-ρ14[t]-ρ41[t])+ω1 (ρ14[t]+ρ41[t])+Ω13 (ρ34[t]+ρ43[t])+Ω14 (-2 ρ11[t]+2 ρ44[t]),
I ρ23'[t]-I ρ32'[t]==Ω13 (-ρ12[t]-ρ21[t])+ω3 (-ρ23[t]-ρ32[t])+ω2 (ρ23[t]+ρ32[t])+Ω23 (-2 ρ22[t]+2 ρ33[t])+Ω24 (ρ34[t]+ρ43[t]),
I ρ24'[t]-I ρ42'[t]==Ω14 (-ρ12[t]-ρ21[t])+ω4 (-ρ24[t]-ρ42[t])+ω2 (ρ24[t]+ρ42[t])+Ω23 (ρ34[t]+ρ43[t])+Ω24 (-2 ρ22[t]+2 ρ44[t]),
I ρ34'[t]-I ρ43'[t]==Ω14 (-ρ13[t]-ρ31[t])+Ω24 (-ρ23[t]-ρ32[t])+Ω13 (ρ14[t]+ρ41[t])+Ω23 (ρ24[t]+ρ42[t])+ω4 (-ρ34[t]-ρ43[t])+ω3 (ρ34[t]+ρ43[t]),
-I ρ11'[t]+I ρ22'[t]==Ω13 (ρ13[t]-ρ31[t])+Ω23 (-ρ23[t]+ρ32[t])+Ω14 (ρ14[t]-ρ41[t])+Ω24 (-ρ24[t]+ρ42[t]),
-I ρ22'[t]+I ρ33'[t]==Ω13 (ρ13[t]-ρ31[t])+Ω23 (2 ρ23[t]-2 ρ32[t])+Ω24 (ρ24[t]-ρ42[t]),
-I ρ22'[t]+I ρ44'[t]==Ω23 (ρ23[t]-ρ32[t])+Ω14 (ρ14[t]-ρ41[t])+Ω24 (2 ρ24[t]-2 ρ42[t])

and the transformation rules are


and its derivative D[rules,t].

I want to simplify the eqns so that it is free of ρ variables.

I tried something like this but not work

ρls = 
   ToExpression["ρ" <> ToString[i] <> ToString[j] <> "[t]"], {i, 
    1, 4}, {j, 1, 4}];
trans[expr_] := expr /. rules /. D[rules, t]
 TransformationFunctions -> {Automatic, trans}, 
 ComplexityFunction -> (LeafCount[#1] + 
     If[And @@ Table[FreeQ[#, x], {x, ρls}], 0, 10^3] &)]
  • $\begingroup$ Why not try Eliminate? $\endgroup$ Jul 14, 2013 at 2:19
  • $\begingroup$ Eliminate seems complicated it a lot rather than simplify it in this case. $\endgroup$ Jul 14, 2013 at 2:34

1 Answer 1


Help others would come up with a more canonic solution, but here is one (brute force) way:

First construct rules that covers both shapes like a-b->c and -a+b->-c

rules1 = rules /. Rule[x_, y_] :> Rule[-x, -y]; 
totRules = Join[rules, rules1, D[rules, t], D[rules1, t]];

then transfer equations to lists to avoid simplify moving terms across the == sign.

transCoff = Transpose[eqns /. x_ == y_ :> {x, y}];

Define a function that simplify each sub-expression, especially to transform terms like a(b*c-b*d) to a*b*(c-d)

mysimplify[expr_] := 
 Module[{expr1 = 
    Collect[expr, {\[Omega]1, \[Omega]2, \[Omega]3, \[Omega]4, \
\[CapitalOmega]13, \[CapitalOmega]14, \[CapitalOmega]23, \
\[CapitalOmega]24, I }, Simplify]},
  Head[expr1] @@ Simplify /@ List @@ expr1

replace the rules

  Map[Collect[#, ToExpression@Table["k" <> ToString@i, {i, 1, 15}], 
     Simplify] &, 
     Simplify[(Collect[#, {\[Omega]1, \[Omega]2, \[Omega]3, \
\[Omega]4, \[CapitalOmega]13, \[CapitalOmega]14, \[CapitalOmega]23, \
\[CapitalOmega]24, I }, Simplify] & /@ transCoff) /. 
       totRules], {2}] /. totRules, {2}], {1}]

and get the result free of rho**

enter image description here


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.