vv

11706 Reputation

19 Badges

7 years, 130 days

MaplePrimes Activity


These are questions asked by vv

Consider the `or` procedure.
`or`(x, y)  should be equivalent to  x  or  y.

However:
restart;
x := a=0;
y := b=0;

                           x := a = 0
                           y := b = 0
x or y;
                             false
`or`(x,y);
                         a = 0 or b = 0
%;
                             false
simplify(`or`(x,y));
                         a = 0 or b = 0
eval(`or`(x,y));
                             false


### So,  `or`(x,y)  is not fully evaluated [or simplified?].
### Is this documented somewhere?


# Similarly
`not`(x);
                           not a = 0
%;
                              true
not x;
                              true

 

This question is related to an answer I gave here:
So, please look at a simple worksheet containing only a few lines; the resuts are in the # comments.

restart;
evalf(frac(Pi^20));

#                              23.
restart;
printlevel:=40:
evalf(frac(Pi^20));

  ###  prinlevel stuff
#                              0.


And now the questions.
1. Why the first evalf(frac(Pi^20))  does not  call  `evalf/frac`?
     (the second does, trace(`evalf/frac`)  shows this  if inserted).
     Note that  `evalf/frac`(Pi^20)    returns  0.
2. Why evalf(frac(Pi^20))    depends on printlevel?
    Note that  if  printlevel is changed to 20 (say)  the result is again 23.
3. Why if we set interface(typesetting=standard)  in a fresh session
     the results are both 23?

 

The procedure F computes the smallest prime factor of  ithprime(n)-2

F := n -> ifactors((ithprime(n)-2))[2][1][1]:

F(11);
                               29
Strangely, print(F)  must be interrupted!
print(F);
Warning,  computation interrupted
 
Also,

F := n -> ifactors((ithprime(n)-2))[2][1][1];

Warning,  computation interrupted
Warning,  computation interrupted

(F is defined, only the display fails).
This happens only for interface(typesetting=extended).
In Maple 2017 it was OK.

 

Is it possible to split an execution group containing 2D input?
(without conversion to 1D which destroys the format).
Using F3 or the menu seems to work only for lines with a prompt.
But usually an execution group has a single prompt; lines with prompts appear e.g. when two execution groups are joined (with F4).
Is copy&paste the only solution?

Strange (inconsistent) behavior of eval in piecewise

 

restart;#####################

a:=2:

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33);

p := piecewise(x < 2, 1/(-2+x), x = 2, 22, 33)

(1)

eval(p, x=a);

22

(2)

restart;#####################

a:=Pi:

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33);

p := piecewise(x < Pi, 1/(-Pi+x), x = Pi, 22, 33)

(3)

eval(p, x=a);

Error, (in eval/piecewise) numeric exception: division by zero

 

restart;#####################

a:=Pi+ln(2):

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33);

p := piecewise(x < Pi+ln(2), 1/(-Pi-ln(2)+x), x = Pi+ln(2), 22, 33)

(4)

eval(p, x=a);

22

(5)

restart;#####################

a:=Pi+1:

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33);

p := piecewise(x < Pi+1, 1/(-Pi-1+x), x = Pi+1, 22, 33)

(6)

eval(p, x=a);

Error, (in eval/piecewise) numeric exception: division by zero

 

restart;#####################

a:=gamma:

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33);

p := piecewise(x < gamma, 1/(-gamma+x), x = gamma, 22, 33)

(7)

eval(p, x=a);

Error, (in eval/piecewise) numeric exception: division by zero

 

#######################

f:=x->piecewise(x<Pi, 1/(x-Pi), x=Pi, 22, 33);

f := proc (x) options operator, arrow; piecewise(x < Pi, 1/(x-Pi), x = Pi, 22, 33) end proc

(8)

f(Pi);

22

(9)

 


Download piecewise-strange.mw

4 5 6 7 8 9 10 Page 6 of 12