Carl Love

Carl Love

28050 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@nm Also, see the help page ?SoftwareMetrics,HalsteadMetrics. It's not exactly the same thing as leaf count, but in some ways it's much more useful. Another useful one is codegen:-cost. It counts the various arithmetic operations separately, but it's trivial to add those separate counts.

@nm I suppose that you're right about Maple should provide. But it's trivial to write your own. I thought that you would after reading that code. Here's mine:

LeafCount:= e-> `if`(e::atomic, 1, 1+(add@thisproc~@[op])(e)):

Using this on your lengthy piecewise expression from an earlier Question today

LeafCount(ff);
              16814

which is the same value returned by MmaTranslator:-Mma:-LeafCount.

@vv You definitely should change {numeric, name, string} to atomic!

If I click in MaplePrimes on the "Active Conversations", then I get a list of the 50 most-recent threads, with the first few words of their titles. So, for this thread, that's "why Maple 2023 gives internal error..." You see, the only part that's shown has extremely low information content, and is likely to be an exact match for other titles. The error message alone is sufficient title.

I know that MaplePrimes advises you to phrase Question titles as questions. Whoever wrote that advice is wrong. They apparently have no idea on how technical and scientific information should be organized for long-term storage. They seem to be more concerned with style than substance.

@tomleslie Since the OP requires 10-digit precision due to the courseware app being used, it should be noted that only this will give it without adjusting Digits:

evalf(D[1$3, 2$4](f)(-1, 2)); #no decimals!
                         
205.6236296

@nm There is a movement in Maple towards using strings rather than symbols as option values for new commands. However, it should be noted that iscoulditbe, and _EnvTry:= 'hard' all existed in Maple before strings were even introduced. Prior to that introduction, symbols (often enclosed with `...`) were used for all cases where strings would be used today.

@sursumCorda According to the definitions and test code in this blog post "Programming Research Laboratory: Lexical and Dynamic Scope" by Ming-Ho Yee, Maple uses dynamic scoping. Yee's test code is

x <- 1
f <- function(a) x + a
g <- function() {
  x <- 2
  f(0)
}
g() # what does this return?

Translated into Maple:

restart:
x:= 1:
f:= a-> x+a;
      f := a -> x + a 
#Note the x in the displayed procedure

g:= proc() :-x:= 2; f(0) end proc:
g();
                               2

Yee says output 1 means lexical, and 2 dynamic.

It makes no difference whether one uses proc or ->, or whether x is an environment variable or a regular global. If we make x into what Maple calls a lexical variable, the results are the same:

restart:
f:= proc(a) 
local x:= 1, f1:= a-> x+a, g:= proc(a) x:= 2; f1(a) end proc; 
    g(a)
end proc:
f(0);
                               2

This is all good, the way things should be. I couldn't imagine extensively programming with symbolic variables (i.e., variables that don't necessarily evaluate to something other than themselves) in a lexically scoped environment, especially in an interpreted (i.e., not compiled) language like Maple. It'd also make weird situations where a procedure could come from a different file (or library) than the code that uses the procedure.

If you want to force a global variable in a procedure to assume a certain value for all time, that can be done with subs:

restart:
x:= 1: f:= subs(_x= x, a-> _x+a);
      f := a -> 1 + a 
#Note the absence of _x in the displayed procedure

f(0);
                               1

This subs thing only works when _x is global. This is a very powerful technique for creating efficient procedures on-the-fly from procedure templates.

@MaPal93 No, it's not necessary to first create a sequence of plots and then loop through them sending each to a file. And, if you do first create the sequence, it's not necessary to put it in an array (with the angle brackets); putting it into a list (with square brackets) works just as well. If your actual plots use a lot of memory, it might be beneficial to avoid the sequence. 

@MaPal93 Without delving into the details of your particular case (which I don't feel like pursuing at the moment), I'll advise you thus: Any numeric value representing a plot coordinate can be replaced with the keyword 'undefined'. These will simply appear as nothing at all in the plot. Example:

restart:
f:= x-> piecewise(abs(x-3/2) < 1/2, 'undefined', x^2):
plot(f(x), x= 0..3);

@AHSAN Running your most-recent worksheet in Maple 2023 (with no changes!), I get the following plot. 

  1. Is this plot different from what you get (presumably in Maple 2022)?
  2. Is this plot (shown below) what you want to get?
  3. If not, then precisely how do you want the colors changed?

The cutting off of the third digits (the right side) of the legends is a separate issue.

In my worksheet itself, the above plot displays with a very ugly font used for the tickmark labels (but not the legend labels). I don't know why that is corrected by my context-menu Copy-As-Image followed by Ctrl-V paste into MaplePrime. Anyway, that's also a separate issue from the colors.

 

@achreftabet if we let k = i + j, then goes from 0 to n, and j = k - i. Then the sum can be obtained as 

add(add(a[i, k-i]*x^i*y^(k-i), i= 0..k), k= 0..n)

This assumes that n has a definite nonnegative value at the time the command is executed.

I didn't see your presumably deleted follow-up question, although I can see some possible loose ends in my Answer above. So, if you're having any trouble with that Answer, please ask here.

@sursumCorda I wonder what you mean by saying that `$` is a "lower-level command" (as compared to seq). If you mean simply that it has fewer options than seq, then that is true. But I can"t think of any other way that it could be considered lower level. 

I think that `$` is higher level because it allows for the abstract representation of infinite sequences and sequences with an indefinite number of terms. (Admittedly, those are quite easy things to do.) I make the formal analogy "`$` is to seq as sum is to add."

If you'd post a worksheet showing the error, there's a good chance that I could figure out the problem without even needing to unpack my computer, which'd be useful for me at the moment because I'm driving (at a rest stop at the moment).

@Rakshak As I said, you could plot the polar jets with plots:-tubeplot (which'll give you the most flexibility for color, etc.), or plots:-spacecurve, or plot3d with option style= wireframe. Then assemble all those static plots into a single static plot with plots:-display, and then plots:-animate with plottools:-rotate as shown above.

First 51 52 53 54 55 56 57 Last Page 53 of 709