Joe Riel

9660 Reputation

23 Badges

20 years, 12 days

MaplePrimes Activity


These are replies submitted by Joe Riel

I assume you mean with the constraint that the 'sum' of each equals [1$12].  In that case, the problem is equivalent to finding the number of partitions of a set of m*k  elements into m sets of k elements (here k=3, m=4). 


k := 3: # specialization to 3
req := f(m) = binomial(m*k-1,k-1)*f(m-1):
rsol := rsolve({req, f(0)=1},f(m));
                     (-m - 1)  m                                1/2
                    2         9  GAMMA(m + 2/3) GAMMA(m + 1/3) 3
            rsol := -----------------------------------------------
                                          Pi


eval(rsol, m=4);
                                     15400

The recurrence f(m) = binomial(m*k-1,k-1)*f(m-1) comes from the following consideration. Choose the first set of a partition by picking the first element of the set of m*k elements, then choosing k-1 elements from the remainder.  There are binomial(m*k-1,k-1) ways to do this.  We are left with (m-1)*k elements. There are f(m-1) ways to partition these remaining elements. f(m) is the product.

Expanding f(m-1), etc, then expressing the binomials as factorials and canceling gives the general expression

fmk := (m*k)!/m!/(k!)^m:
eval(fmk, [m=4, k=3]);
                                                       15400
eval(fmk, [m=4, k=2]); # your previous problem
                                                        105

It's hard to suggest anything without knowing what it is you are doing.  Your original comments indicate that you are looking for the minimum difference, however, the code you presented doesn't quite do that---rather, it returns a list rather than a single value. An example would clarify.

It's hard to suggest anything without knowing what it is you are doing.  Your original comments indicate that you are looking for the minimum difference, however, the code you presented doesn't quite do that---rather, it returns a list rather than a single value. An example would clarify.

Note that you can use a recurrence to solve for the number of partitions.  That is, given a list of 2*m elements, the number of partitions into pairs can be expressed as the recurrence

req := f(k) = (2*k-1)*f(k-1):

Use ?rsolve to solve this


f := rsolve({req, f(0)=1}, f(m));
                                  m
                                 2  GAMMA(m + 1/2)
                            f := -----------------
                                         1/2
                                       Pi


eval(f, m=4);
                                      105

Note that you can use a recurrence to solve for the number of partitions.  That is, given a list of 2*m elements, the number of partitions into pairs can be expressed as the recurrence

req := f(k) = (2*k-1)*f(k-1):

Use ?rsolve to solve this


f := rsolve({req, f(0)=1}, f(m));
                                  m
                                 2  GAMMA(m + 1/2)
                            f := -----------------
                                         1/2
                                       Pi


eval(f, m=4);
                                      105

There's nothing wrong with that code.  What version of Maple are you using?

There's nothing wrong with that code.  What version of Maple are you using?

(neg,pos) := selectremove(`<`, re, 0);
(neg,pos) := selectremove(`<`, re, 0);

The cause is a more subtle error; M and N are always the same matrix because of the way you initially assigned them. The $ operator evaluates the lhs before duplicating it, so

(M,N) := Matrix(n,n,1)$2;

assigns a single Matrix to both M and N. One way to avoid that is to delay the evaluation of the left side

(M,N) := 'Matrix(n,n,1)'$2;

I prefer not using $ unless I want all the objects to be the same and instead do

M := Matrix(n,n,1);
N := Matrix(n,n,1);

The cause is a more subtle error; M and N are always the same matrix because of the way you initially assigned them. The $ operator evaluates the lhs before duplicating it, so

(M,N) := Matrix(n,n,1)$2;

assigns a single Matrix to both M and N. One way to avoid that is to delay the evaluation of the left side

(M,N) := 'Matrix(n,n,1)'$2;

I prefer not using $ unless I want all the objects to be the same and instead do

M := Matrix(n,n,1);
N := Matrix(n,n,1);

Try replacing xy with x*y

Try replacing xy with x*y

In case it wasn't clear, Robert is referring to his extreme game, where coin 2 always loses.  That isn't the case with the actual Parrondo coin.

In case it wasn't clear, Robert is referring to his extreme game, where coin 2 always loses.  That isn't the case with the actual Parrondo coin.

First 94 95 96 97 98 99 100 Last Page 96 of 195