Carl Love

Carl Love

26488 Reputation

25 Badges

12 years, 309 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@delvin What do you mean by "fixed"? You simply typed a - where you should've typed =. That's all there is to it.

Regarding tanh: You can simply enter tanh(a+b) and tanh(a-b). Maple knows these functions, and you don't need to provide any further definition.

@delvin This is your input for pde2 from your attached worksheet:

pde2:= beta[3]*beta[4]*diff(U(xi), xi, xi) - (beta[4]*diff(U(xi),xi))*(u(xi[n - 1])-2*U(xi)+u(xi[n + 1]));

If you want that to be equivalent to the displayed equation at the top of your worksheet, then change the central (minus sign) to = (equals sign).

Regarding tanh, are you asking because you think that perhaps Maple's definition is different from what you expect? If so, what do you expect?

@aimLow The fact that your error messages are accompanied by your input in a red-dashed rectangle indicates that those two lines have a syntax error specific to 2-D Input. In such cases, Maple cannot translate the input into equivalent 1-D Maple-code input. The error is not related to your use of sum. If you tell me what output you expect from each command, I might be able to help further.

@Kitonum Maple understands indefinite sums, and they can't be adequately replaced with add, for example:

sum(i^2, i);
            1/3*i^3 - 1/2*i^2 + 1/6*i                     

 

@sursumCorda If you tell me for your most-recent case what you expect the quotients to be, I may be able to adjust my program. What does Mathematica return? The package Groebner might have something that helps.

The direct problem is that regardless of the elimination order used, the 2nd remainder has a denominator containing the 3rd variable.

As I said, my knowledge of this area of math is limited. It may be that this problem cannot be solved by using quo and rem as the only algebraic operations. It may require Groebner or something similar.

What does the operator symbol N (in "blackboard bold") in paragraph 1 mean? 

@sursumCorda 

Here is a procedure to reconstruct the original from the output of PolynomialReduce(P,R,V). It only requires one preliminary step to your expand(inner(...)) + ..., and it needs to be passed the elimination order that was used.

PolyRecon:= proc(Q::list(polynom), Rm::polynom, Z::list(polynom), V::list(name))
local k, z:= <Z>, v;
    for k,v in V do z[k+1..]:= rem~(z[k+1..], z[k], v) od;
    expand(<Q>^+.z + Rm)
end proc
:
(P,R,V):= (x^5 - x*y^6 - x*y, [x^2 + y, x^2 - y^3], [y, x]):
PolynomialReduce(P,R,V);
 
[    5    3  4    5  3    7  2    9     / 10    \      7    3]   3
[-x y  + x  y  - x  y  + x  y  - x  y + \x   - 1/ x, -x  + x ], x 

PolyRecon(%, R, V);
                            6    5      
                        -x y  + x  - x y
evalb(%=P);
                              true
V:= [x,y]:
PolynomialReduce(P,R,V);
                  [ 3           3      ]      
                  [x  - x y, x y  - x y], -x y

PolyRecon(%, R, V);
                            6    5      
                        -x y  + x  - x y
evalb(%=P);
                              true

 

@sursumCorda I wouldn't expect your reconstruction process to return the original, just something equivalent to the original under the given reductions. It seems to me that it does that. In other words, for any P, R, V such that PolynomialReduce(P,R,V) returns a result, I think that it'll always be true that

PolynomialReduce(expand(inner(R, PolynomialReduce(P,R,V)[1])), R, V)[2] = 0

Note that for each iteration of my loop, all future divisors are also reduced.

@sursumCorda The elimination order matters a great deal in these problems. For the case shown, 
rem(y^3 - y, x^3 - x, y) = 0, so for the second loop iteration, the divisor is 0. I suppose one could trap for this error and try a different order in that case.

