Question about to_poly_solve



see *Karl-Dieter Crisman*  question
http://www.math.utexas.edu/pipermail/maxima/2013/033251.html

Example. Solve trigonometric equation
(%i1) sin(x)+cos(x)=cos(2*x);
(%o1) sin(x)+cos(x)=cos(2*x)

(%i2) trigexpand(%);
(%o2) sin(x)+cos(x)=cos(x)^2-sin(x)^2
(%i3) L:lhs(%)-rhs(%);
(%o3) sin(x)^2+sin(x)-cos(x)^2+cos(x)
(%i4) wxplot2d([L], [x,0,2*%pi])$
(%t4)  << Graphics >>

 In interval [0, 2*%pi) equation has four solutions.
We will find them.

(%i5) factor(L)=0;
(%o5) (sin(x)-cos(x)+1)*(sin(x)+cos(x))=0

 We  convert this equation to set two equations eq1 and eq2.

(%i6) eq1:sin(x)-cos(x)+1=0;
(%o6) sin(x)-cos(x)+1=0
(%i7) to_poly_solve([eq1], [x]);
to_poly_solve: to_poly_solver.mac is obsolete; I'm loading
to_poly_solve.mac instead.
Loading maxima-grobner $Revision: 1.6 $ $Date: 2009-06-02 07:49:49 $
(%o7) %union([x=2*%pi*%z10-%pi/2],[x=2*%pi*%z8])

(%i8) eq2:sin(x)+cos(x)=0;
(%o8) sin(x)+cos(x)=0
(%i9) to_poly_solve([eq2], [x]);
(%o9) %union([x=2*%pi*%z20+(3*%pi)/4],[x=-(%pi/2-4*%pi*%z22)/2])

 For solving trigonometric equations in interval [a, b) we define function
"trigsolve"

(%i10) trigsolve(eq,a,b):=block([a1,s,ats,i],
algebraic:true,
to_poly_solve([eq], [x],
'simpfuncs = ['rootscontract,'expand,'radcan, 'nicedummies]),
s:makelist(rhs(part(%%,k)[1]),k,1,length(%%)),
ats:[],
for i:1 thru length(s) do
(makelist(ev(s[i],%z0=k),k,-10,10),
ats:append(ats,%%)),
sublist(ats,lambda([e],e>=a and e<b)),
sort(%%),
setify(%%)
)$

(%i11) S1:trigsolve(eq1,0,2*%pi);
(%o11) {0,(3*%pi)/2}
(%i12) S2:trigsolve(eq2,0,2*%pi);
(%o12) {(3*%pi)/4,(7*%pi)/4}
(%i13) S:union(S1,S2);
(%o13) {0,(3*%pi)/4,(3*%pi)/2,(7*%pi)/4}

(%i14) sol:listify(S);
(%o14) [0,(3*%pi)/4,(3*%pi)/2,(7*%pi)/4]

 Answer:
x = a+2*%pi*k, where a any from sol, k any integer

best regards

Aleksas D