solving simple systems of equations manually



Hi,

This is a newbie question, I am still learning Maxima.  I know a bit
of CL.

I have the following system:

/* equations */
eq1: r*U = b+lambda_u*(W0-U);
eq2: r*W0 = w0 + lambda_e*(W1-W0) + sigma*(U-W0);
eq3: r*W1 = p + sigma*(U-W1);
eq4: W0-U=beta*(W1-U);

The unknowns are W0, W1, U, and w0.  I am interested in the expression

  (w0-b)/(w1-w0)

I could just use solve() and simplify, but the
problem has a specific structure and I want to see the steps -- I am
using this problem to gain intuition about a more complex one.

Using economic intuition about this problem, we want to write
everything in terms of S=W1-U.  So I did the following:

/* utility functions */
mysub(expression,equation) := subst(rhs(equation),lhs(equation),expression);
flip(equation) := rhs(equation)=lhs(equation); /* exchange sides */
solve1(equation,variable) := solve(equation,variable)[1]; /* solve and return the eq */

eqS: S=W1-U; /* define surplus */
eqW1fromS: solve1(eqS,W1);
eqW0fromS: mysub(solve1(eq4,W0),eqW1fromS);

sub2(expression) := ratsimp(mysub(mysub(expression,eqW1fromS),eqW0fromS));

eq1s: sub2(eq1);
eq2s: sub2(eq2);
eq3s: sub2(eq3);

eq2f: eq2s-eq1s;

The last one has w0-b, but I am stuck.  I would appreciate advice on
the following:

1. How can I extract the term w0-b from the last expression?  Or,
equivalently, how can I group coefficients of S on one side?

2. I am sure that I am doing a lot of things non-idiomatically.  Style
advice, pointers to tutorials about this etc would be very welcome.

3. sub2 could be done more generally with reduce.  I tried 

:lisp (defmspec $mysuball (expression equations) (reduce #'$mysub equations \:initial-value expression))

but it doesn't work as expected, it returns a list of expressions.

Best,

Tamas