(My knowledge of this area of math (I guess it's Commutative Ring Theory?) is limited.)

Here is a worksheet that summarizes all of the above.

restart:

FamN:= [3,2,2,2,1]:  #reduced family sizes for test problem

nf:= nops(FamN):

PS:= [0, seq[scan= `+`](FamN)];  #their partial sums

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

FamS:= (`{}`@`$`@`..`)~(PS[..-2]+~1, PS[2..]);  #partition

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

It:= Iterator:-Permute(PS[-1]):

# For efficiency, split the Iterator's output array into aliases for
# the image of each family under a given permutation:
sp:= output(It):
FamA:= [seq](ArrayTools:-Alias(sp, PS[i], [FamN[i]]), i= 1..nf)
:

# Does the given permutation swap families i and j?
Swapped?:= (i,j)-> local x;
    andseq(x in FamS[j], x= FamA[i]) and andseq(x in FamS[i], x= FamA[j])
:

SwapJ:= (2,3):  #indices of families to swap

V:= 0:  #counter of permutations with the desired property

CodeTools:-Usage(in It do if Swapped?(SwapJ) then V++ fi od):

memory used=1.04GiB, alloc change=26.27MiB, cpu time=11.08s, real time=10.04s, gc time=1.83s

V;

2880

V/10!;  #probability

1/1260

# Now, do the same thing with fixed-size set partitions, which are often
# easier to work with because there are far fewer of them than permutations.

CountPartitions:= (S::list(posint))->
    add(S)!/mul([S[], rhs~(Statistics:-Tally(S))[]]!~)
:

# My flawed first-posted attempt was analogous to this:
CountPartitions(FamN[[({$nf} minus {SwapJ})[]]])
/ CountPartitions(FamN);

1/210

# The correction is:
CountPartitions(FamN[[({$nf} minus {SwapJ})[]]])
/ CountPartitions(FamN) / numboccur(FamN, FamN[SwapJ[1]])!

1/1260

# Now apply what we've learned above to the original problem:
FamN:= [3,4,4,4,1]:
CountPartitions(FamN[[({$nops(FamN)} minus {SwapJ})[]]])
/ CountPartitions(FamN) / numboccur(FamN, FamN[SwapJ[1]])!

1/900900

# So, the probability that this happens for any one of the 3 possible pairs
# of equal-size families, and happens for that same pair in the next
# drawing is:
p1:= evalf(3*%^2);

0.3696307393e-11

# To put that into perspective, the probability of a royal flush in a 5-card
# poker hand with no card exchanges is
p2:= evalf(4/binomial(52,5));

0.1539077169e-5

round(p2/p1);

416382

 

Download SecretSanta.mw

@sursumCorda Here is a procedure that might do what you want. Let me know. I've made it so that the elimination order is an optional third argument:

PolynomialReduce:= proc(
    p::polynom, Z::list(polynom), 
    ord::list(name):= [indets(p, And(name, Not(constant)))[]]
)
local r:= p, v:= ord, z:= Z, k, d;
    if nops(v) < nops(z) then 
        v:= [v[], (indets(z, And(name, Not(constant))) minus {v[]})[]]
    fi; 
    [for k to nops(z) do
         z:= rem~(z[2..], (d:= z[1]), v[k]);
         quo(r, d, v[k], 'r')
     od],
     r
end proc
:      
PolynomialReduce(x^2+y^2, [x-y, y+a]);
                                           2
                   [x + y, -2 a + 2 y], 2 a 

I withdrawal the above Reply. Indeed, my probabilities were too large by a factor of 6. Although my procedure CountPartitions is correct, one does need to consider the order of the images when computing the probability. I confirmed this by doing the analogous problem with the sizes changed to [3,2,2,2,1] and enumerating all 10! ~ 3.6 million permutations, which only takes 11 seconds.

@mmcdara @Christopher2222 The anomalous extra multiplier of 1/6 (exactly) that you're both getting is due to subtly and unawarely implying that the set images of the families under the permutations are in some family-to-family order. In truth, the permuted images of families BCD can appear in any of 3! = 6 orders.

That is why my counting procedure CountPartitions divides out the factorials of the rhss of the Statistics:-Tally of the block sizes S

@Michael 

@acer was only using posint to refer to the type of the suffix on the variable. For example, in _Z2, the is the suffix, and it happens to be a posint. This has nothing to do with what the variable is "assumed to be", which is almost always integer (negative, zero, or positive) for variables beginning _Z. Other common automatically generated variables returned by solve are prefixed _NN (assumed to be a nonnegative integer) and _B (assumed to be 0 or 1). 

Things that are formally assumed about variables are "properties", not "types". It's very easy to confuse properties and types. They are quite similar, but not exactly the same thing. Further adding to the confusion is that many properties and types have the same names, for example integer.

The basic command that checks whether something has a given property (analogous to the type command for types) is is. For example,

solve({sin(x)=0}, {x}, allsolutions);
                         
{x = Pi _Z2~}
is(_Z2, integer);
                             
true
about(_Z2);
Originally _Z2, renamed _Z2~:
  is assumed to be: integer


The about command returns the information also, but in a format that's difficult to use programmatically because it's intended for direct human reading.

Finally, note that objects can satisfy many types simultaneously. The command whattype only returns the most fundamental, and I usually discourage using it. Likewise (this is probably more obvious), variables can simultaneously have multiple properties or assumptions.

Hvae a look at the package SignalProcessing (help page ?SignalProcessing). It might have some commands to help with that. I don't know enough about that branch of math to say for sure.

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