Kitonum

21550 Reputation

26 Badges

17 years, 124 days

MaplePrimes Activity


These are replies submitted by Kitonum

@Markiyan Hirnyk  I do not know how many more you need examples to believe the complete inefficiency of DirectSearch  package for solving problems of discrete optimization. Here are two very obvious example. It is taken from your question about the maximum of determinant with numbers 1..16. Consider two simpler examples of the determinant of the second order (numbers 1..4) and third order (the numbers 1..9). 

The first example is trivial and can be solved in the mind for a few seconds. Here's the work  DirectSearch  package:

restart;

ts:=time():

F:=LinearAlgebra[Determinant](Matrix([[x[1],x[2]],[x[3],x[4]]]));

DirectSearch[GlobalOptima](F, {[x[1],x[2],x[3],x[4]]=Matrix(map(convert,combinat[permute]([$1..4]),Vector))}, maximize);

time()-ts;

                                       

 

 

The solution of the same problem for the determinant of the third order:

restart;

ts:=time():

F:=LinearAlgebra[Determinant](Matrix([[x[1],x[2],x[3]],[x[4],x[5],x[6]],[x[7],x[8],x[9]]]));

DirectSearch[GlobalOptima](F, {[seq(x[i],i=1..9)]=Matrix(map(convert,combinat[permute]([$1..9]),Vector))}, maximize);

time()-ts;

 

As you can see, I did not wait for any result and interrupted calculation.

 

The latest example is solved in 20 seconds by simple enumeration:

restart;

ts:=time():

P:=combinat[permute]([$1..9]):

M:=-infinity:

f:=unapply(LinearAlgebra[Determinant](Matrix(3, [seq(x||i, i=1..9)])), seq(x||i, i=1..9)):

for p in P do

d:=f(op(p));

if d>M then M:=d; L:=[d,p] fi;

od:

L[1],Matrix(3,L[2]);

time()-ts;

                            

 

 

@Markiyan Hirnyk  You call  566073  as a worthy output  in comparison with the exact result  5927 ?

@Markiyan Hirnyk   

Digits := 200:

 fsolve(100^x - x^100=0, x = 2 .. infinity);

         100.000000000000 ... 

 

 

@Markiyan Hirnyk  As you can see, it took a lot of options for finding all solutions. Here's an easier way. From continuity and properties of functions it follows that two roots are in the ranges  x=-1..0  and  x=1..2  and third exact root  x=100  is evident.

Eq:=100^x=x^100:

fsolve(Eq, x=-1..0);

fsolve(Eq, x=1..2);

                  -0.9568903883

                    1.049519190

 

Another way:

RootFinding[Analytic](100^x=x^100, re=-1..110, im=-1..1):

select(t->type(t, realcons), [%]);

                  [-0.956890388296380, 1.04951918980717, 100.000000000000]

 

@Carl Love  Thank you, but I have already made the amendment earlier.

@Carl Love  That's good, but it works only for newer versions Maple. Variant for all versions:

P:=a*x^2*y*z+b*x*y*z+c*x^2*y*z+d*x*y^2*z+e*x*y*z:

L:=[coeffs(P, [x,y,z], 't')]: 

H:= table(zip(`=`, [t], L)):

H[x^2*y*z];

                         a+c

@Axel Vogt  Yes, this product is the classical identity. See here

@Axel Vogt  Thank you for your interest and useful procedure. I think this procedure solves and other similar examples. There are also examples with which it can not handle.

Examples:

f:=n->tan(sqrt(n^2+2*n/3)*Pi);

seqLimit(f(n), n, 1);

h:=n->product(cos(1/2^k), k=1..n);

evalf(limit(h(n), n=infinity));

identify(%);

seqLimit(h(n), n);

 

 

@Carl Love  Actually, this sequence increases monotonically. This follows from the monotony of  sin  function on [0,Pi/2] and

g:= n->sqrt(n^2+n)*Pi - Pi*n:

is(diff(g(n), n)>0)  assuming n>1;

is(g(n)<Pi/2)  assuming n>1;

                             true
                             true

@Carl Love   Thanks.

Here is another interesting phenomenon. With an increase  n  the calculation accuracy falls:

f:=n->sin(sqrt(n^2+n)*Pi)^2;

seq(evalf(f(10^5*k)), k=1..10);

@Kitonum   We can solve the problem numerically by reducing it to the calculation of the sum a series:

f:=n->sin(sqrt(n^2+n)*Pi)^2;

evalf[100](sum(f(n+1) - f(n), n=1..infinity)+f(1));

 

@Carl Love  I think your solution closer to hand than to automatic. Why we have to guess to use asympt(sqrt(n^2+n)*Pi, n, 1) ?  We wish the developers to solve this problem in a future release of Maple.

 

BTW in Mathematica the problem already solved:

Limit[Sin[Sqrt[n^2 + n]*Pi]^2, n -> Infinity, Assumptions -> Element[n, Integers]]

                                                                    1

@tomleslie  Thanks. And how about this example for  n::posint  in Maple:

limit(sin(sqrt(n^2+n)*Pi)^2, n=infinity);

@Markiyan Hirnyk  Why did you write the option "solutions=16" ? Without this option, DirectSearch finds some the other number of solutions. I think that aser's and Preben's ways (using only Maple tools) are more  justified.

@Carl Love   Of course, you're right! Still, the list is somewhat broader. As it is written in the help, for example, the list includes the values of functions with rational arguments and algebraic numbers of degree <=6.

Examples:

Digits:=20:

evalf(ln(101));

identify(%);

convert(%, ln);

evalf(sqrt(3+5^(1/3)));

identify(%);

evalf(sin(1/3));

identify(%);

                         

 

 

First 92 93 94 95 96 97 98 Last Page 94 of 133