one question about Maxima



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