Alec Mihailovs

Dr. Aleksandrs Mihailovs

4495 Reputation

21 Badges

20 years, 338 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 replies submitted by Alec Mihailovs

That's a great idea!

For larger n, k, and m, a direct formula for f may be faster. For example,

F:=(n,k,m)->add(binomial(k+1,i)*binomial(-k-1,n-k-m*i)*(-1)^(n-k-(m-1)*i),i=0..(n-k)/m):

time(f(500,200,40));
                                4.071

time(F(500,200,40));

                                  0.
f(500,200,40)-F(500,200,40);

                                  0

Alec

Not that simple, but that can be done as

r:=proc(a,b,n,m)
    local L;
    a+~ListTools:-PartialSums([0,op(1+~eval(
        combstruct[draw]([L,{L=Prod(Sequence(Z,card<=m-1)$(n-1))}],size=b-a-n+1),
        [Z=1,Epsilon=0,Sequence=`+`,Prod=`[]`]))])
end;

For example,

to 3 do r(0,10,6,3) od;

                         [0, 2, 5, 7, 8, 10]


                         [0, 3, 5, 6, 7, 10]


                         [0, 1, 4, 5, 8, 10]

Probably, all the combstruct names in the procedure should be quotted. In that case, L may be not necessarily declared local, I think. I didn't try that (or quotting) though.

Alec

PS Thank you, acer, for the nice note. That may keep me around this site for a few days more. Because usually, withouting getting any responce, I start thinking that either I am talking to myself posting here, or "throw pearls before swine" (Matthew 7:6) -Alec

Not that simple, but that can be done as

r:=proc(a,b,n,m)
    local L;
    a+~ListTools:-PartialSums([0,op(1+~eval(
        combstruct[draw]([L,{L=Prod(Sequence(Z,card<=m-1)$(n-1))}],size=b-a-n+1),
        [Z=1,Epsilon=0,Sequence=`+`,Prod=`[]`]))])
end;

For example,

to 3 do r(0,10,6,3) od;

                         [0, 2, 5, 7, 8, 10]


                         [0, 3, 5, 6, 7, 10]


                         [0, 1, 4, 5, 8, 10]

Probably, all the combstruct names in the procedure should be quotted. In that case, L may be not necessarily declared local, I think. I didn't try that (or quotting) though.

Alec

PS Thank you, acer, for the nice note. That may keep me around this site for a few days more. Because usually, withouting getting any responce, I start thinking that either I am talking to myself posting here, or "throw pearls before swine" (Matthew 7:6) -Alec

I agree. There is a remote possibility that randcomb produces a sorted result even for gmp numbers and different kernel settings, but I wouldn't bet on that (is online betting legal in Canada, by the way?). That can be corrected by sorting the result.

Alec

I agree. There is a remote possibility that randcomb produces a sorted result even for gmp numbers and different kernel settings, but I wouldn't bet on that (is online betting legal in Canada, by the way?). That can be corrected by sorting the result.

Alec

My reasoning was that if something wrong is going in Standard, and it is not clear why, the easiest way to avoid that is to use Classic. Much less weird things happen there.

Alec

That seems to be one of things why experienced users prefer classic interface. A workaround is either using classic Maple for help, or use online help.

Alec

It can be done more simple using randcomb,

q:=(a,b,n)->[a, op(a+~combinat:-randcomb(b-a-1,n-2)), b]:

For example,

to 3 do q(0,10,6) od;

                         [0, 2, 4, 6, 7, 10]


                         [0, 1, 5, 6, 8, 10]


                         [0, 2, 4, 5, 8, 10]

Alec

It can be done more simple using randcomb,

q:=(a,b,n)->[a, op(a+~combinat:-randcomb(b-a-1,n-2)), b]:

For example,

to 3 do q(0,10,6) od;

                         [0, 2, 4, 6, 7, 10]


                         [0, 1, 5, 6, 8, 10]


                         [0, 2, 4, 5, 8, 10]

Alec

And what is the output of

libname;

?

Alec

The launching is not such a big problem. The problem is getting the output of qHull (or other program) back in Maple. Passing several input options, which usually is done by several command line commands, and possibly using echo, also may be a problem. As Axel said, that can be done using a .bat script, but still all the procedure looks too complicated - use Maple to enter the input parameters into a .bat script, then using system command to launch that .bat script, then read the output from a text file produced by that script.

Why in the world would one want to do that?

Same in another thread with using Maple for batch processing images, or using listdensityplot. Certainly, such things are possible, but why go into all that trouble when it can be done much more simple in Python or even in C# ?

Alec

 

The launching is not such a big problem. The problem is getting the output of qHull (or other program) back in Maple. Passing several input options, which usually is done by several command line commands, and possibly using echo, also may be a problem. As Axel said, that can be done using a .bat script, but still all the procedure looks too complicated - use Maple to enter the input parameters into a .bat script, then using system command to launch that .bat script, then read the output from a text file produced by that script.

Why in the world would one want to do that?

Same in another thread with using Maple for batch processing images, or using listdensityplot. Certainly, such things are possible, but why go into all that trouble when it can be done much more simple in Python or even in C# ?

Alec

 

It's from my past experience. Several years ago I used Maple much more intensively than now. I'm sure that there are a lot of examples posted in various Maple groups and Maple newsgroup (at least several years ago.)

An example with echo causing problems in ssystem in Standard in Linux was posted recently on this site (in the thread about representing real numbers in base 12.)

Alec

It's from my past experience. Several years ago I used Maple much more intensively than now. I'm sure that there are a lot of examples posted in various Maple groups and Maple newsgroup (at least several years ago.)

An example with echo causing problems in ssystem in Standard in Linux was posted recently on this site (in the thread about representing real numbers in base 12.)

Alec

It's not Maple, it's some versions of Windows (ans some settings in Windows) cause problems with spaces. It works in some Windows versions, and doesn't work in others (or in the same versions, but with different settings.)

Sometimes it works inside a string, so the ssystem command should include a string inside a string, and that seems to be often causing problems in Standard, while working OK in Classic.

Alec

First 52 53 54 55 56 57 58 Last Page 54 of 180