7.129 Bug in solve in Maple V.5 (3.3.99)

7.129.1 Norbert Van den Bergh
7.129.2 Joe Riel (4.3.99)
7.129.3 Helmut Kahovec (5.3.99)
7.129.4 Bob Wright (8.3.99)

7.129.1 Norbert Van den Bergh

It looks as if we have a new Release 5.1 BUG (I only tried it under the Windows 95 version). Try this:

>restart: 
>solve(z*cos(a)^2+x*sin(a)*cosa+x^2,x);
 

The answer is what you would expect ... Now go for this one:

>restart; 
>solve(z*cos(a)^2+x*sin(a)*cos(a)+x^2,x);
 

It is corrected with Maple 6. (U. Klein)

7.129.2 Joe Riel (4.3.99)

I’m not sure I’d classify this as a bug (the null answer isn’t wrong) so much as a deficiency. R4 could get this one, but neither R5 nor R5.1 can. However, frontend will permit a solution, and a slightly nicer one then R4 using only solve:

> eq := z*cos(a)^2+x*sin(a)*cos(a)+x^2: 
> frontend(solve,[eq,{x}],[{},{x,z}]); 
                                      2 
  {x = (- 1/2 sin(a) + 1/2 sqrt(sin(a)  - 4 z)) cos(a)}, 
                                            2 
        {x = (- 1/2 sin(a) - 1/2 sqrt(sin(a)  - 4 z)) cos(a)}
 

7.129.3 Helmut Kahovec (5.3.99)

Yes, it is a bug: Maple converts \(\cos (a)\) into an expression of \(\sin (a)\) and thus introduces a RootOf expression. During the computation, Maple tests the left-hand side of the equation for a polynomial with coefficients of type rational or algnum, and this test returns false:

> restart; 
> eq:=z*cos(a)^2+x*sin(a)*cos(a)+x^2=0; 
 
                            2                      2 
              eq := z cos(a)  + x sin(a) cos(a) + x  = 0 
 
> solve({eq},{x});
 

eqns2 is an intermediate representation of eq:

> eqns2:={z-z*_S01^2+x*_S01*RootOf(_Z^2+_S01^2-1)+x^2}; 
 
                         2                   2       2         2 
     eqns2 := {z - z _S01  + x _S01 RootOf(_Z  + _S01  - 1) + x }
 

Now the type check mentioned earlier returns false:

> type(subs(I='RootOf(_Z^2+1)',eqns2[1]),polynom({rational,algnum})); 
 
                                false
 

However, if you replace \(\cos (a)\) with cosa then there will be no RootOf expression and the type check returns true:

> eq:=z*cos(a)^2+x*sin(a)*cosa+x^2=0; 
 
                             2                    2 
               eq := z cos(a)  + x sin(a) cosa + x  = 0 
 
> solve({eq},{x}); 
 
                       ... result skipped ... 
 
> eqns2:={z-z*_S01^2+x*_S01*cosa+x^2}; 
 
                                  2                  2 
              eqns2 := {z - z _S01  + x _S01 cosa + x } 
 
> type(subs(I='RootOf(_Z^2+1)',eqns2[1]),polynom({rational,algnum})); 
 
                                 true
 

As a workaround I suggest using frontend(): in this case there is no RootOf expression at all and you get a neat result without any simplification:

> eq:=z*cos(a)^2+x*sin(a)*cos(a)+x^2=0; 
 
                            2                      2 
              eq := z cos(a)  + x sin(a) cos(a) + x  = 0 
 
> frontend(solve,[{eq},{x}],[{`+`,`*`},{x}]); 
 
                                      2 
  {x = (- 1/2 sin(a) + 1/2 sqrt(sin(a)  - 4 z)) cos(a)}, 
 
                                            2 
        {x = (- 1/2 sin(a) - 1/2 sqrt(sin(a)  - 4 z)) cos(a)}
 

7.129.4 Bob Wright (8.3.99)

Apparently the same happens in Release V.0: but see below:

solve(z*cos(a)^2+x*sin(a)*cos(a)+x^2,x);
 

no solution found. But look at this:

> solve(z*cos(a)^2+x*sin(b)*cos(a)+x^2,x); 
 
                                 2 
  (- 1/2 sin(b) + 1/2 sqrt(sin(b)  - 4 z)) cos(a), 
 
                                       2 
        (- 1/2 sin(b) - 1/2 sqrt(sin(b)  - 4 z)) cos(a)