Problems (different) with solve and %solve



see: http://www.math.utexas.edu/pipermail/maxima/2012/031303.html

Example. Solve trigonometric equation
(%i1) eq:(sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x))-
(2*cos(x)*sin(x) -sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x))=0$

 To finding all solutions of trigonometric equation eq
from interval [a, b) we define function "trigsolve":

(%i2) load(to_poly_solve)$
Loading maxima-grobner $Revision: 1.6 $ $Date: 2009-06-02 07:49:49 $

(%i3) trigsolve(eq,a,b):=block([a1,s,ats,i],
algebraic:true,
%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(%%)
)$

(%i4) f1:atan(x);
(%o4) atan(x)
(%i5) cos(%);
(%o5) 1/sqrt(x^2+1)
(%i6) f2:acos(%);
(%o6) acos(1/sqrt(x^2+1))

 If x>0 then f1=f2. If x<0 then f1=-f2. We define function for converting
atan to acos:
(%i7) atan_to_acos(x):=block(cos(x),if x>0 then acos(%%) else -acos(%%));
(%o7) atan_to_acos(x):=block(cos(x),if x>0 then acos(%%) else -acos(%%))

(%i8) T:atan(2^(3/2))=atan_to_acos(atan(2^(3/2)));
(%o8) atan(2^(3/2))=acos(1/3)

(%i9) sol:trigsolve(eq,0,2*%pi);
(%o9) {0,%pi,%pi-atan(2^(3/2)),atan(2^(3/2))+%pi}
(%i10) S:subst(T,%);
(%o10) {0,%pi,%pi-acos(1/3),acos(1/3)+%pi}

 Then all solutions of eq is: x=a+2*%pi*k, where a - any from S, k - any
integer

Happy New Year !

Aleksas Domarkas