# collect variables buried in an expression

Suppose we have

```
var('Pmean,alpha,M,Nb,D,H,c');
sol3= [M == 1/4*(2*D*Nb*Pmean - (D*H*alpha + D*H)*c)/((alpha + 1)*c)]
```

How would you collect the coefficients of D*H in the second term?

Specifically, once the collection is done, how could the factored version of the expression be returned?

I know from using other computer algebra systems that it can be taken all the way to this:

```
M==1/4*D*(-H+(2*Nb*Pmean)/((1+alpha)*c))
```