[Maxima] solving simple systems of equations manually
tkpapp at gmail.com
Thu Mar 29 08:51:01 CDT 2012
This is a newbie question, I am still learning Maxima. I know a bit
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);
The unknowns are W0, W1, U, and w0. I am interested in the expression
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); /* solve and return the eq */
eqS: S=W1-U; /* define surplus */
sub2(expression) := ratsimp(mysub(mysub(expression,eqW1fromS),eqW0fromS));
The last one has w0-b, but I am stuck. I would appreciate advice on
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.
More information about the Maxima