Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

eqns={
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])+ω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],ρ23[t]+ρ32[t]->k4[t],ρ24[t]+ρ42[t]->k5[t],ρ34[t]+ρ43[t]->k6[t],ρ12[t]-ρ21[t]->k7[t],ρ13[t]-ρ31[t]->k8[t],ρ14[t]-ρ41[t]->k9[t],ρ23[t]-ρ32[t]->k10[t],ρ24[t]-ρ42[t]->k11[t],ρ34[t]-ρ43[t]->k12[t],-ρ11[t]+ρ22[t]->k13[t],-ρ22[t]+ρ33[t]->k14[t],-ρ22[t]+ρ44[t]->k15[t],ρ33[t]-ρ11[t]->k13[t]+k14[t],ρ44[t]-ρ11[t]->k13[t]+k15[t]}

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 = 
 Flatten@Table[
   ToExpression["ρ" <> ToString[i] <> ToString[j] <> "[t]"], {i, 
    1, 4}, {j, 1, 4}];
trans[expr_] := expr /. rules /. D[rules, t]
Simplify[eqns, 
 TransformationFunctions -> {Automatic, trans}, 
 ComplexityFunction -> (LeafCount[#1] + 
     If[And @@ Table[FreeQ[#, x], {x, ρls}], 0, 10^3] &)]
share|improve this question
    
Why not try Eliminate? –  Oleksandr R. Jul 14 '13 at 2:19
    
Eliminate seems complicated it a lot rather than simplify it in this case. –  xslittlegrass Jul 14 '13 at 2:34
add comment

1 Answer

up vote 1 down vote accepted

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

Apply[Equal, 
 Transpose@
  Map[Collect[#, ToExpression@Table["k" <> ToString@i, {i, 1, 15}], 
     Simplify] &, 
   Map[mysimplify, 
     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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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