jayped007

90 Reputation

4 Badges

14 years, 109 days

MaplePrimes Activity


These are replies submitted by jayped007

First, thanks for the feedback -- I do appreciate it!

--

When I try to use the definition for "flat" in Maple 9; it "compiles"; but does not work with polynomial expressions.  I get the following error back when I try to use it:

  "Error, (in type/specop) testing against an invalid type"

However, it appears to work beautifully in Maple 11.

Impressively fast!

--

When I try subsindets(expr, integer, 1), I get a different answer than I expect

(in my example; it should return -2*x1*x2*x3, and instead it returns 4*x1*x2*x3).

Not sure what is going on there.

Recall: expr was 1-(1*x1*x2)*(1-x1*x3)*(1-x2*x3)

--

I will have to spend some time to learn subsindets, and specop

before I really understand what is going on in "flat". :)  My guess is

it is replacing x||i^k by x||i; by replacing k by 1 (checking that k is a

positive integer).  But those are functions I have not really seen

previously.  Probably very good tools for the Maple toolbag though.

-Jay

 

The whole thing was just to come up with a way to estimate the probability of all faces showing up when you roll 8 die. So; only the count was needed. Thanks!
Somehow building the set s and counting it, didn't seem like what I wanted to do. Too much imperative programming in my past I guess. I went back to using a proc, with basically a variable passed by reference to keep the count. Is that against the Maple way? :) I guess its "passed by name", which is a hard concept to get used to for a C programmer. :) f := proc(s::set, x::evaln(integer)) if nops(s) = 6 then x := eval(x) + 1; end if; return(NULL); end proc: roll:= rand(1..6): k:=100000:count := 0: seq(f({'roll()'$8},count), i=1..k): printf("count=%d, prob= %d/%d = %f\n",count,count, k, evalf(count/k));
I am getting an education on different ways to attack the problem. Thanks for all the tips!
Very nice! So then, the whole thing can be done with a proc at all. roll := rand(1..6); count := 0; k := 100000; for i from 1 to k do; dice := ['roll()' $8]; if evalb(convert(dice,set) = {1,2,3,4,5,6}) then count := count + 1; end if; end do: printf("count=%d, prob= %d/%d = %f\n",count,count, k, evalf(count/k));
I ran this on Maple 11 on my machine; and it also stopped after 1500 loops. However, it came up with the same result that you list: *** Max loops in concensusList reached, terminating *** Minimal sum: ACD' + ABC' + A'BE + ADE' + CDB' Looks like either a bug, or the algorithm (or my implementation of it) ... is not very efficient. -Jay
I used Maple extensively in Numerical Methods, Mathematical Statistics and in Discrete Math courses to solve problems. I use it mainly as a mathematical programming platform.
<> Not quite. From the Maple 11 documentation for BooleanSimplify "Note: BooleanSimplify does not guarantee that the returned expansion is a minimum sum of prime implicants" Presuming my code works correctly; it does return a minimum sum of prime implicants. On the other hand. The Logic package may handle more complex expressions (parenthesized). There may be newer/better ways to implement this. Not claiming this is the the best possible solution. Just the one we had to follow in my computer science class. :) Another one I have heard of is "Quine-McCluskey". -Jay
Page 1 of 1