Question: substitution and assuming

The attached file demonstrates that a substitution into a piecewise function appears (sometimes) to execute the wrong half of the function.

If I use "assuming" instead of substitution, the assumption appears to get through to the piecewise function, but only sometimes.

I don't understand why this happens. Can anyone clarify what is going on? See below.

Thank you.

 

______________________________________________________________

 

Why does T2c give a division by zero??
Why does the error message in T1c and T1e suggest that the assumption never got through to the procedure, while case T1d proves the opposite?
T1d and T2c appear to be equivalent ways of saying the same thing, but one works, the other doesn't?
> restart;
> test:=proc(x,n);
> a:=piecewise(n>0,1/GAMMA(x),n<=0,sin(Pi*x));
> end proc;
Warning, `a` is implicitly declared local to procedure `test`


  test := proc(x, n)
local a;
    a := piecewise(0 < n, 1/GAMMA(x), n <= 0, sin(Pi*x))
end proc

> T1:=test(x,n);

                         {    1
                         { --------         0 < n
                   T1 := { GAMMA(x)
                         {
                         { sin(Pi x)        n <= 0

> T1a:=test(-1,-1);
> T1b:=test(-1.,-1);
> T1c:=test(-1,n) assuming n,integer;
> T1d:=test(-1,n) assuming n,negint;
> T1e:=test(-1,n) assuming n,posint;
>

                               T1a := 0


                               T1b := 0

Error, (in assuming) when calling 'GAMMA'. Received: 'numeric exception: division by zero'


                               T1d := 0

Error, (in assuming) when calling 'GAMMA'. Received: 'numeric exception: division by zero'

> T2a:=subs(x=-1,n=-1,T1);
> T2b:=subs(x=-1.,n=-1,T1);
> T2c:=subs(n=-1,test(-1,n));
> T2d:=subs(x=-1,n=-1,test(x,n));
> T2e:=subs(x=-1.,n=-1,test(x,n));
>

                         {     1
                         { ---------        0 < -1
                  T2a := { GAMMA(-1)
                         {
                         { sin(-Pi)         -1 <= 0


                        {     1
                        { ----------         0 < -1
                 T2b := { GAMMA(-1.)
                        {
                        { sin(-1. Pi)        -1 <= 0

Error, (in GAMMA) numeric exception: division by zero


                         {     1
                         { ---------        0 < -1
                  T2d := { GAMMA(-1)
                         {
                         { sin(-Pi)         -1 <= 0


                        {     1
                        { ----------         0 < -1
                 T2e := { GAMMA(-1.)
                        {
                        { sin(-1. Pi)        -1 <= 0

>
>
>

Please Wait...