follow-up on solving a set of symbolic equations



The function assoc may do what you want.

(C1) display2d : false;
(D1) FALSE

(C2) eqs : [a + b*c=1,b - a*c=0, a+b=5];
(D2) [b*C+a = 1,b-a*C = 0,b+a = 5]
(C3) sol : solve(eqs,[a,b,c]);

(D3) [[a = (25*SQRT(79)*%I+25)/(6*SQRT(79)*%I-34),
       b = (5*SQRT(79)*%I+5)/(SQRT(79)*%I+11),C = (SQRT(79)*%I+1)/10],
      [a = (25*SQRT(79)*%I-25)/(6*SQRT(79)*%I+34),
       b = (5*SQRT(79)*%I-5)/(SQRT(79)*%I-11),C = -(SQRT(79)*%I-1)/10]]

/* extract the value of a from the first solution */

(C4) assoc(a,sol[1]);
(D4) (25*SQRT(79)*%I+25)/(6*SQRT(79)*%I-34)

/* extract the value of a from the secod solution */

(C5) assoc(a,sol[2]);
(D5) (25*SQRT(79)*%I-25)/(6*SQRT(79)*%I+34)

/* extract the value of b from the second solution */

(C6) assoc(b,sol[2]);
(D6) (5*SQRT(79)*%I-5)/(SQRT(79)*%I-11)
(C7) 


(C7) describe("assoc");

 0: ASSOC :(maxima.info)Definitions for Lists.
 1: ASSOC_LEGENDRE_P :Definitions for Orthogonal Polynomials.
 2: ASSOC_LEGENDRE_Q :Definitions for Orthogonal Polynomials.
 3: DOTASSOC :Definitions for Matrices and Linear Algebra.
 4: LASSOCIATIVE :Definitions for Simplification.
 5: RASSOCIATIVE :Definitions for Simplification.
Enter n, all, none, or multiple choices eg 1 3 : 0;
Info from file C:/maxima/Maxima/info/maxima.info:
 - Function: ASSOC (exp)
     This function searches for the key in the left hand side of the
     input list of the form [x,y,z...] where each of the list elements
     is a expression of a binary operand and 2 elements.  For example
     x=1, 2^3, [a,b] etc.  The key checked againts the first operand
     and and returns the second operand if the key is found.  If the
     key is not found it either returns the default value if supplied or
     false.
(D7) FALSE
(C8) 
Barton


Paul Spitalny <pauls@cascadelinear.com>
Sent by: maxima-admin@www.ma.utexas.edu
03/12/2003 12:18 PM

 
        To:     maxima@www.ma.utexas.edu
        cc: 
        Subject:  [Maxima] follow-up on solving a set of symbolic equations


First, thanks for all the help. As a first time user I can say that having 

the input and output lines in maxima indexed by c1,c2   d1,d2  can be a 
definite pitfall. It certainly was to me since I had a coefficient called 
"c1" .  I suppose it would be nice to index the in and out lines 
differently, but, now that I understand what's going-on I can work around 
it. One persons email (Thank you Barton Willis) mentioned the re-assigment 

of the in and out line indexing and that looks like a good way to go for 
me.

And, then the follow-up question. If I solve a set of equations like the 
example in the documentation (from "Introduction to MACSYMA"
) below:

(C6) a + b*c=1;

(D6)                              b C + a = 1
(C7) b - a*c=0;

(D7)                              b - a C = 0
(C8) a+b=5;

(D8)                               b + a = 5
(C9) solve([d6,d7,d8],[a,b,c]);

            25 SQRT(79) %I + 25      5 SQRT(79) %I + 5      SQRT(79) %I + 
1
(D9) [[a = -------------------, b = -----------------, C = 
---------------],
            6 SQRT(79) %I - 34       SQRT(79) %I + 11             10

             25 SQRT(79) %I - 25      5 SQRT(79) %I - 5        SQRT(79) %I 
- 1
        [a = -------------------, b = -----------------, C = - 
---------------]]
             6 SQRT(79) %I + 34       SQRT(79) %I - 11               10


How can I separately access the variables a,b and c ?



Thanks

Paul