# Rearrange an expression according to known items

I have this expresion:

$\qquad q_{aft}=-i\,f \left(a_2\right){}^{\dagger }+i\,f \left(a_2\right){}^{\dagger }-\left(a_1\right){}^{\dagger }-a_1$

Defining

$\qquad q_{0_1}=a_1+(a_1)^\dagger$

and

$\qquad p_{0_2}=-i\,(a_2-(a_2)^\dagger)$

straightforwardly you can see that

$\qquad q_{aft}=-(q_{0_1}+fp_{0_2})$

Is there any way to make this identification and manipulation with Mathematica? Or more generaly, is there some kind of Collect function that allow to rearrange an expresion with items previously defined like $p_{0_2}$ and $q_{0_1}$?

• Are you working with traditional form expressions in your Mathematica notebook? Commented Mar 18, 2016 at 0:47
• Yes, but i'm working with this package: homepage.cem.itesm.mx/lgomez/quantum @m_goldberg Commented Mar 18, 2016 at 0:59

I think i've found one solution to my trouble: [PolynomialReduce] do exactly what i wanted. Given this relations,

b1= -a1 - I f SuperDagger[a2]
b2=-a2 - I SuperStar[f] SuperDagger[a1]
q1b = Refine[1/Sqrt[2] (b1 + SuperDagger[b1]), f \[Element] Reals]


Using [PolynomialReduce] we get

   PolynomialReduce[q1b, {q1a, p2a, p1a, q2a}, {a1, SuperDagger[a1], a2,SuperDagger[a2]}]
={{-1, -f, 0, 0}, 0}


As i expected... But new problems arise! If i write

    PolynomialReduce[q2b, {q1a, p2a, p1a, q2a}, {a1, SuperDagger[a1], a2,SuperDagger[a2]}]={{I f, -I, 0, 0}, -I Sqrt[2] f SuperDagger[a1] -
Sqrt[2] SuperDagger[a2]}


Unfortunately, Mathemathica represents the reduction in terms of the first terms (q1aand p2ain this case) giving a non-null remainder. However if i write this

   PolynomialReduce[q2b, {q2a, p1a, p2a, q2a}, {a1, SuperDagger[a1], a2,
SuperDagger[a2]}]={{-1, -f, 0, 0}, 0}


So i have a new question: Is there any way to demand a null-remainder(if it exists) providing to Mathemathica a group of polynomials to work with?