#### 7.14 bizarre convert to piecewise (8.11.99)

##### 7.14.1 Ron Grimmer

The command piecewise has come up in diﬀerent ways recently and I would like to ask about my experience with this command.

I am attemping to teach a class on Maple and am perplexed about using the command convert with piecewise.

I have run into several problems when converting max to piecewise. In particular,

> f:=max(x^5,x^2);

2   5
f := max(x , x )

> g:=convert(f,piecewise);

{     2
{    x             x <= 1
g := {
{    2    5
{ 2 x  - x         1 < x



Several examples of this type were discovered. Even more interesting is that sometimes a convert could be done with the correct answer being returned but after a restart an incorrect answer would be returned. One can even oscillate between the correct and an incorrect answer.

This happens on the student version release 4 in our lab and also on my release 5.0 Professional version.

##### 7.14.2 Robert Israel (10.11.99)

At ﬁrst I thought this bug had been corrected in Release 5.1, but some experimentation revealed that it still happens (sometimes). The factor that it only happens sometimes would tend to indicate that it depends on the arbitrarily-chosen ordering of some set or expression. I’ve traced the bug into unitstep/simpout, which consistently does the following:

> unitstep/simpout(unitstep(x^2 - x^5), x);

unitstep(x) + unitstep(-x) + unitstep(x - 1)



Here it seems "unitstep(x)" is supposed to be 1 if x > 0 and 0 if x <= 0. So unitstep(x^2 - x^5) should be 1 if x < 0 or 0 < x < 1, 0 otherwise, which could be

       unitstep(x) + unitstep(-x) + unitstep(1 - x) - 1



But Maple’s answer is incorrect for x > 1.

On the other hand,

> unitstep/simpout(unitstep(x^5 - x^2), x);

unitstep(x-1)



which is correct.

##### 7.14.3 Herman Jaramillo (10.11.99)

I believe that this bug was ﬁxed in version 5.1. Here is what I get:

f := max(x^5, x^2);

> g := convert(f,piecewise);

{  2
{ x         x <= 1
g := {
{  5
{ x         1 < x