Carl Love

Carl Love

28150 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@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.

@acer IMO, if one is using 1D-input, then the expression-form for-while-do-until loop offers the greatest flexibility:

  • has a bona fide assignable return value;
  • can be used inside other expressions;
  • allows any extra statements inside without changing the return value and without changing the displayed values (unless that is desired);
  • allows any of the control structures that an ordinary do loop allows: whileuntil, multilevel break and next;
  • no detectable efficiency differences compared with seq or elementwise; in particular, expression sequences are built in linear, not quadratic, time.

Example:

Bools:= (
     for x in [0,1,2] do
         es1:= "extra statement 1";
         #Handle true/false/FAIL trichotomy: 
         if (b:= is(x in RealRange(Open(0), infinity))) then
             es2:= "extra statement 2"; 
             yes 
         elif b = FAIL then  #See 10th and 13th paragraphs of "Description" on the
             undecidable     #help page ?assume
         else
             es3:= "extra 3"; 
             no 
         fi 
     until b = FAIL
);
                     Bools := no, yes, yes

Indeed, this is the finest looping construct that I've ever seen in any language. Bravo, Maple kernel developers!

@Carlos36r printlevel is an all-or-nothing thing pretty much only suitable for debugging. It'll show the results of all statements executed at the given level or lower. Assignments to a for loop index are considered statements for this purpose, and, of course, that's useful information for debugging. 

There are several things that you could do instead:

1. Wrap the for loop in parentheses (only works in 1D-input AFAIK):

(for x in [0,1,2] do if is(x in RealRange(Open(0), infinity)) then yes else no fi od)  
                         
no, yes, yes

2. Use elementwise operators instead of a loop:

`if`~(is~([0,1,2], RealRange(Open(0), infinity)), yes, no)[]
                         no, yes, yes

3. Use seq (prefix-form looping operator):

seq(`if`(is(x in RealRange(Open(0), infinity)), yes, no), x= (0,1,2))  
                         
no, yes, yes

and others.

First 53 54 55 56 57 58 59 Last Page 55 of 711