## 12915 Reputation

8 years, 359 days

## Inconsistent behavior of eval in piecewi...

Maple

Strange (inconsistent) behavior of eval in piecewise

 > restart;#####################
 > a:=2:
 > p:=piecewise(x
 (1)
 > eval(p, x=a);
 (2)
 > restart;#####################
 > a:=Pi:
 > p:=piecewise(x
 (3)
 > eval(p, x=a);
 > restart;#####################
 > a:=Pi+ln(2):
 > p:=piecewise(x
 (4)
 > eval(p, x=a);
 (5)
 > restart;#####################
 > a:=Pi+1:
 > p:=piecewise(x
 (6)
 > eval(p, x=a);
 > restart;#####################
 > a:=gamma:
 > p:=piecewise(x
 (7)
 > eval(p, x=a);
 > #######################
 > f:=x->piecewise(x
 (8)
 > f(Pi);
 (9)
 >

## Difficult to explain?...

Maple

Some of these seem to be difficult to explain ...

 > restart;
 > Digits:=3;
 (1)
 > u:=1.23456;
 (2)
 > A := [1.23456, 1.23456+0, 1.23456+x+0, 1.23456+(x+0)]; B := [u,       u+0,       u+x+0,       u+(x+0)];
 (3)
 > lprint(A); lprint(B);
 [1.23456, 1.23, 1.23+x, 1.23456+x] [1.23456, 1.23456, 1.23456+x, 1.23456+x]
 > is(A[1]=A[2]),    is(A[3]=A[4]);
 (4)
 > evalb(A[1]=A[2]), evalb(A[3]=A[4]);
 (5)
 > is(A=B); is~(A=~B);
 (6)
 > evalb(A=B); evalb~(A=~B);
 (7)
 >

## Maple should try harder...

Maple
 > restart;
 > f:=5*x^3-5*x+1;
 (1)
 > s:=[solve(f)]; evalf(%);  # All the roots are real
 (2)
 > max(s);  # ?
 > type(s,list(realcons)); # Wrong, the type realcons should not be purely syntactic; or is it?
 (3)
 > R:=convert(s,RootOf):
 > max(R);  #  For nested RootOfs fails
 > sort(s): evalf(%);  # Wrong
 (4)

Workaround

 > S:=[seq(RootOf(f,x,index=i),i=1..3)];
 (5)
 > evalf(S);
 (6)
 > min(S);max(S);  # OK
 (7)
 > sort(S);   # Wrong!
 (8)
 > ################################
 > r:=(sqrt(2)+I)^3 + (sqrt(2)-I)^3;
 (9)
 > type(r,realcons);  # Purely syntactic?
 (10)
 > type(expand(r),realcons);
 (11)
 > max(r,13);  # Even for such a simple expression?
 >

## Strange output for Vector...

Maple 2017

Here are two inocent Vectors.

 > V1 := Vector[row]([`+`, 1, 2]);
 (1)
 > V2 := Vector[row]([1, `+`, 2]);
 (2)
 > lprint(V1);
 Vector[row](3, {1 = `+`, 2 = 1, 3 = 2}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])

The questions:

1.  Try to guess the Maple's answer for:

 > V1, V2;

2. Try to explain.

## A simple evalf/Int crashes Maple...

Maple 2017
`evalf(Int(x*(1-2*x^(3/10))^(10./3),x=0..1));  # Crashes Maple`

Note that:

int(x*(1-2*x^(3/10))^(10./3),x=0..1);
int(x*(1-2*x^(3/10))^(10/3),x=0..1);

are OK.

(Windows 7, Maple 2017.3, 64 bit)

 5 6 7 8 9 10 11 Page 7 of 12
﻿