[Maxima] solvetrigwarn

robert.marik marik at mendelu.cz
Sun Feb 28 17:11:58 CST 2010

```Raymond Toy <toy.raymond <at> gmail.com> writes:

>
> On 2/28/10 4:04 PM, Barton Willis wrote:
> > -----maxima-bounces <at> math.utexas.edu wrote: -----
> >
> >
> >> is it possible to check, whether a warning
> >> "using arc-trig functions to get a solution. Some solutions will be lost"
> >> has been printed in the last 'solve' call?
> >>
> > Without changing the Maxima function mtell, I don't know of a way to
> > do this. The Maxima function mtell prints the message but does not
> > save it (unlike an error message that is saved). Maybe you could
> > insert a few lines into mtell to do what you would like it to do. If
> > you aren't a CL progammer, hacking mtell is a good excuse to learn :)

Thanks, I'll try it :)

> Why not just replace the call to mtell with something like (setf
> \$solvetrigwarn t), being sure the set \$solvetrigwarn to nil at the
> beginning of solve.
>
> But it would be much better, of course, to teach solve to return all the
> roots.  How does sage do the trick  solve([sin(2*x-%pi/6)=y,
> y=1/2],[x,y])?  When I do this in maxima, I get no solutions.  (That
> seems like a bug too.)

If Sage does not get solution from solve command, it tries to_poly_solve
automatically.

this is the relevant code:

from sage.calculus.calculus import maxima
m = maxima(f)

try:
s = m.solve(variables)
except: # if Maxima gave an error, try its to_poly_solve
try:
s = m.to_poly_solve(variables)
except TypeError, mess: # if that gives an error, raise an error.
if "Error executing code in Maxima" in str(mess):
raise ValueError, "Sage is unable to determine whether the
system %s can be solved for %s"%(f,a
rgs)
else:
raise

if len(s)==0: # if Maxima's solve gave no solutions, try its to_poly_solve
try:
s = m.to_poly_solve(variables)
except: # if that gives an error, stick with no solutions
s = []

Robert

```