Alec Mihailovs

Dr. Aleksandrs Mihailovs

4455 Reputation

21 Badges

20 years, 306 days
Mihailovs, Inc.
Owner, President, and CEO
Tyngsboro, Massachusetts, United States

Social Networks and Content at Maplesoft.com

I received my Ph.D. from the University of Pennsylvania in 1998 and I have been teaching since then at SUNY Oneonta for 1 year, at Shepherd University for 5 years, at Tennessee Tech for 2 years, at Lane College for 1 year, and this year I taught at the University of Massachusetts Lowell. My research interests include Representation Theory and Combinatorics.

MaplePrimes Activity


These are replies submitted by Alec Mihailovs

8 solutions, with x, y, and z being 1 or -1, are obvious.

Alec

For the cases with many Hamiltonian cycles, the following procedure might be useful,

HamiltonianCyclesCount:=proc(g)
    local n,temp,fd,i;
    n:=GraphTheory:-NumberOfVertices(g);
    temp:="/Users/Alec/AppData/Local/Temp/hctemp";
    fd:=open(temp,WRITE);
    fprintf(fd, cat("$\n&Graph\nG\n%d",
        "\n%{}d"$n-1,"  0\n"), n,  
        seq(<-i,op(select(`>`,op([4,3,i,2],g),i))>,
            i=1..n-1));
    close(fd);
    parse(ssystem(cat("/cyg/bin/bash --login -c ",  
        "'hamiltonianCycles/hc_count ",
        "/cygdrive/c", temp, "'"))[2][7..-22]);
end;

For example,

use GraphTheory in  
    g:=CartesianProduct(CycleGraph(6),PathGraph(6))
end:
HamiltonianCyclesCount(g);

                                63674
use GraphTheory in  
    g:=CartesianProduct(CycleGraph(7),PathGraph(7))
end:
HamiltonianCyclesCount(g);

                               2861964
use GraphTheory in  
    g:=CartesianProduct(CycleGraph(8),PathGraph(8))
end;
HamiltonianCyclesCount(g);

                              1087362018

Also, instead of trying to get the list of cycles into Maple, one could save them in a file, and then read that file from Maple if necessary - that can be done by a slight change in the original procedure - I'll post that later.

Alec

If the output is large, the ssystem chokes, which results in the situation when the interrupt button is not working, and it may be even not that easy to close Maple.

In such cases, one can first write the output on the disk and then read it from there to Maple if necessary, using the following 2 procedures,

HamiltonianCyclesWrite:=proc(g)
    local n,temp,fd,i;
    n:=GraphTheory:-NumberOfVertices(g);
    temp:="/Users/Alec/AppData/Local/Temp/hctemp";
    fd:=open(temp,WRITE);
    fprintf(fd, cat("$\n&Graph\nG\n%d",
        "\n%{}d"$n-1,"  0\n"), n,  
        seq(<-i,op(select(`>`,op([4,3,i,2],g),i))>,
            i=1..n-1));
    close(fd);
    system[launch]("/cyg/bin/bash", "--login", "-c",  
        cat("'hamiltonianCycles/hc_list_cycles ",
            "/cygdrive/c", temp, " > ",
            "/cygdrive/c", temp, 1, "'"))
end;

