one question about Maxima



Edwin Woollett wrote:
> On June 23, Renzo Del Fabbro <renzodelfabbro at alice.it> wrote:
> ==================================
> Dear Professor Wollett,
>
> I've read your useful pdf on "Maxima by Example",
>
> but I have an trigonometric equation I am NOT able to solve  ...so I'd like 
> to ask you for some help
>
> the equation is:
>
> A(-sin(x)+1)=2Bcos(x)
>
> I've tried to use "solve" with
> ex : A*(-sin(x)+1)=2*B*cos(x);
> solve(ex,x);
>
> but the only solution i got is
> [sin(x)=-(2*cos(x)*B-A)/A]
>
> the only way I've found is the one to use the parametric half-angle tangent 
> trasformation
> please see ... http://www.electroportal.net/phpBB2/viewtopic.php?f=7&p=82212
>
> What is the right way to get the simbolic solution
>
> Thank you very much,
>
> Best regards from Italy,
>
> Renzo Del Fabbro
> BTW: sorry for my terrible english
> ====================
> Hi Renzo,
> Thanks for the great "solve" question.
> >From looking at your link, it appears that
> MathCad had no problem getting an answer.
>
> I have to do a lot of piecework to solve this
> using Maxima (surely there is a simpler way!!).
>
> For what it's worth, my method is to replace both
> cos(x) and sin(x) by their equivalent in terms of tan(x),
> so you end up with an equation in terms of tan(x)
> only. There is no built-in function that I know of
> which does this, so I defined totan(v,e) below.
>
> The equation will then be easier on the eyes if you
> just replace tan(x) by "t" until the end.
>
> We then need to isolate a square root
> of an expression depending on t
> by getting the square root on one side of
> the equation by itself, and then squaring
> the equation (maybe losing a solution in the
> process).
> The function unsquare(q,eqn) does that
> job, and then solve has no problem
> getting one solution.
>
> (%i1) display2d:false$
> (%i2) totan(v,e):= (ratsubst(1/sqrt(1+tan(v)^2),cos(v),e),
>              ratsubst(tan(v)/sqrt(1+tan(v)^2),sin(v),%%))$
> (%i3) unsquare(q,eqn) :=
>          block([p],
>           ratsubst(p,sqrt(q),eqn),
>           first(solve(%%,p)),
>           subst(p = sqrt(q),%%),
>           %%^2 )$
> (%i4) eqn : expand(a*(1-sin(x)) = 2*b*cos(x));
> (%o4) a-a*sin(x) = 2*b*cos(x)
> (%i5) solve(eqn,x);
> (%o5) [sin(x) = -(2*b*cos(x)-a)/a]
> (%i6) totan(x,eqn);
> (%o6) a*(sqrt(tan(x)^2+1)-tan(x))/sqrt(tan(x)^2+1) = 2*b/sqrt(tan(x)^2+1)
> (%i7) ratsubst(t,tan(x),%);
> (%o7) (a*sqrt(t^2+1)-a*t)/sqrt(t^2+1) = 2*b/sqrt(t^2+1)
> (%i8) ratsimp(%*denom(lhs(%))/a);
> (%o8) sqrt(t^2+1)-t = 2*b/a
> (%i9) unsquare(t^2+1,%);
> (%o9) t^2+1 = (a*t+2*b)^2/a^2
> (%i10) solve(%,t);
> (%o10) [t = -(4*b^2-a^2)/(4*a*b)]
> (%i11) subst(t = tan(x),first(%));
> (%o11) tan(x) = -(4*b^2-a^2)/(4*a*b)
>
> Best Wishes to all in Italia,
> Ted Woollett
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
> .
>
>   
Of course, I don't know all the tricks that maxima might bring to bear 
on this, but (in what amounts to more less the same idea that Ed Woolett 
had), one has to translorm this to an algebraic equation somehow. I 
simply used the equation cos(x)^2 = 1 - sin(x)^2. (after squaring the 
equations). It seems that maxima can't handle the equation

solve(A*(1-sin(x) = 2*B*sqrt(1 - sin(x)^2), sin(x)).

so square both sides and get
(%i90) display2d: false;

(%o90) false
(%i91) eq: A*(1-sin(x)) = 2*B*cos(x);

(%o91) (1-sin(x))*A = 2*cos(x)*B
(%i92) eq2: part(eq,1)^2= part(eq,2)^2;

(%o92) (1-sin(x))^2*A^2 = 4*cos(x)^2*B^2
(%i93) eq3: part(%,1) = 4*(1-sin(x)^2)*B^2;

(%o93) (1-sin(x))^2*A^2 = 4*(1-sin(x)^2)*B^2
(%i94) solve(%,sin(x));

(%o94) [sin(x) = -(4*B^2-A^2)/(4*B^2+A^2),sin(x) = 1]

Then, just take the arcsin's .

I tried this equation in both Mathematica and Maple, and they both can 
solve the original equation, and do equations such as
solve( A*(1-t) - 2*B*sqrt(1-t)=0,t)
It is of course disappointing that maxima can't solve even simple 
equations like
sqrt(1-t)=t

%i96) solve(sqrt(1-t)=t,t);

(%o96) [t = sqrt(1-t)]

-sen