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

@mehdibgh If a function such as x(t) appears in an expression ex both as an argument or part of an argument of another function, say F, and as elsewhere in ex as an ordinary polynomial term, then the concept of "coefficient" in its usual defintion doesn't make sense. For example, what is the coefficient of x(t) in 2*x(t) + sin(3*x(t))? In your example, the functions appear as arguments to diff. If you temporarily remove all the derivatives (by setting them to 0), then you can do the remaining coefficient extraction; like this:

CML:= eval(EqML, diff= 0);
KKNL:= Matrix((nops(EqML), nops(Var[4])), (i,j)-> coeff(CML[i], Var[4][j]));

@Harry Garst The distinction between the a's in the matrix and the a's returned by komb has nothing to do with types indexed or symbol. The a's returned by komb are local to komb because a is declared local there. When a local name (either indexed or symbol) continues to exist outside of the procedure where it was declared local, it's called an "escaped local" (as mentioned by acer). Escaped locals are not bugs--they are often useful--but they can lead to bugs if you're not aware of them. The a's in the matrix are of course not local to komb. They are globals that look the same as the local a's both as prettyprinted and via lprint. However, the command addressof will show that they're different. This is why acer rewrote komb so that var is passed in.

Ever since the keyword thismodule was introduced (many years ago), I've wanted an analogous keyword for "this module's parent". It'd even be more useful than thismodule itself. I guess that Python's super has this functionality. 

To me, there's nothing beautiful about digit patterns that are only apparent in the base-10 representation of a number.

It's trivial (because there's only about 3.3 million possible dates with a 4-digit year) to iterate through all possible digit sequences that represent dates and find those that you think are beautiful.

@max125 If you want to discuss some totally unrelated issue/bug regarding Maple's help system, please start a new thread.

@soran Thank you. That's simple and easy to remember.

Why do you want to declare it constant? What would that allow you to do that you couldn't do by just using it without any special declaration (or assumption)?

I'm not necessarily suggesting that you shouldn't declare (or assume) it a constant, but in my experience it's usually (not always) not particularly useful to do so.

@Maxwell_MA I deleted your Question which was essentially a duplicate of this Question. I will give you some help on this momentarily. 

@vv Vote up.

It's possible to reduce the number of subset comparisons by a factor of more than 2 and the number of union operations by about 2 orders, like this

Dynkin:= proc(C::set(set), X::set:= `union`(C[]))    
local D, newD:= (C minus {{}}) union {X};
    if not `union`(C[]) subset X then 
        error "Invalid input: C must contain subsets of X"
    fi; 
    while newD <> D do
        D:= newD;
        newD:= D union 
            map(
                P-> P[2] minus P[1], 
                select(`subset`@op, combinat:-choose(D,2))
            )
    od;
    D union {{}}
end proc
:

Note that I switched the order of arguments and X (partly so that could be given a default value).

@Rouben Rostamian  The three transformations of your double-angle identities can be done with combine.

The half-angle transformations can be done a bit more efficiently by using a table instead of an if statement: 

`convert/half_angle`:= module()
local
    F:= [sin, cos, tan, cot],
    T:= table(
        F =~ [2*sin*cos, 2*cos^2-1, 2*tan/(1-tan^2), (cot^2-1)/2/cot]
    ),
    TT:= {F[]}(anything),
    ModuleApply:= expr-> evalindets(expr, TT, f-> T[op(0,f)](op(f)/2))
;
end module
: 

 

@Rouben Rostamian  In my opinion, applyrule is crap, and I would always replace it with subsindetsevalindets, or something similar.

Since the third argument to subsindets or evalindets is a procedure, there's no limit to the number of rules you can use or their complexity. To do what you just asked:

subsindets(
    sin(x)+cos(x),
    {sin, cos}(anything),
    f-> 
        local x:= op(f)/2;
        if op(0,f)=sin then 2*sin(x)*cos(x) else 1-2*sin(x)^2 fi
);

 

@lcz While it may not conform to the usual custom, it is far more convenient and efficient for most programming purposes. The first step in almost every GraphTheory program that I write is to construct a table matching the vertex labels to their indices. The indices are also the indices into the adjacency matrix.

@Felipe_123 The question is if there is a P that works, is it sufficient for your purpose to return just that P? Or do you need returned all P that work?

@Joe Riel In procedure Fullnumelems(L1) should be numelems(L1[1]) or its equivalent. There's no good reason why the number of elements in the vectors should be the same as the number of vectors in the lists; that just happens to be true in the example shown.

@C_R Thanks. A triple interobang can indeed be created as a Maple symbol like this

nprintf(`#mo(%a)`, cat("&#8253;"$3));

Such creations can be used like any other Maple symbol (or variable); in particular, they can be function names. Also try

nprintf(`#msup(msup(mo(%a),mo(%a)),mo(%a))`, "&#8253;"$3);

First 101 102 103 104 105 106 107 Last Page 103 of 708