Question about to_poly_solve



Try setting algexact to true:

  (%i1) sol : to_poly_solve(eq : sin(x)+cos(x)=cos(2*x),x),algexact : true$

If you enjoy huge messy symbolic answers, look at sol. I do not know of a way to simplify sol to something that is publishable.

Check the solutions numerically

  (%i2) eq : lhs(eq)-rhs(eq)$

Reindex new variables starting with zero:

  (%i3) sol : trigexpand(nicedummies(sol))$
  (%i4) map(lambda([s],  float(rectform(subst(s,eq)))),sol);

Oh, the %zXXX variables get in the way

  (%o4) %union(0.0,2.2204460492503131*10^-16-1.0*cos(2.0*(6.283185307179586*%z0-0.78539816339745)),%i*(3.1401849173675493*10^-16-4.4408920985006252*10^-16*sin(2.0*  (6.283185307179586*%z1+2.356194490192345)))-1.0*cos(2.0*(6.283185307179586*%z1+2.356194490192345))-2.2204460492503131*10^-16,1.0-1.0*cos(2.0*(6.283185307179586*%z2-4.71238898038469)))

Say uncle and set each %zXXX variable to zero

  (%i5) subst([%z0=0,%z1=0,%z2=0],%);
  (%o5) %union(-6.1230317691118863*10^-17,0.0,2.0,7.581077015868174*10^-16*%i-3.8353651851674719*10^-17)

OK fine--the residules are small multiples of the binary64 machine epsilon.

--Barton
________________________________
From: Karl-Dieter Crisman [kcrisman at gmail.com]
Sent: Thursday, June 13, 2013 10:16
Cc: Barton Willis; maxima at math.utexas.edu
Subject: Re: [Maxima] Question about to_poly_solve

 Yes, it does call algsys, but usually the approximate methods end up looking like decimals, I haven't noticed these fractions before.   I guess I was just surprised that this particular one went crazy, since it ends up being sin+cos=0 and cos-sin=1.  Thanks.


On Thu, Jun 13, 2013 at 10:25 AM, Stavros Macrakis <macrakis at alum.mit.edu<mailto:macrakis at alum.mit.edu>> wrote:
It looks like to_poly_solve is calling algsys, which is using approximate methods and thus giving bogus results.

You might try:

         sols: solve( [ trigexpand( sin(x)+cos(x)=cos(2*x) ), sin(x)^2+cos(x)^2=1 ], [sin(x),cos(x)] )

To get explicit results (rather than sin(x)=...), you can then use %solve:

          map(lambda([eq],%solve(eq,x)), sols);

          -s



Essentially doing the same thing with directly gives me the following.  I think I see what is happening here within Sage, thanks for the help.

(%i3) sols:solve(trigexpand( sin(x)+cos(x)=cos(2*x)),x);
(%o3)              [sin(x) = - cos(x), sin(x) = cos(x) - 1]
(%i6) load(to_poly_solve);

Loading maxima-grobner $Revision: 1.6 $ $Date: 2009-06-02 07:49:49 $
(%o6) /Users/.../sage-5.9.rc1/local/share/maxima/5.29.1/sha\
re/to_poly_solve/to_poly_solve.mac
(%i8) map(lambda([eq],%solve(eq,x)), sols);
                                               %pi
                                               --- - 4 %pi %z28
                                3 %pi           2
(%o8) [%union([x = 2 %pi %z26 + -----], [x = - ----------------]),
                                  4                   2
                                                                         %pi
                              %union([x = 2 %pi %z36], [x = 2 %pi %z38 - ---])]
                                                                          2



                                                                          2