Alec Mihailovs

Dr. Aleksandrs Mihailovs

4475 Reputation

21 Badges

20 years, 39 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

That also could be done with mtaylor which produces polynomials instead of series,

S0:=1: Km:=11: v:=1:
sol:=solve(v*t=(S0-St)+Km*ln(S0/St),St):
eval(sol,t=5.);

                             0.6549618124

plot(sol);

s:=unapply(mtaylor(sol,t),t);

                          11   2     11    3      143     4
  s := t -> 1 - 1/12 t + ---- t  - ------ t  + --------- t
                         3456      165888      286654464

               2629      5
         + ------------ t
           206391214080

s(5.);

                             0.6549679603

plot(s);

Alec

select(a->a[1]=6,a);

                      [[6, 3], [6, 6], [6, 12]]

Alec

However, that correction with evalf works in this simplified example, without parameters, but doesn't work with parameters,

eval(integrand,[a=1,b=0]);

                                        2
                           cos(q) sin(q)
                           ---------------
                           cos(p) - cos(q)

evalf(%): A := int(%, q = 0 .. 2*Pi, 'CauchyPrincipalValue');

                     /       2      1/2
  A := - 3.141592654 |(cos(p)  - 1.)
                     |
                     \

                    2        2      1/2
         - 2. cos(p)  (cos(p)  - 1.)

                             cos(p) + 1.
         - 2. cos(p) csgn(-----------------)
                                 2      1/2
                          (cos(p)  - 1.)

                    3         cos(p) + 1.    \   /        2      1/2
         + 2. cos(p)  csgn(-----------------)|  /  (cos(p)  - 1.)
                                  2      1/2 | /
                           (cos(p)  - 1.)    /

evalf(eval(%,p=1));

                     -1.307363844 + 2.856642118 I

Also, the answer after evalf is numerical, while the expected answer is symbolical, Pi*cos(2) in the example with p=1 and Pi*cos(2*p) in this example, assuming that p is real.

Alec

In Maple 13+, sort without additional arguments should work like that,

