Carl Love

Carl Love

28100 Reputation

25 Badges

13 years, 105 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@crockeea 

Sorry, once I found a fix for pdf1, I didn't continue because I just assumed that the other pdfs were simply your attempt to correct pdf1

While it is true that your procedures pdf3 and pdf4 don't return a purely numeric value when called with symbolic input, they still evaluate and return a mostly numeric floating point result. This is enough to mess up the computation.

It's easy the analyze what's the special value returned for symbolic input. Just perform the steps on the desktop. I'll do it for pdf1i mod 2 returns i. (The is treated as a polynomial, and the mod is applied to its coefficients.) doesn't equal 1, so the else branch is taken, which produces a purely numeric result. floor(i/2) returns unevaluated. On the second round, the mod also returns unevaluated. Once again, the result doesn't equal 1, so the else branch is taken, producing a purely numeric result. So the "magic" value is (1-pr[0])*(1-pr[1]) evaluated at whatever the setting of Digits is.

By the way, the distinction between procedures declared with proc and those declared with the arrow is very small. Don't read too much into it.

@MDD The coefficients are necessarily already computed at the time the determination of false is made. They are only returned to potentially help with debugging is, which occasionally returns false when it should return true for some extremely complicated expressions that are identically equal to 0.

Note if the input is restricted to polynomials, then you can use the procedure PolyLinearCombo from the other thread. That procedure doesn't use is; the determination true or false is made just by looking at the coefficients. 

Can you post the code? It's very easy to write parallel code that deadlocks and yet works as documented. I'm not saying that that's what's happened in your case, but it does need to be ruled out before searching deeper in the system software for a bug.

You can test your ability to run parallel code like this:

WasteTime:= proc(timeout::positive)
local st:= time();
     while time()-st < timeout do end do;
     time() - st
end proc:

Threads:-Seq[tasksize= 1](WasteTime(30), k= 1..kernelopts(numcpus));

Change the 30 (seconds) to whatever amount of time you need to verify that all threads are running.

I think that what you're calling a "furtex" is called a Mutex in Maple.

@Kitonum I like your way better than my way (evaluation of the variables at random values) for those problems that your way works on (all polynomials and the target is 0). Here is a variation of your way that sets all the free variables to 1 and returns just a list of nontrivial annihilating coefficients.

CoeffsOfLinComb:=proc(L::list(polynom), V::list(name))
local
     c, k, C:= {c[k] $ k= 1..nops(L)},
     S:= solve({coeffs(expand(`+`((C*~L)[])), V)}, C),
     F:= indets(rhs~(S), name) intersect C=~ 1
;
     eval([C[]], eval(S,F) union F)
end proc:

Let me know if you want it translated to Maple 12.

The error message shown in your worksheet is 

Error, (in CodeGeneration:-IssueError) cannot resolve types in {numeric, CodeGeneration:-Names:-ArrayType(numeric, CodeGeneration:-Names:-ArrayRanges(1 .. CodeGeneration:-Names:-unknown), CodeGeneration:-Names:-ArrayOptions())}

Why do you think that this error is due to the length of the expression?

What is the value of your n? It must have a numeric value for you to get any simplification at all.

Several points:

1. Your model seems quite unusual with the c being used in two ways. What's the theoretical justification?

2. Please post your data. The plaintext format that you used before worked well as it could be cut-and-pasted directly into a worksheet.

3. The method that I used for your last problem can't be used on this one. That problem was only slightly nonlinear, and this one is highly nonlinear. Specifically, for that problem I could isolate the nonlinearity into a single dimension where I could do a global branch-and-bound search for the minimum.

4. DirectSearch:-DataFit is very good if you use several of its 36 methods (9 metrics x 4 minimization algorithms) and then take the best answer. It has much more flexibility than Statistics:-NonlinearFit.

5. You can install the DirectSeach package in your own file space---you don't need any permission from your University. If you installed it in your own file space, it would be just like any other Maple program that you personally wrote.

Would you please supply a more-specific example? And would you show some steps in Maple toward what you are trying to accomplish, and where those steps fail? I think that the command Primfield used in conjunction with evala may be part of an answer to your problem, but I'm not sure. See ?Primfield, and ignore the examples the use mod rather than evala.

I've added some features to LinearCombo based on user requests. The first is that parameters are now allowed:

LinearCombo([a*x+b*y, x^2+a*y], x^2+x+y, params= {a,b});

The params argument is optional, and, if present, it must be a set of names. A true result indicates that the returned coefficients form a linear combination for all values of the parameters. A false result indicates that there are no such coefficients. This is very different from finding the values of the parameters for which there is linear dependence or independence.

