Alec Mihailovs

Dr. Aleksandrs Mihailovs

4470 Reputation

21 Badges

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

Social Networks and Content at Maplesoft.com

Maple Application Center

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 answers submitted by Alec Mihailovs

There were earlier discussions about that; in particular, there are links to a package doing that at the end of that thread

I didn't try it myself.

Alec

Solve with assumptions doesn't always work as expected. In this particular example it is easier to use another option - Explicit, and choose the right solution (the first one) manually,

c9:=solve({mu = Mean(Y9), sigma^2 = Variance(Y9)},{a,b},Explicit);
                   2                  1/2 1/2
                 mu          1/2    %1
  c9 := {a = ln(-----), b = 2    ln(-----)   },
                  1/2                mu
                %1

                   2                   1/2 1/2
                 mu           1/2    %1
        {a = ln(-----), b = -2    ln(-----)   },
                  1/2                 mu
                %1

                     2                    1/2 1/2
                   mu          1/2      %1
        {a = ln(- -----), b = 2    ln(- -----)   },
                    1/2                  mu
                  %1

                     2                     1/2 1/2
                   mu           1/2      %1
        {a = ln(- -----), b = -2    ln(- -----)   }
                    1/2                   mu
                  %1

             2     2
  %1 := sigma  + mu

Alec

Adding assignments X2:=0,...,X7:=0 at the beginning, after about 95 sec I got

M;
              ["X2"     20963     134699    6.425559319]
              [                                        ]
              ["X3"    119020     679933    5.712762561]
              [                                        ]
              ["X4"    232017    1160027    4.999750018]
              [                                        ]
              ["X5"    251327    1076892    4.284824153]
              [                                        ]
              ["X6"    133160     476066    3.575142685]
              [                                        ]
              ["X7"     35513     101512    2.858446203]

The numbers in the second column look pretty close to the expected values, which should be reversed in the original post,

map2(numboccur,convert~(combinat:-permute(L)[..,1..5],`+`), [$2..7])*
    792000/combinat:-numbperm(L);

            [21000, 119000, 232000, 252000, 133000, 35000]

Replacing Y||E1 := Y||E1 + E2: with Y||E2 := Y||E2 + 1: would make the 3rd column rather close to the second, and the values in the 4th column close to 1.

M;
              ["X2"     20963     21035    1.003434623 ]
              [                                        ]
              ["X3"    119020    118966    0.9995462947]
              [                                        ]
              ["X4"    232017    232467    1.001939513 ]
              [                                        ]
              ["X5"    251327    251688    1.001436376 ]
              [                                        ]
              ["X6"    133160    133055    0.9992114749]
              [                                        ]
              ["X7"     35513     34789    0.9796130994]

That could be done much faster in Maple.

Alec

First problem,

solve(x=9*sqrt(x+6));
                                       1/2
                                  9 105
                           81/2 + --------
                                     2

evalf(%,20);

                        86.611278446818192724

Second problem,

evalf(T^1000 . <1,0,0,0,0,0,0,0>);

                           [0.1570630660 ]
                           [             ]
                           [0.1658896414 ]
                           [             ]
                           [0.08721452279]
                           [             ]
                           [0.08387472686]
                           [             ]
                           [0.1411339534 ]
                           [             ]
                           [0.04125731218]
                           [             ]
                           [0.1767959573 ]
                           [             ]
                           [0.1467708200 ]

Alec

I don't exactly understand the purpose of it, but the following seems to be working,

BFS := proc(G::Graph, x1::seq(anything))
    local A, B, C, S, T, x, y;
    uses GraphTheory;
    A := {x1};  T := Graph([x1]); 
    B := {op(Vertices(G))} minus A;  S := { };
    while not (B = {}) do
        x := A[1];
        C := {op(Neighbors(G, x))} intersect B;   
        B := B minus C;
        for y in C do
            T := AddVertex( T, y);  
            T := AddEdge( T, {x, y})  
        end do;
        S := S union C;  A := A minus {x};
        if A = { } then A := A union S  end if;
        S := { };  C := { }
    end do;
    return T;
end proc;

It looks as if it could be written much more simple if I understood what it is doing.

Alec

I was trying to guess why this book was chosen. 

Starting reading it, with Hiro being the Deliverator, I thought that you, guys, are preparing to changing your careers to becoming pizza delivery guys.

