## 2304 Reputation

1 years, 240 days

## TravelingSalesman - speed...

Maple

How is it possible that  GraphTheory:-TravelingSalesman
is much slower than a simple brute-force solution?

 > restart;
 > n:=10:
 > A:=Matrix(n, (i,j)->`if`(i=j,0,n*(n-i)^4+2*j+(n-i)^2+j^3)):A[1,2]:=100*n^3:A;
 (1)
 > with(GraphTheory):
 > G:=Graph(A);
 (2)
 > t:=time[real](): TravelingSalesman(G); 'time'=time[real]()-t;
 (3)
 > ############### brute-force #############
 > t:=time[real](): P:=Iterator:-Permute([seq(2..n)]): cmin:=infinity: ord:=<"none">: for  v in P do   f:=add(A[v[k],v[k+1]],k=1..n-2) + A[1,v[1]]+A[v[n-1],1];   if f
 (4)
 > # And for n=11 I had to interrupt TravelingSalesman; # brute-force still works for n=12.

## evalf random results - serious bug...

Maple

 > restart;
 > Digits:=10; to 10 do evalf(add(sin(k), k = 1 .. 10000)) od;
 (1)
 > restart;   # execute several times to obtain randomness
 > interface(version);
 (2)
 > Digits:=18;
 (3)
 > to 10 do   evalf(add(sin(k), k = 1 .. 10000)) od;
 (4)
 >

## Solving with Groebner basis...

Maple

Suppose that a finite set of polynomials in C[x,y,z] has a finite number of solutions (i.e. the generated ideal is 0-dimensional).

Suppose also that the Groebner basis wrt plex(x,y,z) is

[f(z), g(y,z), h(y,z), k(x,y,z)]

As well known, the system can be now easily solved: choose a root z0 of f, plug it into g and h and look for a common root (y0) etc.

The question is the following:
Is it true that for EVERY root z0 of f there exist y0, z0 such that (x0,y0,z0) satisfy the system?

In all the examples I have seen this is true, but I don't know whether this is true in general or there is a counterexample.

[This is not a pure Maple question but I know that some members here work in this area].

Thank you.

## Strange bug in fsolve with Digits...

Maple

It is well known that fsolve usually increases (internally) Digits in order to obtain the desired accuracy.

But in the following example, it seems that fsolve highly exaggerates :-)

```restart;
N:=40:
Digits:=100:
F:=expand(mul(x-k,k=1..N)):
f:=evalf(F):
S:=[fsolve(f,complex)];
```

Error, (in fsolve) Digits cannot exceed 38654705646

Note that the bug does not appear if e.g. F:=expand(mul(x-k-I, k=1..N)):

## Order in plots[display]...

Maple
```with(plots):with(plottools):
p1:=plot( x^3,x=-1..1,thickness=20,color=red):
p2:=plot(-x^3,x=-1..1,thickness=20,color=blue):
p3:=display(rectangle([0.5, 1],[0.75,-1],color=green)):
p4:=display(rectangle([-1,-0.1],[1,0.1],color=yellow)):

display(p1,p2,p3,p4); # order = 4312
```

#  display(p3,p4,p1,p2); # order = 4312 (the same)

It seems that the rectangles are plotted first, in reversed order, and then the curves, in direct order.
Has someone an explanation?

 1 2 3 4 Page 1 of 4
﻿