Quoting rene kaelin <renekaelin at gmx.ch>:
> Thank you Leo, so far so good.
>
> Dear Leo
>
> Thanks for your hint. The problem now is the following:
>
> sol:solve(x^2=9,x)
> gives
> [x = -3,x = 3]
>
> I only need the righthandsides of the solutions. They get saved in
> an array like
> [-3,3]
map(rsh,sol);
>
> (I do it this way: for ... rs:rhs(sol[i]), a:append(a,[rs])...)
>
> The output with
>> load(to_poly_solver);
>> to_poly_solve(abs(x)=9,x);
> is
> %union([x = -9],[x = 9])
>
> How can I generate an array like the one above that only contains
> the righthandsolutions?
sol : to_poly_solve(...);
sol : subst(%union="[",sol);
map(rhs,flatten(sol));
In fact, it is often useful to have both rhs and lhs from
solutions, because subst lets you do things like:
eq : abs(x)-9;
sol : tps(eq,x);
/* Now check solutions: */
map(lambda([xeq],subst(xeq,eq)),sol);
where:
tps([l]):=subst(%union="[",apply(to_poly_solve,l));
In fact, instead of using rhs, you can use
map(lambda([s],subst(s,x)),sol);
to pick out just the x values of each solution.
Please cc your replies to the Maxima email list.
Regards,
Leo
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.