How to get only real solutions?



On Wed, Dec 12, 2012 at 10:30 AM, Piet van Oostrum <piet at vanoostrum.org>wrote:

> Barton Willis <willisb at unk.edu> writes:
>
> >>(%i31) esolve(eq, x) := block(numer:true, defrule(r1, %i, 0),
> >> expand(to_poly_solve(eq, x)), part(apply1(%%, r1),1))$
> >
> > (a) There is no guarantee  that the first solution returned by
> to_poly_solve is real.
> >
> > (b) The function esolve globally sets numer to true; I would guess that
> you would like to change
> >      the definition of esolve to something like block([numer : true],
> .....
> >
> > (c) Every time esolve is executed, the rule r1 is re-created. Actually,
> instead of a rule, esolve
> > could
> >     simply substitute 0 for %i.
>
> Thanks for these observations. I am a beginner in maxima.
>
> > Keepin' it real isn't easy:
> >
> >   (%i3) esolve(x/sin(x)=0,x);
> >   part: fell off the end.
> >
> >   (%i4) esolve(x^2+1,x);
> >   (%o4) [x=0]
>
> Actually I use it only for equations of the form A+Be^Ct = D, that's why
> I called it *e*solve.
>

In that case:

esolve(a,b,c,d) := log((d-a)/b)/c



> --
> Piet van Oostrum <piet at vanoostrum.org>
> WWW: http://pietvanoostrum.com/
> PGP key: [8DAE142BE17999C4]
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>