Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@taro Please execute these four examples. I hope that the output will help you understand what map is for.

map(`*`, [a,b,c], z);
map(f, [a,b,c]);
map(f, [a,b,c], z);
eval(%, f= `*`);

So, map cannot be used to convert a list into something else. If its second argument is a list, then its output will be a list.

@nunavutpanther If you want to create a list in the default set order with no repeats, then you can do that. Note that if L is a list or set then op(L) is equivalent to L[], so your line of code can be replaced by [{L1[], L2[]}[]]. If you don't care about order or repeats, then it's more efficient to simply make a list: [L1[], L2[]]. (Well, at least the creation of it is more efficient.)

HOWEVER, sets are always stored sorted, so checking whether an element is in a set is only time O(log(n)), whereas the same check in a list is O(n) where n is the size of the set or list---a huge difference.

@_Maxim_ Oh, okay. In that case, I withdrawal my comment about simplify.

The most disturbing thing about your example is that simplify returns 0.

Since it's not entirely obvious from the ensuing discussion, I thought that I should point out for less-experienced readers that Maple can ordinarily take the derivative of a definite integral with respect to a variable that occurs both in the integrand and the limits of integration, even if it can't do the integral. For example,

int(exp(-x*(t^3+t)), t= 0..x);
diff(%, x);

The case at hand is special because the integrand can't be evaluated at t= x.

 

@AmusingYeti It's a recent thing; it's been around a few years.

@AmusingYeti Yet sometimes the amount of allocated memory is reduced without restart: Sometimes you see that memory number on the bottom right go down, or you use CodeTools:-Usage and the reported "alloc change" is negative. I don't know how to force this to happen though.

You need to ask yourself Why solve it? If you were to solve it, would it be possible for you to effectively use the solution, which'll probably be 170 very lengthy expressions? Would it perhaps be better to simply resolve the whole system each time that you have numeric values for the parameters, which'd likely only take a fraction of a second?

@Markiyan Hirnyk The problem that you gave to Mathematica is much easier than the original. Your function, considered as a function of a real variable, is continuous and periodic with an irrational period. Thus the limit superior of the discrete sequence is just the maximum of the function considered as a function of a real variable. Maple can do that with

maximize(sin(x)/(3+cos(x)), x= 0..2*Pi);

You may verify that Maple's simplified answer is equivalent to Mathematica's unsimplified one.

@Lime Juice If you make assignments to an indexed (see ?indexed) name (see ?name), E in the case, it turns E into a table (see ?table) (*footnote). In this case, the table's indices are 1, 2, 3; and its entries are the corresponding expressions that you've assigned. The command entries (see ?entries) returns those entries as a sequence.

Let me know if you understand, and feel free to ask other specific questions.

(*footnote) Therefore, it's not safe to assign to an indexed name such as E[n] and then try to use E itself as a variable or to assign to E. Doing so is a very common source of bugs in user code. But it is safe to assign to E, E1, E_1, E__1. The last of these will display as subscripted in the GUI, which is convenient. These name forms (when they're global) can be easily sequenced with the || and cat operators.

@nunavutpanther I updated my code to remove the use of add.

@vv Once again, we had exactly the same idea at the same time! This time, however, my procedure isn't letter-for-letter the same as yours.

@awass The quotation marks that you used in this line:

  • Cmnts:= “if time goes by then a=2.1” ;

are not normal ASCII characters. They are not the double quotation marks that I was referring to. The correct double quotation marks have numeric value 34, that is, the 7-bit sequence is 0100010. And it must be the same character at the beginning and end of the string.

It's perfectly legal to have non-ASCII characters inside strings and names, but they can't be the delimiters. Indeed, I recently worked on a package where all the internally generated variable names (such as variables of integration) were Chinese characters. The GUIs (including the command-line interface) and most standard text editors handle them just fine.

 


 

@awass 

There are three types of quotation marks in Maple. All are always used in pairs.

  1. The double quote ": These are used to make strings.
  2. The single backward quote `: These are used to make names, which are very similar to strings.
  3. The single forward quote ': These are to prevent or delay the evaluation of expressions. The usage of these is quite subtle, and often frustrating and mind-boggling, especially when multiple pairs are used.

From your description of the problem, I can only imagine that you are using two pairs of single forward quotes (#3 above). If you are using #1 or #2, there should be no problem.

Regarding the storage of true comments: There is a way that was introduced in Maple 2017 (the most-recent version). If that's what you're using, I'll look it up.

@Joe Riel Thanks for the information about objects and modules. So, it'd be more germane to say that a module is simply a container of persistent local variables rather than that it's a procedure with persistent local variables, right?

I have a question about illegal use of keyword static, and this seems like a good place to ask it. Consider this variation of your Incrementer object:

Incrementer3:= module()
option object;
local 
   cnt:= 0,
   ModuleCopy::static:= proc(self::Incrementer)
      self:-cnt:= 0;
   end proc,
   ModuleApply::static:= proc()
      cnt:= cnt + 1;
   end proc
;
end module:

Based on your explanation of static above, I understand why static can't be used with the ModuleApply. My question is Why isn't the illegal usage detected by the syntax checker? The error message doesn't come until you actually try to use the module.

First 349 350 351 352 353 354 355 Last Page 351 of 709