Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@bellaqueame As far as I'm concerned, there's no practical difference between an infinite equivalent class and its canonical representative. For example, consider 3/5: Is it just a rational number, or is it the equivalence class of all pairs of integers (n,m) such that 5*n = 3*m? And does making that distinction make any practical difference? Only set theorists make that distinction, and then only when they're being pedantic.

My command Rem(..., f, x) mod p does include the ring extension element! It's the x, and I told you to pass the x to your FastEval.

Doesn't the following code do (over a randomly generated ring) what you describe above?: 

restart:

p:= 3: d:= 2: q:= p^d: n:= 2: #size parameters
interface(rtablesize= 2+p^(n*d)):

alias(T = RootOf(Randprime(d, z) mod p, z)): #random degree-d field extension

#explicit list of ring elements:
R:= [seq(rtable(
   (0..p-1)$(n*d), 
   ()-> add(add(args[d*i+j+1]*xi^i, i= 0..n-1)*T^j, j= 0..d-1)
))];

#random polynomial that splits into n distinct linear factors over F_q:
f:= sort(
   collect(Expand(mul(xi-a, a= combinat:-randcomb(R,n))) mod p, xi, expand), 
   xi
);
 
#table of powers of every ring element:
<
   <seq(a^(` q `^k), k= 0..n)>^+,
   <seq(`=======`, k= 0..n)>^+,
   Matrix((nops(R), n+1), (i,j)-> Powmod(R[i], q^(j-1), f, xi) mod p)
>;

Powmod(a, n, f, x) mod p is equivalent to Rem(a^n, f, x) mod p but is a little more efficient.

Regarding ceil(log[2](n)), it's equivalent to

ceillog2:= (n::posint)-> `if`(n=1, 0, 1+ilog2(n-1)):

 

@acer Vote up. Since these commands are undocumented, do you have any idea what mtr and mtd stand for? That would help me remember them.

@izhammulya It's not at all strange that the minimal solution sets those variables to their maximal values. All coefficients are positive and those variables appear in equality constraints but not the objective. I think that you simply made a mistake by including them in the constraints. Removing those variables from the problem entirely is equivalent to setting them to 0.

@izhammulya If you think that those variables should be 0, then simply remove them from the problem!

@izhammulya Please post your problem as an attached worksheet. For one thing, it'll be much easier to read. You can attach a file by using the green uparrow on the toolbar of the MaplePrimes editor.

I could write a procedure that does that, but before I do, I'm curious what the purpose is for you. Any of the following commands is likely to provide more-relevant information about a DAG and its substructures:

indets, #by far the number-one choice
ToInert,
dismantle, #gives a visualization, but difficult to process results programmatically

disassemble@addressof

@jbuddenh Yours is the second problem in a week reported in MaplePrimes caused by the poor rendition of code examples in Maplesoft's online help pages. As I told that other Questioner, I recommend that you always compare with the in-program help (in this case ?Statistics,Distributions,Uniform). And for additional clarity, press F5 to display the code in a monospaced font if it's not already thus displayed.

@minhhieuh2003 Thanks, I totally understand your Question now.

The answer depends on whether Typesetting:-mrow has an option akin to tabulation, such as placement at a certain distance from the left edge of the virtual box that it works in. Trying to fit in a certain number of space characters is unreliable if you're not using a monospaced font.

@Carl Love Upon deeper analysis, it looks like your character is equivalent to the ASCII &Assign;, which leads me to believe that you got it from a palette. I'd recommend that those palette symbols be reserved for display purposes and that only keyboard characters be used for coding purposes. While this recommendation is not strictly required, it does help keep one out of trouble.

I think that most of the readers here are having trouble understanding your Question. Would you please elaborate, rephrase, and include an attached worksheet? Do you mean that you want to use the TAB key to change the selection of multiple-choice answers?

@sand15 This Reply is not directly related to your question from two Replies above, but I wonder what you hope to achieve by setting UseHardwareFloats:= true. Do you believe that if you don't do this then it's equivalent to setting it to false? That's not the case: There's a middle value between true and false named deduced, which is the default value and the one most useful for most purposes.

@Carl Love After seeing a Reply by Acer above, I realize that of course doing 2 substitutions is better than doing n indexing operations, so I change the above to

n:= 10: 
cat(seq(subs([0= "T", 1= "H"], rtable(1..n, random(0..1)))));

Note that even 0 is a pointer in Maple (as can be seen by addressof(0)), so the substitution of 0 only occurs once rather than at every array position that contains (likewise for 1, of course).

Something that Daniel just said makes me think that maybe there's a possibility that you want to share RAM memory across some open worksheets, so that when a variable is changed in one, it's also changed in the other (because they're literally the same variable, with the same memory address). This is easy to do in Maple if you accept these conditions:

  • It's all or nothing: To do this, you must share all memory: Anything that can be seen in one worksheet can be seen in the other, including the countless global variables that are deeply hidden in the Maple library code that you probably don't know about.
  • It's totally up to you to avoid the crazy conflicts that can occur if the two worksheets write to the same memory.

If this is what you want, let me know. It's trivial to set this up, and it works decently if you're not actively executing code in both worksheets at the same time. This kind of link between worksheets is broken when they're closed; it's not like a workbook.

@sand15 You wrote:

  • It's rather difficult to compare the results produced by Q3 with the true ones. 

I knew that the limitations of hardware-float arithmetic would kick in at some point, so I was already suspicious. To check the results, I simply summed them. The command add can be applied to any list or rtable without needing an index, as in add(L). For NumberOfDice > 22, the sums are different from 1, although they're close. For NumberOfDice > 394, the sums are undefined, which indicates that you not only overflowed the mantissas (the exact part of an hfloat), but you also overflowed the exponents.

  • I suppose your observation definitely discredits Q3?

It's hard to argue for undefined as a credible answer.  :-)

A procedure to do convolutions in Maple's default exact rational arithmetic could be written in 3-5 lines. It wouldn't be as fast as hfloat, but you'd probably be surprised how fast it is.

Another alternative is to use LinearAlgebra:-Modular, doing the convolutions for a set of prime moduli (all less than 2^25) whose product exceeds the product of the number of sides of the dice, and reconstructing the exact result with LinearAlgebra:-Modular:-ChineseRemainder. You could use ArrayTools:-FlipDimension to express each entry of the convolution as a dot product of two vectors. It sounds complicated, but it may possibly be worth it because Modular is amazingly, blindingly fast when used in hfloat mode with moduli < 2^25. I think it could be done in 20-30 lines.

@mmcdara It's a good try, and I do believe that there's a good solution to this problem using convolutions. However, your procedure Q3 has several shortcomings, and one very serious error that will be difficult to fix: SignalProcessing:-Convolution uses hardware-float arithmetic, where the largest integer that can be represented exactly is (IIRC) 2^53 - 1 (I'm sure that it's some number close to that). Because of this, Q3 returns incorrect results for NumberOfDice > 22 and total nonsense for NumberOfDice > 394 (using the "default" initial die [1,2,3,4,5,6], with similar cutoffs for other initial dice).

First 286 287 288 289 290 291 292 Last Page 288 of 708