The command piecewise has come up in different 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.
At first 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.
I believe that this bug was fixed 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