Carl Love

Carl Love

28130 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

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);

@C_R To provide a further example of functional syntax, your simplify_expanded can be simplified to

simplify_expanded:= 1@@0 = simplify@`/`@op@expand~@[numer,denom]:

Since every element of that is already a functional operator, there's no need for any -> or any variables.

1@@0 is a multivariate identity operator. Some other identity operators are D[]`@`(), and ()-> args.

In my Answer, I essentially claimed that if G had a Hamiltonian path beginning at v, then any depth-first search applied to (G,v) would necessarily return a Hamiltonian path[*1]. I was wrong about that. Depending on the order that vertices are selected, it's still possible to reach a "dead end" before all vertices are exhausted, in which case a "branch" will be taken from one of the vertices on the stack that connects to a not-yet-seen vertex.

Despite that incorrect claim, the posted code does correctly perform the function stated in its description.

[*1] In other words, I'd claimed, incorrectly, that if G had a spanning tree that was a simple path starting at (such a path is called Hamiltonian) then the depth-first search starting at v would necessarily return it or another simple path.

First 103 104 105 106 107 108 109 Last Page 105 of 710