Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

There is no attached worksheet.

If your code works at all, then your usage of modpol is not supported by its help page. It says that the 4th argument should be prime and that the command works with polynomials over fields of prime order (rather than prime-power order).

Using a much smaller example, please verify that your usage of modpol works.

Does a folder "namef" (with a properly qualified name) appear listed in your global variable libname?

@vs140580 And here's an iterator for combinations:

Combos:= proc(S::set, k::nonnegint)
description `Iterator for k-combinations of S`;
option 
    `Reference: Donald Knuth, _The Art of Computer Programming_`,
        `section 7.2.1.3, Algorithm L`
;
local c:= Array([$1..k, nops(S)+1, 1]);
    proc()
    local j, R:= S[[seq](c[..k])];
        for j while c[j]+1 = c[j+1] do c[j]:= j od;
        c[j]++;
        R
    end proc
end proc
:
Get:= Combos({a,b,c,d,e,f}, 3):
'Get'() $ binomial(6,3);
{a, b, c}, {a, b, d}, {a, c, d}, {b, c, d}, {a, b, e}, {a, c, e}, {b, c, e},
{a, d, e}, {b, d, e}, {c, d, e}, {a, b, f}, {a, c, f}, {b, c, f}, {a, d, f}, 
{b, d, f}, {c, d, f}, {a, e, f}, {b, e, f}, {c, e, f}, {d, e, f}

binomial(6,3)=nops({%});
                            20 = 20

 

@vv Yes, I noticed. That's why I multiplied by the local `1` (which converts to 1 at the finish).

@ThU The solutions do not approach infinity as (or C) approaches 0. And, if you use my method, the solutions can be directly evauated at C=0 to get the obvious limiting value 2*Pi.

@tomleslie I understood your points from the very beginning; I wouldn't say that you made them badly. However, you are judging this based on a feeling that this should be a mathematical operation when it's only intended to be a syntactic operation.

Definition: An operation f is a mathematical operation if whenever e1 and e2 are mathematically equivalent expressions of the type that f operates on, then f(e1) is mathematically equivalent to f(e2). In brief, f distributes over the equals sign.

Now, if my SplitProduct or Acer's F were intended to be mathematical operations, then your objections would have some merit; but, they were not so intended. Like a great many operations in Maple, they are purely syntactic.

@Kitonum To get 10-digit accuracy using 0 as the series expansion point requires n > 167. I think that you'd get much better accuracy by using 10 (the integral's upper limit) rather than 7.5 as the expansion point and treating the exp(10^2) as a separate factor.

Do you mean that you want an approximation based on a finite number of terms of the series?

@vs140580 Here is a crude implementation of Heap's permutation algorithm (see Wikipedia article) as an iterator. That is, this procedure returns another procedure such that each call of this latter procedure produces 1 permutation. 

Permute:= proc(L::set)
local n:= nops(L), A:= Array(0..n-1, [L[]]), c:= Array(0..n), i:= 0;    
    proc()     
    local R:= [seq](A);
        while c[i] >= i do c[i++]:= 0 od;
        if i=n then return R fi;
        if i::even then A[[0,i]]:= A[[i,0]] else A[[c[i],i]]:= A[[i,c[i]]] fi; 
        c[i]++; i:= 0;
        R
    end proc  
end proc
: 
#Usage:   
Get:= Permute({a,b,c}):
'Get'()$3!;
[a, b, c], [b, a, c], [c, a, b], [a, c, b], [b, c, a], [c, b, a]

Since the above is written entirely with primitive commands, you can see directly that it uses nearly 0 memory (if you don't save the output in a memory container such as a list, set, or sequence).

A more-sophicated algorithm is needed to efficiently generate the permutations of a multiset (i.e., with repeated elements).

@acer Yes, I understand that the order of L makes no difference programmatically. I thought that the OP would prefer that the numeric order of the coefficients correspond to the order of L, especially given the originally posted code with commented-out corrections. Also, I'd guess that the actual use case is far more complex than the posted example.

Edit: I just now read your edit about the arbitrariness of order. Okay, I guess that you see the same issue that I do.

@Neel Here's a simpler way, using coeff instead of coeffs. I probably would've posted this had I thought of it before I thought of the other.

sol:= W(x) = 
    _C1*(cosh(alpha*x)-sinh(alpha*x))
    + _C2*(cosh(alpha*x)+sinh(alpha*x))
    + _C3*sin(alpha*x) + _C4*cos(alpha*x)
:
V:= [sinh, cosh, sin, cos](alpha*x):
sol:= collect(sol, V):
subs(coeff~(rhs(sol), V) =~ D||(1..nops(V)), sol);

The output is identical to the output in my first Answer.

I totally understand your concern that Maple may run out of memory if you represent the totality of combinations\permutations in a single Maple structure before writing that structure to Excel. But doesn't that concern apply to Excel also? Or does Excel manage a balance between RAM and disk storage for an active worksheet (in a more sophisticated way than Maple does)?

@acer Is it assured that the order of CL corresponds to the order of L? My concern about this was why I made CL (my C) a table. 

@Joe Riel So, are you saying that a variable local to a static module needs to itself be declared static even though a variable local to a static procedure does not need to be declared ​​​​​​static? And does that need continue no matter how deeply nested the modules are? 

Logically, I would think that anything local to anything static couldn't possibly be non-static.

First 184 185 186 187 188 189 190 Last Page 186 of 708