How to factor out favored variables out of an equation?



[Gerhard Zintel , Sun, 23 Oct 2005 23:33:38 +0200]:
> u12: A * p22 + B * u22

  (%i10) u12: - ((((T23 + T21)*T34 + (T22 - T24)* T33 + (- T23 - T21)* T32
   + (T22 - T24)* T31)* u22 + (- p22* T23 - p22* T21)* T44 + (p22* T24 - p22* T22)* T43
   + (p22* T23 + p22* T21)* T42 + (p22* T24 - p22* T22)* T41)* Zo
   + (T22* T34 - T24* T32)* u22 - p22 *T22* T44 + p22* T24* T42)/DENOM;
  
  (%o10) (- (((T23 + T21) T34 + (T22 - T24) T33 + (- T23 - T21) T32
  
   + (T22 - T24) T31) u22 + (- p22 T23 - p22 T21) T44 + (p22 T24 - p22 T22) T43
  
   + (p22 T23 + p22 T21) T42 + (p22 T24 - p22 T22) T41) Zo
  
   - (T22 T34 - T24 T32) u22 + p22 T22 T44 - p22 T24 T42)/DENOM
  (%i11) ratsimp(u12, p22,u22);
  
  (%o11) - (p22 (((- T23 - T21) T44 + (T24 - T22) T43 + (T23 + T21) T42
  
   + (T24 - T22) T41) Zo - T22 T44 + T24 T42)
  
   + u22 (((T23 + T21) T34 + (T22 - T24) T33 + (- T23 - T21) T32
  
   + (T22 - T24) T31) Zo + T22 T34 - T24 T32))/DENOM

Or use coeff if you want A and B directly:

  (%i13) coeff(expand(u12), p22);
  
         T23 T44 Zo   T21 T44 Zo   T24 T43 Zo   T22 T43 Zo   T23 T42 Zo
  (%o13) ---------- + ---------- - ---------- + ---------- - ----------
           DENOM        DENOM        DENOM        DENOM        DENOM
  
                         T21 T42 Zo   T24 T41 Zo   T22 T41 Zo   T22 T44   T24 T42
                       - ---------- - ---------- + ---------- + ------- - -------
                           DENOM        DENOM        DENOM       DENOM     DENOM


HTH,

Albert.

P.S.: It would have been slightly more convenient if you had posted an
      expression for u12 that can be used as Maxima input; e.g., what
      string(u12) gives you.