how extract value from list?



El mi?, 20-09-2006 a las 10:48 +0200, Johan Ekh escribi?:
> Hi all!
> I have a simple question regarding "solve".
> Using solve results in a list e.g. [x=a,x=b].
> How can I assign the results to a variable, i.e.
> I want to do someting like,
> 
> x: solve(expr,x);
> 
> and then use x in further calculations.
> 
> I cannot figure this out, please help me.
> 
> Regards,
> Johan

(%i1) z: solve(x^2+x+1);
                   sqrt(3) %i + 1      sqrt(3) %i - 1
(%o1)       [x = - --------------, x = --------------]
                         2                   2
(%i2) z[1];
                             sqrt(3) %i + 1
(%o2)                  x = - --------------
                                   2
(%i3) rhs(z[1]);
                           sqrt(3) %i + 1
(%o3)                    - --------------
                                 2
(%i4) rhs(z[2]);
                          sqrt(3) %i - 1
(%o4)                     --------------
                                2

-- 
Mario Rodriguez Riotorto
www.biomates.net