Carl Love

Carl Love

28150 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@nm I agree wholeheartedly; I hate reading superfluous parentheses in standard algebraic expressions.

Maple's conversion of 2-D input to 1-D form also suffers from automatically added superfluous parentheses.

Your Mathematica example doesn't look so great to me! The spacing is awkward, and the 2 is not superscripted.

@Sabrina Kamal It's not some unprintable character. The function's name literally has a question mark. Explicitly, it's

back-quote question-mark left-square-bracket right-square-bracket back-quote

Or, if execute this, you'll see the name in Maple:

convert(cat(StringTools:-Char~([96, 63, 91, 93, 96])[]), name);

@Sabrina Kamal In that case (Maple 2016) you can use

R:= unapply(map(`?[]`, <P1, P2, P3, P4, P1 | Q1, Q2, Q3, Q4, Q1>, [i]), i):
plot([seq(R(i), i= 1..21)], color= plots:-setcolors()[1]);

And before you ask, this neither goes inside nor outside your loop. Instead, it completely replaces your loop.

 

@one man Your solution works fine when the numerator of the fractional exponent is an even integer, but not if it's an odd integer. Your solution is probably fine for the OP in this case, but a surd solution is more general.

This doesn't seem to me like a problem appropriate for Groebner.

Do you want all solutions? Or would you be satisfied with just one solution? Are all the inequalities linear?

@Carl Love My code above doesn't handle every possible case of obtaining a decimal approximation of frac(x) where x is a symbolic real constant of large magnitude. It relies on the ability of frac to find the integer part. There are some extreme cases where frac returns unevaluated.

My code also doesn't the handle the two-argument derivative-of-frac case. It seems unlikely that that case would come up.

@acer You mentioned "special evaluation rules of evalf." Do you know what those rules are? There does seem to be something special, but my experiments so far haven't been able to nail it down.

@rahinui The exp= 1 trick works because explicit numbers can be used as procedures that return themselves. This doesn't apply to symbolic numbers like Pi.

@vv In that case I'll continue. But this material is still intended primarily for @nm.

In some library procedure, inplace can be specified as an option by using an index on the procedure's name. This is coded as

foo:= proc(REC::record)
local 
   inplace:= procname::'indexed' and ':-inplace' in {op(procname)}, 
   rec:= `if`(inplace, REC, copy(REC))
;
   rec:-b:= 5;
   `if`(inplace, NULL, eval(rec))
end proc:

And it's invoked as

foo(R)
or
foo[inplace](R)

@vv Oops, that Reply was not meant to be directed specifically at you. I forgot to take off the @vv.

@vv In the related thread, I just posted some `evalf/...` code to work around the frac problem.

@das1404 lprint shows you output in its most-basic one-dimensional plaintext format. It is useful for re-examining output that you can't otherwise understand. That is the context that I previously recommended it for. Setting interface(prettyprint= 0) is pretty much equivalent to putting all output into lprint form.

The command print(expr) means "evaluate expr and display it in whatever format it would've been displayed in had it been output at the top level." So, if expr is a plot, then it's displayed as a plot. I guess that that wasn't your intuition.

@Kitonum You said that "everything works with assuming." But the very thing that the OP wants, simplify(A*B), still doesn't work with assuming.

@das1404 There's no difference between sin(s)^2 and (sin(s))^2. The latter simply has superfluous parentheses (which I personally find to be a significant annoyance when I'm trying to read code). There's no question of the latter form being "safer"; the former will only ever be interpreted as squaring the whole expression. I've done computer programming for 40 years, and I've studied a great many computer languages. I'm not aware of any language where f(x)^2 is interpreted (or could even possibly be interpreted) as f(x^2), although I suppose that that possibility exists if there's some language that let's you change the precedence of operators. (Is there any such language?) Nor am I aware of any standard or system for printing formulas for reading by humans where f(x)2 is intended to be interpreted as f(x2).

If you consider the juxtaposition between f and (x) to be a binary infix operator (and you should consider it thus), then this operator has higher precedence than all the "normal" operators (all except || and :-) , such as ^. Its precedence relative to || and :- is a bit more complicated to state because it depends on which is on the left and which is on the right. The associativity of this juxtaposition operator is to the left. That is, f(x)(y) is equivalent to (f(x))(y).

In Maple's loathsome and hideous 2-D input (which you, David, don't have because it's newer than Maple 7), a distinction is made between f(x) and f (x): In the latter, the space is considered a multiplication operator. This is the source of a great many problems reported here on MaplePrimes. Using this, f (x)^2 would be interpretted as f*(x^2). This doesn't contradict what I said above because there's no function application at all.

@vv The way that it's done in much of Maple's library code is that there's a keyword option to specify in-place operation (the same as call by reference) with the default being call by value. Like this:

foo:= proc(REC::record, {inplace::truefalse:= false})
local rec:= `if`(inplace, REC, copy(REC));
   rec:-b:= 5;
   `if`(inplace, NULL, eval(rec))
end proc:

R:= Record(b=99):
R2:= foo(R);

                      R2 := Record(b = 5)
eval(R);
                         Record(b = 99)
foo(R, inplace);
eval(R);

                         Record(b = 5)

You can change  inplace to any name that you want.

First 327 328 329 330 331 332 333 Last Page 329 of 711