On 12/13/2012 10:38 AM, Enrique Perez-Terron wrote:
> realp(x) := if imagpart(x) = 0 then true else false$
> solution: solve(...)$
> sublist(solution, realp)
Thanks for that idea.
I think realp() needs a change:
(%i8) realp(x) := if imagpart(rhs(x)) = 0 then true else false$
(%i9) solutions: solve( exp(-10*t/50175) = 1/2);
(%o9) [t = 10035*log(-sqrt(2)),t = 10035*log(2)/2]
(%i10) sublist(solutions, realp);
(%o10) [t = 10035*log(2)/2]
and it does not work for to_poly_solve
(%i19) solutions: %solve( exp(-10*t/50175) = 1/2, t);
(%o19) %union([t = (20070*%i*%pi*%z13+10035*log(2))/2])
(%i20) sublist(first(args(solutions)), realp);
(%o20) []
In any case, by changing the units used for t one can make the length of
the list obtained by solve grow to thousands taking too long for solve
to finish. Of course, this is a trivial example that could be solve by
taking log on both sides of the equation but this is only to illustrate
a problem that arises in more complicated cases.
Regards,
Jaime