Duc Trung Ha | 18 Apr 2012 23:46
Picon

`to_poly_solve` inconsistency of solutions for equivalent forms of goniometric equations

Hola,

I am sorry if this would come as a completely stupid question but I was really
amazed at this Maxima's behavior:

When I searched for solution of goniometric equation `tan(x) = 1`::

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(%i22) to_poly_solve(tan(x) = 1, x);
                                                   %pi
                                    - 2 %pi %z30 - ---
                                                    2
(%o22)                %union([x = - ------------------])
                                            2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

answer was given to me. On the other hand, when I entered what I consider an
equivalent form of the very same equation:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(%i23) to_poly_solve((sin(x)/cos(x)) - 1 = 0, x);
                                                                   %pi
                                                    - 4 %pi %z40 - ---
                      %pi (8 %z40 + 1)                              2
(%o23) %union(%if(cos(----------------) # 0, [x = - ------------------], 
                             4                              2
                                                                        3 %pi
                                           %union()), [x = 2 %pi %z38 - -----])
                                                                          4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(Continue reading)

Stavros Macrakis | 19 Apr 2012 00:34
Picon
Favicon
Gravatar

Re: `to_poly_solve` inconsistency of solutions for equivalent forms of goniometric equations

You can use trigreduce to convert sin(x)/cos(x) to tan(x).  But I agree that it would be nice if solve(sin(x)/cos(x)=1,x) gave a reasonable answer.  Besides to_poly_solve, another way to handle trigonometric equations more systematically is to put them in exponential form, e.g. rectform(solve(exponentialize(...), ...)).  But the result can be ugly in some cases.

As for to_poly_solve, it's unreasonable to expect in general that equivalent solution sets will be syntactically identical. That is a very hard problem (actually unsolvable in general), though over time, more and more cases will be handled nicely.

            -s

On Wed, Apr 18, 2012 at 17:46, Duc Trung Ha <mathemage <at> gmail.com> wrote:
Hola,I am sorry if this would come as a completely stupid question but I was really amazed at this Maxima's behavior:When I searched for solution of goniometric equation `tan(x) = 1`:: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (%i22) to_poly_solve(tan(x) = 1, x); %pi - 2 %pi %z30 - --- 2(%o22) %union([x = - ------------------]) 2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; answer was given to me. On the other hand, when I entered what I consider an equivalent form of the very same equation:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (%i23) to_poly_solve((sin(x)/cos(x)) - 1 = 0, x); %pi - 4 %pi %z40 - --- %pi (8 %z40 + 1) 2 (%o23) %union(%if(cos(----------------) # 0, [x = - ------------------], 4 2 3 %pi %union()), [x = 2 %pi %z38 - -----]) 4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; output came out. After a brief inspection one can unravel that this solution is in fact identical, however, denoted in very much less elegant & transparentway. This may cause some serious troubles to external programs exploiting Maxima'sfunctionality. For instance, I discovered this issue while using Sage's `solve` command -- original bug can be viewed athttps://groups.google.com/forum/?hl=en&fromgroups#!topic/sage-support/ys3CASZ3vrs Similarly, `solve` also is not capable of recognizing `sin/cos` form of `tan`:: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(%i24) solve(tan(x) = 1, x); solve: using arc-trig functions to get a solution. Some solutions will be lost. %pi(%o24) [x = ---] 4(%i25) solve((sin(x)/cos(x)) - 1 = 0, x); (%o25) [sin(x) = cos(x)];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Is it somehow possible to alter the output for equivalent forms of suchwell-known goniometric functions and thus fix this pseudo-bug? ---Duc Trung Ha _______________________________________________Maxima mailing listMaxima <at> math.utexas.edu http://www.math.utexas.edu/mailman/listinfo/maxima
_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
Barton Willis | 19 Apr 2012 01:02
Favicon

Re: `to_poly_solve` inconsistency of solutions for equivalent forms of goniometric equations

Appending 'simpfuncs = ['expand] helps somewhat; try  to_poly_solve(sin(x)/cos(x) = 1, x, 'simpfuncs = ['expand]);

I made no particular effort to make to_poly_solve (usually) find syntactically identical solution sets
to semantically identical equations. That simply
wasn't a design goal. Although it might seem easy to do write a pre-processor that would do things such as
sin(x)/cos(x) --> tan(x), it's not so
easy to do this in a way that doesn't make some answers much much more complicated, or to do it without
introducing spurious solutions.

 Most days, I'm happy when nobody locates an abject bug in to_poly_solve :)

Thanks for the interest in to_poly_solve.

--bw

________________________________________
Raymond Toy | 19 Apr 2012 02:08
Picon

Re: `to_poly_solve` inconsistency of solutions for equivalent forms of goniometric equations

On 4/18/12 4:02 PM, Barton Willis wrote:
> Appending 'simpfuncs = ['expand] helps somewhat; try  to_poly_solve(sin(x)/cos(x) = 1, x, 'simpfuncs = ['expand]);
> 
> I made no particular effort to make to_poly_solve (usually) find syntactically identical solution sets
to semantically identical equations. That simply
> wasn't a design goal. Although it might seem easy to do write a pre-processor that would do things such as
sin(x)/cos(x) --> tan(x), it's not so
> easy to do this in a way that doesn't make some answers much much more complicated, or to do it without
introducing spurious solutions.

I think it should be this way.  Maxima doesn't automatically convert
sin(x)/cos(x) to tan(x).  I don't think to_poly_solve should magically
do that either.

Although it would be nice for %union and %if were smarter so that %if
would know that cos(%pi/4*(8*%z40+1)) is never zero.  Then we'd just
have %union of two values of x.  And it would be nice to see that they
differ by just an integral multiple of %pi so that they could be
combined into one.

Ray

Gmane