HamiltonianCyclesRead:=proc(g)
    local m,n,temp1,fd,M;
    n:=GraphTheory:-NumberOfVertices(g);
    temp1:="/Users/Alec/AppData/Local/Temp/hctemp1";
    m:=parse(ssystem(cat("/cyg/bin/bash --login -c 
        'wc -l /cygdrive/c", temp1, "'"))[2][1..-52])-1;
    fd:=open(temp1,READ);
    readline(fd);
    M:=fscanf(fd, cat("%{",m,",",n,";d(<>)}dm"))[];
    close(fd);
    M
end;

If temp1 is changed, then 52 should be changed accordingly the change of the length of temp1 - if the length, say, get increased by 3 characters, 3 should be added to 52, making it 55. That works as

use GraphTheory in  
    g:=CartesianProduct(CycleGraph(6),PathGraph(6))
end;
HamiltonianCyclesWrite(g);

                                 1436

M:=HamiltonianCyclesRead(g);

                         [ 63674 x 36 Matrix     ]
                    M := [ Data Type: integer[4] ]
                         [ Storage: rectangular  ]
                         [ Order: Fortran_order  ]

The file hctemp1 in this example has size 6.31 MB, so one can estimate the sizes of files in larger examples :)

Alec

Sorry, I didn't even try. Perhaps, Alejandro has them.

Alec

Sorry, I didn't even try. Perhaps, Alejandro has them.

Alec

One could just add [1] at the end,

c9:=solve({mu = Mean(Y9), sigma^2 = Variance(Y9)},{a,b},Explicit)[1];

                         2                            2     2 1/2 1/2
                       mu                1/2    (sigma  + mu )
  c9 := {a = ln(-----------------), b = 2    ln(-----------------)
                      2     2 1/2                      mu
                (sigma  + mu )

        }

Alec

One could just add [1] at the end,

c9:=solve({mu = Mean(Y9), sigma^2 = Variance(Y9)},{a,b},Explicit)[1];

                         2                            2     2 1/2 1/2
                       mu                1/2    (sigma  + mu )
  c9 := {a = ln(-----------------), b = 2    ln(-----------------)
                      2     2 1/2                      mu
                (sigma  + mu )

        }

Alec

That particular example is not that bad actually, I would say, in spite of few clear mistakes, and the ratings confirm that quite a few people found it useful. 

But in general, I agree - the quality of many items in the Application Center is questionable.

Alec

It would be more useful (and more tempting) if the comments there, as well as on the help pages, stayed visible. 

Frankly, I don't visit Application Center often (if any), but I looked through some help pages several months ago and left few comments, and the fact that comments didn't stay there visible (not even talking that the mistakes in the help pages that I pointed out were not corrected), was rather disappointing and not stimulating for leaving further comments.

What are the chances that leaving comments in the Application Center would change anything if that doesn't work like that with the help pages?

Alec

There are several algorithms known. All of them are exponential - with Maple's speed it would take forever for more than 10 or 12 vertices. 

A reasonable option would be to find a library (a dll) where it is implemented and call the corresponding function in it from Maple using external calling.

Or use one of existing executables - for example, Ham Cycle unix tool (do make clean first, then replace -fast with -O3 in the Makefile before doing make release), prepare its input in Maple, and then call it from Maple usyng ssystem command.

I posted that procedure in my blog.

But since you have Mathematica - why bother? You can just use it.

Alec

There are several algorithms known. All of them are exponential - with Maple's speed it would take forever for more than 10 or 12 vertices. 

A reasonable option would be to find a library (a dll) where it is implemented and call the corresponding function in it from Maple using external calling.

Or use one of existing executables - for example, Ham Cycle unix tool (do make clean first, then replace -fast with -O3 in the Makefile before doing make release), prepare its input in Maple, and then call it from Maple usyng ssystem command.

I posted that procedure in my blog.

But since you have Mathematica - why bother? You can just use it.

Alec

If I remember correctly, the guy who started doing that Hint-Rule approach left Maplesoft before finishing it. In its first version, again, if I remember correctly, even such things as 1/(x^2+a^2)^2 were not integrated. Later some work was done by other people, and rational functions seemed to be completed, but the quadratic irrationalities (with trigonometeric, or hyperbolic substitutions) - obviously are still unfinished.

On the other hand - it is Calculus II, not Calculus I...

Alec

Wolfram Alpha produces the answer to integrate sqrt( (x+a)(x+b) ) / ( x (x+c) )  and even has ShowSteps link, but clicking it doesn't show steps, and it says down below that step-by-step results unavailable.

Alec

ShowSolution() stops here after the 5th step - so there might be some way to detect that.

Alec

The corollary is wrong.

Proof.

f:=(-1)^n* n^(1/n);

                                   n  (1/n)
                          f := (-1)  n

diff(f,n);

              n     (1/n)         n  (1/n) /  ln(n)    1  \
          (-1)  Pi n      I + (-1)  n      |- ----- + ----|
                                           |    2       2 |
                                           \   n       n  /

Alec

First 23 24 25 26 27 28 29 Last Page 25 of 180