The second change is that the returned value is now always a pair. The first member of the pair is a trivalent Boolean value (i.e.truefalse, or FAIL), and the second is the list of coefficients. Note that in the vast, vast majority of cases a false result is correct and thus the returned coefficients are meaningless. In case the returned value is false, [], the result is guaranteed.

LinearCombo:= proc(B::list(algebraic), T::algebraic, {params::set(name):= {}})
local
     V:= indets([B,T], And(name, Not(constant))) minus params,
     nV:= nops(V),
     c, #linear coeffiecients
     k, #index
     nB:= nops(B),
     C:= [c[k] $ k= 1..nB],
     Eq:= `+`((C*~B)[]) - T,
     Eqs, S, Z
;
     for k to 2 do
          Eqs:= {'eval(Eq, V=~ {'rand()' $ nV})' $ nB};
          if nops(Eqs) = nB then break end if;
     end do;
     if k = 3 then
          error "Almost certainly, all expressions are constant"
     end if;
     S:= solve(Eqs, {C[]});
     if S=[][] then return false,[] end if;
     Z:= indets(rhs~(S), And(name, Not(constant))) minus params=~ 0;
     S:= eval(S,Z) union Z;
     is(eval(Eq,S) = 0), simplify(eval(C,S))
end proc:

@erik10 

The following seems too trivial to post, but maybe it was what you had in mind:


restart:

TwoDice:= {combinat:-permute([$1..6, $1..6], 2)[]};

{[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]}

H:= select(x-> `+`(x[]) = 5, TwoDice);

{[1, 4], [2, 3], [3, 2], [4, 1]}

G:= select(x-> x[2] < 3, TwoDice);

{[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2]}

#Complement function:

C:= A-> TwoDice minus A;

proc (A) options operator, arrow; `minus`(TwoDice, A) end proc

#Probability function:
#Use two arguments for conditional probability.

p:= proc(A::set, B::set:= TwoDice)
     nops(A intersect B)/nops(B)
end proc;

proc (A::set, B::set := TwoDice) nops(`intersect`(A, B))/nops(B) end proc

p(H);

1/9

p(G);

1/3

p(H union G);

7/18

p(H intersect G);

1/18

p(H,G);

1/6

p(G,H);

1/2

#Law of total probability illustration

p(H) = p(H,G)*p(G) + p(H,C(G))*p(C(G));

1/9 = 1/9

 


Download prob.mw

@Axel Vogt I decided to avoid the issue of cases and dependencies by using assuming real.

Did you know that you can do a parameter-case analysis of a definite integral by including the option AllSolutions? For the problem at hand, this gives very lengthy and wide output for the first integral, with many invocations of piecewise. I didn't do it for the second integral.

@Axel Vogt 

Absolutely. Despite numerous attempts, Markiyan has come up with only one example of a transcendental identity for which the program returns FAIL, which, as I've said, is unfortunate but not incorrect. (And my computer with Maple 18 returns successfully for that identity. I don't know why his is returning FAIL.) (And since when do we expect Maple programs to return a definite answer for all transcendental expression input?) For the four other example that he posted where he thought that my program was wrong, it turns out that the program was correct.

I've tested the program extensively on polynomials (up to 36 polynomials in three variables), and less extensively on transcendental identities involving sincos, and exp, including ones with complex coefficients (e.g.LinearCombo([sin(x), cos(x)], exp(I*x))). It could use more testing on algebraic and rational functions.

It seems like Markiyan is compelled to poison the well.

@Kitonum C'mon, now: That's a vast overstatement of the power of the power of identify. It really only knows a few transcendentals: Piln(2), ln(3), exp(1)Zeta(3), and Zeta(5). You can teach it others (see ?identify), but that means that you need to have a guess of the basis transcendentals in your expression.

@MDD As my program is currently written, it treats all nonconstant names as variables. I'll have to make some modifications for it to be able to treat some as parameters. I'll work on it this evening.

@Markiyan Hirnyk 

You already presented that example in your Reply "Still". The answer FAIL is unfortunate, but not incorrect. (It's also the fault of is so not really about my program.) So this is not a "counterexample". Like I said (three times now), I never claimed that this program works for all transcendental expressions. Even so, you have yet to come up with a single instance where my program returned incorrect results. If you think my program is so bad, can you name any other program or algorithm that finds the linear coefficients for transcendental identities?

So how about a polynomial example? 

First 481 482 483 484 485 486 487 Last Page 483 of 709