Carl Love

Carl Love

21223 Reputation

24 Badges

8 years, 249 days
Natick, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity

These are replies submitted by Carl Love

I thought that it'd be more generally useful to separate the cases as Z[1], ..., Z[5]. I don't consider ee->Z to be "the normal transformer" because I don't think that it's normal to replace distinct subexpressions with the same variable. This way, you can examine the contents of all the Zs via

LargeExpressions:-Unveil[Z]([seq](Z[k], k= 1..LargeExpressions:-LastUsed[Z]));

But separate Zs isn't really necessary. If you want to replace all the expressions with just Z, you could do that. However, note that that could lead to unexpected oversimplifications such as the cancelling of two Zs which originally represented distinct expressions.

@lcz It's not clear what you want. Why should a*b*c be kept? Do you only want to remove terms containing a and exactly one other variable?

@MapleEnthusiast Why do you care about an iterative solution? If you want a solution equivalent to the Moore-Penrose, then use LinearAlgebra:-LeastSquares (which'll do it without explicitly converting the pseudoinverse). If you want to know the spectral radius, just compute that.

AFAIK, an iterative solution to a linear system is only worthwhile if the coefficient matrix is large and sparse. The iterative process that has been described so far in this thread (which I guess could be called fixed-point iteration) is crude and not often used.

@Carl Love The labels can also be generated on an as-needed basis from their position number by an arithmetic formula:

GetLabel:= subs(
    _AZ= ["", cat("A".."Z")],
        local n:= N, k;
        cat(seq(_AZ[1+iquo(n,26^(2-k),'n')], k= 0..2), 1)
    end proc

In Maple 2019 or later and 1D input, the procedure can be shortened to

GetLabel:= subs(
    _AZ= ["", cat("A".."Z")],
        local n:= N, k:= 3;
        cat('_AZ[1+iquo(n,26^--k,'n')]'$3, 1)


@Carl Love Recent versions of Excel allow up to 2^14 = 16,384 columns by using up to 3 letters for the labels. The code above can be easily extended to accomodate all of them:

my_alph:= [seq](cat(("A".."Z")$k, 1), k= 1..3)[..2^14]:

While 16000 may seem like a lot to us, the execution time of the above is barely even measurable by Maple.

@emendes In my opinion, alias is superficial. Yes, it can be used to achieve a certain desirable output display, and it allows for abbreviated input, but it doesn't fundamentally affect the computation. While the bugs are still being worked out, the presence of alias just adds confusion. Please present the above Lie derivative example from restart with any alias commands commented out (not removed). They can be replaced after the bugs are worked out.

@mmcdara You wrote:

  • Thanks for your first reply about the mechanism behind satisfies.

My first Reply is about the distinction between operators and operands. I hope that you read that also. My second Reply is about satisfies.

  • Is there a particular reason to write  indets(e, typefunc(anything, And(name, Not(mathfunc)))) instead of 
    indets(e, typefunc(And(anything, name, Not(mathfunc))))?

As you confirmed, anything is the implicit first argument of typefunc when it's used with one argument. Since anything is like the identity type of And, there's never a reason to use anything as an argument to And. So, the whole thing can be simplified to indets(e, typefunc(And(name, Not(mathfunc)))).

  • What situation does indets(e, typefunc(anything, And(name, Not(mathfunc)))) avoid that 
    indets(e, Not(mathfunc)) doesn't?

Given any "reasonable" type foo, I don't think that it'd ever be a good idea to use indets(e, Not(foo)), which would select all subexpressions, no matter how complicated, that aren't of type foo.

  • Is it necessary to discard the "case of a constant" in indets(expr, And(name, Not(constant))) ?
    For instance it seems that these simplifications of v still give the correct result.

From your new example expr, I guess that you realize that Pi is both a name and a constant. But your example is superficial because the Pi is not inside piecewise. If you put it inside the piecewise for which it's currently a coefficient (this can even be done in a way that doesn't change the mathematical meaning of expr), then you'll see why constants need to be discarded from the freeof set. (Your example is superficial because the expressions that appear outside the piecewises are irrelevant to determining whether a term is selected.)

  • Maybe a little less concise than Preben's but I still vote up

Preben's Answer addresses the specific example that you gave. My Answer addresses the verbal description that you gave (modulo my comment about operator vs, operator) using the example as a guide but trying to cover all cases "in the same spirit" as the example that fit your verbal description. There are a vast variety of such cases "in the same spirit" that are covered by my Answer but not his. For example, Preben's Answer will select any term containing any piecewise that contains any inequality or equation whose left side is t, even if that piecewise contains x elsewhere. Surely, such a piecewise shouldn't be considered to be a "function of t alone". And what if 2*t is on the left side of the inequalities? What if t is on the right side but not the left?

@mmcdara I hope that this can alleviate those mental gymnastics:

In other (perhaps more-formal) words, satisfies is a meta-type (or type constructor) that allows, on an ad hoc basis, any predicate expressed in procedure form to be used as a type. Here, I'm using predicate as it's standardly used in mathematical logic: a parameterized expression which becomes a proposition when appropriate values are substituted for its parameters. A proposition is an expression that can be evaluated to true or false.

For non-ad-hoc situations, it's probably better to use TypeTools:-AddType. For example, if is a one-parameter procedure that always returns true or false, then 
TypeTools:-AddType(typeP, P);
type(e, typeP)

is equivalent to
type(e, satisfies(P)). (typeP could be replaced by simply P or any other symbol.)

Having read this whole thread, I now know that by "operator" you mean either "operand" or "term", and this has led to some confusion among the respondents. In this particular case---where expr is type `+`--- "operand" and "term" mean the same thing.

Consider the expression b*f(t). Its top-level operator is `+`. The operands of that operator are a and b*f(t). A 2nd-level operator is `*`.

In f(t) we can call the operator (although I'm not sure if that usage of operator is universally standardized) and t the operand. Another point of view (towards which I lean), is that the operator in f(t,u) is the invisible infix function application operator (represented in prefix form in Maple as `?()`) and its operands are ft, and (or and the sequence (t,u)). In either point of view, calling t and u the arguments is universal.

term, as that word is used in secondary-school algebra, is simply any single operand of a `+` expression, or anything that could be used as a single operand of `+`. (Expressions constructed with infix `-` are considered to be type `+` also.)

From my quick reading, both eq1 and eq2 are derived from id, but no definition is given for id. S​​​​​​o the more-fundamental question is Where is id (which presumably stands for ideal diode) defined?

@vv You wrote:

  •  I don't know why uses does not work in this form.

Because the module references are linked into the code at the time that the code is read, not the time that it's executed.

This is the same reason that with doesn't work in procedures and why my procedure init wouldn't work without the parse command.

@greatpet You wrote:

  • For example, I might want to do this if I want to use some "inner" procedure heavily in the defintion of a procedure in the outer module.

Using so-called "short-form" names is a bad programming habit that makes code less readable. I advise against it, and I never do it myself, even at the top level, unless I'm doing "scratch" work that won't be saved and I need to work quickly (usually because I'm talking to a student at the same time as doing some computations relevant to what I'm talking about). Instead, I do what VV recommended: I use uses to define a one- or two-character abbreviation of the prefix.

@Rouben Rostamian My interpretation is that (a,b) < (c,d) means a < c and b < d, although it's not entirely clear that that's the intended meaning.

@greatpet You wrote:

  • Unfortunately this gets very verbose when there are many inner modules.

The way that you described the steps makes it seem as if you consider defining the inner modules and exporting them to be separate steps. Yes, you can do it that way, but it's not necessary. I define all procedures and submodules immediately at the point that they're declared local or export. See the example below. It also seems as if you consider export to be a command instead of a declaration. I lconsider it to have the same status as local. Every variable is either a local, an export, or a global.

  • It would be really helpful if Maple supported "nested export", allowing procedures exported by inner modules to be further exported by the outer module.

I'm not sure what you mean. Could you show an example that leads you to believe that Maple doesn't have that feature?

Here's my example:

OM:= module()
    IM:= module()
    option package;
    export add_three:= x-> x+3;
    end module;
end module
                             z + 3


For months you have been asking Questions very similar to this one. I'm not saying that that's a problem, but hopefully you're trying to learn how to do these yourself? You should post your attempts at writing procedures so that we can help you better. It doesn't matter how incorrect the attempts are; you'll learn more that way than by just asking straightforward graph theory questions. 

1 2 3 4 5 6 7 Last Page 3 of 592