sort(a);

       [[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]

Alec

For example,

alias(alpha=RootOf(X^4+X+1)):
f:=op(1,Factor(X^16+X^5+X^3+X^2+1,alpha) mod 2);

        4        2  3    3        2  2        3          2
  f := X  + alpha  X  + X  + alpha  X  + alpha  X + alpha  X

                              2
         + alpha X + X + alpha

alias(beta=RootOf(f)):
P:=p->collect(Expand(p) mod 2,beta):

And then you can do calculations using P. For example,

P(beta^5+alpha*beta^3);

         2     3        3     2                     2
    alpha  beta  + alpha  beta  + alpha beta + alpha  + alpha + 1

P(eval(f,X=beta));

                                  0
P(beta^(2^16-1));

                                  1

Alec

Not really. In some cases, with(RealDomain); works, but it's rather buggy and dangerous.

It can be done in an expression using assuming real ,

simplify(sqrt((x+y)^2)) assuming real;

                              | x + y |

Alec

Cauchy Principal Value is buggy in Maple anyway, and the answer might be wrong even if the calculation could be finished. For example, 

eval(integrand,[a=1,p=1,b=0]);
                                        2
                           cos(q) sin(q)
                           ---------------
                           cos(1) - cos(q)

A real expression, so the integral should be real. Maple gives

int(%,q=0..2*Pi,CauchyPrincipalValue);

                  2 1/2             3
  Pi (-(1 - cos(1) )    - 2 I cos(1)  + 2 I cos(1)

                   2            2 1/2    /            2 1/2
         + 2 cos(1)  (1 - cos(1) )   )  /  (1 - cos(1) )
                                       /

evalf(%);

                     -1.307363844 + 2.856642118 I

The real part should be the answer, and the imaginary part should be 0.

Alec

combine(4*2^n,icombine);
                                (2 + n)
                               2

Alec

Click My files (at the left hand side), then Browse and Upload.

Alec

For example,

g := i->add(arctan(1/sqrt(n)), n = 1 .. i):
p := seq(POLYGONS(evalf([[0, 0], [sqrt(k+1)*cos(g(k)), 
    sqrt(k+1)*sin(g(k))], [sqrt(k)*cos(g(k-1)), 
    sqrt(k)*sin(g(k-1))]])), k = 1 .. 16):
P:=seq(PLOT(p[..i]),i=1..16): 
plots:-display(P, insequence = true);

Alec

In addition to using goto inside procedures, it can be also used inside other blocks, just not at the top level. For example,

a:=0: to 10 do goto(1); a:=a+1; 1 od: a;

                                  0

In particular, it would work in the original code after putting to 1 do at the beginning (after restart;) and od; at the end.

To trace the goto usage, one can add lprint("four"); in front of goto("four") etc.

Alec

PS How did you find out that the goto exists in Maple? It is undocumented. -Alec

In Mupad (which is a part of MATLAB now), one can do various rotations in plots, including those in help pages, just by pushing a corresponding button at the top - left to write, top to bottom etc., other directions, change the speed of rotation etc. 

Alec

To make a smooth animation which could be run continuously, I would change the third coordinates in both plots from -p*Z to (R+abs(p))/2*Z, as well as the first range in view from -50..50 to -60..60.

The first volume is rather simple,

vol1:=int(int(int(1,x=z/c-8*sqrt(z/c-y^2/64) .. 
z/c+8*sqrt(z/c-y^2/64) ), 
y=-8*sqrt(z/c) .. 8*sqrt(z/c)), z=0..100);

                                  320000 Pi
                          vol1 := ---------
                                      c

with c=(R+abs(p))/2 if the animation is changed accordingly to my suggestion above.

The second volume is slightly more complicated,

vol2:=int(int(int(1,x=-7*sqrt(z/c-y^2/64)-20 .. 
-abs(7*sqrt(z/c-y^2/64)-10)-10 ), 
y=-8*sqrt(z/c) .. 8*sqrt(z/c)), z=0..100, AllSolutions);

                                  280000 Pi
                          vol2 := ---------
                                      c

It looks as if the second volume should be about a half of the first one though, but who knows...

Mathematica gives the same answers (assuming that c is positive). I hope that somebody will double check the limits of integration I entered.

Alec

anames(user);

gives the list of the names of the variables defined after the last restart. Sometimes it includes some additional variables generated by Maple as well, such as lasterror and lastexception, for example.

The variables of a specific type, say integer, could be found using

{anames(user)} intersect {anames(integer)};

unames() is supposed to produce a sequence of unassigned names, but in reality produces a lot of other stuff, which may be an interesting reading though.

Alec

Wonderful calculation! I really enjoyed it.

For the symmetry case, r and s could be defined shorter using indexing,

r := L -> L[[7,4,1,8,5,2,9,6,3]]:
s := L -> L[[7,8,9,4,5,6,1,2,3]]:

which can be also written as

r:=rcurry(`?[]`,[1,[7,4,1,8,5,2,9,6,3]]):
s:=rcurry(`?[]`,[1,[7,8,9,4,5,6,1,2,3]]):

Also, that calculation could be done in a slightly different form as

r:=[[1, 7, 9, 3], [2, 4, 8, 6]]:
s:=[[1, 7], [2, 8], [3, 9]]:
G:=map(convert,group:-elements({r,s}),permlist,9):
add(nops(select(t -> t[g]=t, OKboards)), g=G)/nops(G); 

                                 765

At the beginning (without considering symmetry) everything works fast except select(OK,Wins). That could be avoided by using the following procedure instead of IsWin,

Is_Win:=proc(L) 
local LP,x,o; 
LP:= eval(P,B=L);
x:=coeff(LP,X,3);
o:=coeff(LP,O,3);
if numboccur(L,_)::even 
then x>0 and o=0
else x=0 and o>0 fi
end;

Using it instead of IsWin produces OKWins instead of Wins, immediately,

evalb(select(Is_Win,Boards)=OKWins);

                                 true

Also, the OKboards could be produced directly from Boards by replacing > with ≥ in Is_Win,

Is_OK:=proc(L) 
local LP,x,o; 
LP:= eval(P,B=L);
x:=coeff(LP,X,3);
o:=coeff(LP,O,3);
if numboccur(L,_)::even 
then x>=0 and o=0
else x=0 and o>=0 fi
end;

Check that,

evalb({op(select(Is_OK,Boards))}={op(OKboards)});

                                 true

Finally, I'd like to add a different method of generating P, using a 3×3 magic square,

m:=[B[8],B[1],B[6],B[3],B[5],B[7],B[4],B[9],B[2]]:
S:=[seq(m[i],i=select(x->convert(x,`+`)=15,
combinat:-choose(9,3)))];
P:=add(mul(i,i=j),j=S);

or

P:=convert(convert~(S,`*`),`+`);

Alec

First 11 12 13 14 15 16 17 Last Page 13 of 76