Maxima : Getting a value from 'Solve'




On Mon, 7 Feb 2011, Lut Mentz wrote:

< Hi,
< ?
< I want to extract from the output of Solve() an executable string to make an assignment. For instance
< ?
< (%i1) solve([gz], [accz]);
< (%o1) [accz=-(Fz*Vt^2*F^4-Fz*Vz^2-2*Fy*Vy*Vz+Fz*Vy^2)/F]
< (%i2)? %[1];
< (%o2) accz=-(Fz*Vt^2*F^4-Fz*Vz^2-2*Fy*Vy*Vz+Fz*Vy^2)/F
< ?
< I'd like to turn the last output to "accz: -(Fz*Vt^2*F^4-Fz*Vz^2-2*Fy*Vy*Vz+Fz*Vy^2)/F" and execute it.
< ?
 
 Here is another way:

 solve(....);
 map(lambda([t],lhs(t)::rhs(t)),%);

 This will bind accz. If there are no solutions, that's ok; if there
 are multiple solutions, this binds accz to the last solution in the
 list.

 The :: operator is like : except that both sides are evaluated before
 binding.

 Leo
-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.