Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@MDD 

Okay, I'm glad that you already understand some of it. That means I can move faster through this. Let's consider the next line:

S:= solve({coeffs(expand(`+`((C*~L)[])), V)}, C),

especially the part at its heart, `+`((C*~L)[]).

Your question gave me the impression that you thought that the C* and the ~ were separate operations. No: The preceded by almost any other binary operator makes the operator an elementwise operator (see ?elementwise). So C*~L multiplies the coefficients by the polynomials and produces a new list or set (it doesn't matter which in this case) containing the products.

Appending [] to a set or list extracts its underlying sequence of elements. Passing these to `+` adds them. So `+`((C*~L)[]) computes the dot product of and L. The rest of the line expands this polynomial, extracts its coefficients with respect to V, sets them to 0, and solves this linear system for the variables C. The final result of this is a set S of the form

{c[1]=..., c[2]=..., ..., c[n]=...}.

Note that it's a homogenous and square linear system, so it always has a solution, which solve always finds.

Now let's consider the next line

F:= indets(rhs~(S), name) intersect C=~ 1;

First consider the rhs~(S). This applies rhs to every element of S, producing a new set containing just the right-hand sides of the equations in S. All the names in this set are extracted. This represents the free variables in the solution set S, which is why I call it F. From these free variables, I only want the linear coefficients, not the parameters; so, I intersect with C

Then I want to equate all these free variables to 1. My choice of is arbitrary; I could use any nonzero value, because I want to return, if possible, a definite but nontrivial solution to the homogenous linear system. The elementwise operation A =~ 1 forms with every member of A an equation whose right side is 1. So the final result of this line is a set F of the form

{c[a]=1, c[b]=1, ...},

where the c[a], c[b], etc., represent only the free variables in that are also in C.

Now let's consider the last line of CoeffsOfLinComb, which forms the return value:

eval([C[]], eval(S,F) union F) .

This takes the set C, forms the corresponding list [C[]], and evaluates each of these using 1 for all the free linear coefficients. The final result is a list of length nops(L) that contains only numbers and parameters.

Now let's consider the next procedure, PolyLinearCombo, and its first executable line

C:= CoeffsOfLinComb([f, F[]], V);

This takes the target polynomial f, makes it the first element of a list [f, F[]] and finds the linear coefficients, if any, that are needed to produce 0.

The final line is 

if C[1]=0 then (false, []) else (true, -C[2..] /~ C[1]) end if.

If the coefficient of f is 0, then is linearly independent of F. Otherwise, the dependency coefficients are the coefficients of F divided by the negative of the coefficient of f. The elementwise operator /~ performs the division on all the other coefficients. The C[2..] means the sublist of starting with the second element and going to the end.

@mattcanderson1 

It is ambiguous whether the OP is interested in the convergence/divergence of a series or of a sequence. Since the word "series" is used and "sequence" isn't, I think that a series is more likely. But then there's "Is this function convergent or divergent?", which implies an interest in the sequence.
 

@MDD There's a lot to explain. I may do this a few lines at a time. I'll start with procedure CoeffsOfLinComb, which is my version of Kitonum's algorithm. I guess that the first line that needs some explanation is 

  V::set(name):= indets(L, And(name, Not(constant))).

This declares the second parameter to be called V. If a corresponding second argument is passed, it must be a set of names; if a second argument isn't passed, then will be assigned a default value of all the names in the first argument, L, that are Not constants (such as Pi).

The next thing that might need explaining is 

C:= {c[k] $ k= 1..nops(L)}.

This declares a local variable C and assigns it the value of a set {c[1], c[2], ..., c[n]} where n is the number of polynomials in (nops(L)). This can be expressed (with the sequencing operator) as "the set of c[k] where runs from to nops(L)."

I'm tired...that's enough for now.

@Kanellopoulos I don't know if the Maple is correct. There is that 1 point (out of the 18 that I checked) with relatively high residuals. Can you check the residuals in Mathematica? 

Maple's algorithm is the "theta method". This is the only method that it ever uses when there's more than one PDE.

@Kanellopoulos It's a moot point now because I've already reconstructed your worksheet by cut-and-paste from the PDF, but please, next time, upload the worksheet directly to MaplePrimes using the green up arrow like I said. The Dropbox version is unusable to me.

We can read the PDFs, but not work with them in Maple. Use the green up arrow on the toolbar in the MaplePrimes editor (last item on the second row of the toolbar) to upload a Maple worksheet in .mw or .mws format.

Please post the equations, the Maple code that you used to solve them, and the Maple code that you used to plot. Regarding checking the solution: That is generally possible through numeric differentiation with the fdiff command.

@MDD It's done. Please find procedure PolyLinearCombo in an Answer below.

@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.

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