Then I found the following text: "It's owned by the Nipponese, which is no big deal. But it's also managed by the Nipponese, which means that all the programmers have to wear white shirts and show up at eight in the morning and sit in
cubicles and go to meetings." - and started to think that you are preparing for that.

Now, when I am on page 138 out of 221, with a detailed description of Y.T. mother's job, I am starting to think that that may be it - your job might look similar.

Alec

In Mathematica, the Cartesian product of graphs is done by GraphProduct command.

Alec

I don't think so.

Alec

No, it is a two-argument arctan.

You could obtain a better-looking solution with some assumptions. For example,

eq:=y=a*cos(theta)-tan(b)*a*sin(theta):
A:=b>0,b<Pi/2,a>0:
convert(eq,phaseamp,theta) assuming A;

               2         2  2 1/2
         y = (a  + tan(b)  a )    cos(theta + arctan(tan(b)))

solve(%,theta) assuming A;

                                       y
                  -b + arccos(--------------------)
                                2         2  2 1/2
                              (a  + tan(b)  a )

simplify(%) assuming A;

                                    y cos(b)
                        -b + arccos(--------)
                                       a

Or, if you are interested in all solutions, add AllSolutions to the solve command above,

solve(%%%,theta,AllSolutions) assuming A;

                       y
  -b + arccos(--------------------)
                2         2  2 1/2
              (a  + tan(b)  a )

                             y
         - 2 arccos(--------------------) _B2~ + 2 Pi _Z2~
                      2         2  2 1/2
                    (a  + tan(b)  a )

simplify(%) assuming A;

                 y cos(b)             y cos(b)
     -b + arccos(--------) - 2 arccos(--------) _B2~ + 2 Pi _Z2~
                    a                    a

_B2~ here means 0 or 1, and _Z2~ means an integer (any).

Alec

I would use Numpy for such things instead of Maple,

>>> from numpy import arange, dot
>>> a=arange(24).reshape((2,3,4))
>>> b=arange(4)
>>> dot(a,b)
array([[ 14,  38,  62],
       [ 86, 110, 134]])

The Maple equivalent of that looks like

A:=ArrayTools:-Alias(Array([$0..23]),[1..2,1..3,1..4],C_order):
B:=<($0..3)>:
Matrix(2,3,(i,j)->Vector(A[i,j]).B);

                          [14     38     62]
                          [                ]
                          [86    110    134]

Alec

For n=8 and greater, it would be definitely much faster to use nauty directly, without Maple.

I've just tried to import graphs from a g6 file, which was generated rather fast, in 0.36 sec, by geng, to Maple, and it took almost 5 minutes,

system("/cyg/bin/bash --login -c 'nauty24/geng -d1 9 graphs9.g6'");

                                  0

L9:=GraphTheory:-ImportGraph("/cyg/home/Alec/graphs9.g6",
    graph6,output=list):

nops(L9);

                                262322

length(L9);

                               55961020

Operating with such large objects is slow in Maple.

Alec

Perhaps, installing more memory in the computer might help - such a behavior often happens when Maple is using virtual memory on disk, and writing there and reading it back is very slow.

Also, the Standard interface eats a lot of memory, and your program might perform better in Classic or command line Maple.

Alec

Maple doesn't simplify it because in Maple variables are complex by default - not real, and that simplification is not correct also for negative x, because the power 2/3 acts in a different way than you might expect,

simplify((x^3)^(2/3)) assuming positive;

                                   2
                                  x

simplify((x^3)^(2/3)) assuming negative;

                            2       1/2   2
                           x  (1 + 3    I)
                           ----------------
                                  4

evalc(%);

                            2
                           x            2  1/2
                        - ---- + 1/2 I x  3
                           2

Alec

A natural way of doing that would be using Arrays - but the corresponding procedures (multiplication etc.) have to be written manually - they are not provided in Maple's standard library.

Alec

The fastest way to generate  all nonisomorphic graphs on n vertices where all vertices have degree at least 1, is using nauty . For example, for n=5,

$ ./geng -d1 5 graphs5.g6

After that, they can be imported in Maple as

L5:=GraphTheory:-ImportGraph("graphs5.g6",graph6,output=list):

with adjusting the paths to the correct file location, of course.

Alec

First 8 9 10 11 12 13 14 Last Page 10 of 76