## 12755 Reputation

8 years, 298 days

## 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)

## evalf[d] and Digits...

Maple

A fact that seems to be not documented. Probably it should be obvious.

Digits := d0
evalf[d](expr);

The toplevel float sub-expressions in expr  are computed with Digits=d0 but in procedures Digits is set to d.
Notice that the actual float parameters of the toplevel procedures are evalf-ed with Digits=d0.

 > restart;
 > g:=proc() convert(1/3., string) end: h:=proc() 1/3. end:
 > Digits:=3; evalf[10]([   1/3. = h(),   convert(1/3.,string) = g(),     fsolve(3*x=1) = add([1/3]),   fsolve(x/3=1/9.) # 1/9. being at top level is evalf-ed with Digits=3 ])
 (1)
 >
 > k:=proc(x) convert(x,string) end:
 > kernelopts(floatPi);
 (2)
 > 4.+Pi;
 (3)
 > evalf(k(1/3.+Pi)); # floatPi seems to be ignored inside actual parameters
 (4)
 > evalf(k(4+evalf(Pi)));
 (5)
 > evalf(k(4+Pi)); # 4 not being float (or "infected" by a float) is not evalf-ed
 (6)
 >
 > ### (this is documented)
 > `evalf/h` := proc() 7.777 end:
 > evalf(h(1/3));
 (7)
 > evalf('h'(1/3));
 (8)
 >