vv

12238 Reputation

19 Badges

8 years, 74 days

MaplePrimes Activity


These are questions asked by vv

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

 

restart;

Digits:=3;

3

(1)

u:=1.23456;

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)];

[1.23456, 1.23, 1.23+x, 1.23456+x]

 

[1.23456, 1.23456, 1.23456+x, 1.23456+x]

(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]);

true, true

(4)

evalb(A[1]=A[2]), evalb(A[3]=A[4]);

true, false

(5)

is(A=B);
is~(A=~B);

false

 

[true, true, true, true]

(6)

evalb(A=B);
evalb~(A=~B);

false

 

[true, true, false, true]

(7)

 

Download Difficult-to-explain.mw

restart;

f:=5*x^3-5*x+1;

5*x^3-5*x+1

(1)

s:=[solve(f)]; evalf(%);  # All the roots are real

[(1/30)*(-2700+(300*I)*219^(1/2))^(1/3)+10/(-2700+(300*I)*219^(1/2))^(1/3), -(1/60)*(-2700+(300*I)*219^(1/2))^(1/3)-5/(-2700+(300*I)*219^(1/2))^(1/3)+((1/2)*I)*3^(1/2)*((1/30)*(-2700+(300*I)*219^(1/2))^(1/3)-10/(-2700+(300*I)*219^(1/2))^(1/3)), -(1/60)*(-2700+(300*I)*219^(1/2))^(1/3)-5/(-2700+(300*I)*219^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/30)*(-2700+(300*I)*219^(1/2))^(1/3)-10/(-2700+(300*I)*219^(1/2))^(1/3))]

 

[.8788850663-0.2e-9*I, -1.088033915-0.2598076212e-9*I, .2091488484+0.2598076212e-9*I]

(2)

max(s);  # ?

Error, (in simpl/max) complex argument to max/min: (1/30)*(-2700+(300*I)*219^(1/2))^(1/3)+10/(-2700+(300*I)*219^(1/2))^(1/3)

 

type(s,list(realcons)); # Wrong, the type realcons should not be purely syntactic; or is it?

false

(3)

R:=convert(s,RootOf):

max(R);  #  For nested RootOfs fails

Error, (in simpl/max) complex argument to max/min: (1/30)*RootOf(_Z^3+2700-300*RootOf(_Z^2+1, index = 1)*RootOf(_Z^2-73, index = 1)*RootOf(_Z^2-3, index = 1), index = 1)+10/RootOf(_Z^3+2700-300*RootOf(_Z^2+1, index = 1)*RootOf(_Z^2-73, index = 1)*RootOf(_Z^2-3, index = 1), index = 1)

 

sort(s): evalf(%);  # Wrong

[.8788850663-0.2e-9*I, .2091488484+0.2598076212e-9*I, -1.088033915-0.2598076212e-9*I]

(4)

 

Workaround

 

S:=[seq(RootOf(f,x,index=i),i=1..3)];

[RootOf(5*_Z^3-5*_Z+1, index = 1), RootOf(5*_Z^3-5*_Z+1, index = 2), RootOf(5*_Z^3-5*_Z+1, index = 3)]

(5)

evalf(S);

[.2091488484, .8788850662, -1.088033915]

(6)

min(S);max(S);  # OK

RootOf(5*_Z^3-5*_Z+1, index = 3)

 

RootOf(5*_Z^3-5*_Z+1, index = 2)

(7)

sort(S);   # Wrong!

[RootOf(5*_Z^3-5*_Z+1, index = 1), RootOf(5*_Z^3-5*_Z+1, index = 2), RootOf(5*_Z^3-5*_Z+1, index = 3)]

(8)

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

r:=(sqrt(2)+I)^3 + (sqrt(2)-I)^3;

(2^(1/2)+I)^3+(2^(1/2)-I)^3

(9)

type(r,realcons);  # Purely syntactic?

false

(10)

type(expand(r),realcons);

true

(11)

max(r,13);  # Even for such a simple expression?

Error, (in simpl/max) complex argument to max/min: (2^(1/2)+I)^3+(2^(1/2)-I)^3

 

 


Download TryHarder.mw

Here are two inocent Vectors.

V1 := Vector[row]([`+`, 1, 2]);

_rtable[18446744074366295326]

(1)

V2 := Vector[row]([1, `+`, 2]);

_rtable[18446744074366288110]

(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.

 


Download v1v2.mw

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)

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

3

 

[.333 = .3333333333, ".333" = ".3333333333", .3333333333 = .3333333333, .3330000000]

(1)

 

k:=proc(x) convert(x,string) end:

kernelopts(floatPi);

true

(2)

4.+Pi;

7.14

(3)

evalf(k(1/3.+Pi));
# floatPi seems to be ignored inside actual parameters

".333+Pi"

(4)

evalf(k(4+evalf(Pi)));

"7.14"

(5)

evalf(k(4+Pi));
# 4 not being float (or "infected" by a float) is not evalf-ed

"4+Pi"

(6)

 

### (this is documented)

`evalf/h` := proc() 7.777 end:

evalf(h(1/3));

.333

(7)

evalf('h'(1/3));

7.777

(8)

 

 

Download digits.mw

(edited)

5 6 7 8 9 10 11 Page 7 of 12