acer

32460 Reputation

29 Badges

20 years, 1 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@nm Of course I tried the code that I wrote. The code I put in my answer is exactly what I tried. It worked. I don't know quite what to make of your followup request that I show the actual code I used, since I already have done so.

You have not assigned to L in any way even close to what I wrote.

I wrote about passing one of the library file names in libname to LibraryTools:-ShowContents. That is, the name (string) of an .mla archive file. But, very differently, you appear to be passing the name of some module (in your session) to LibraryTools:-ShowContents. That's not what I suggested.

I had an example in which L was one of the items in libname. That means that L was assigned a string. In my case I was using,

   L := [libname][1];
             L := "/usr/local/maple/maple2022.2/lib"

If instead I use any of the other .mla file names in libname, then those work perfectly fine as well, showing different results, of course.

But here are the commands you used to assign to L. It does something completely different and is not at all what I described. You pass the name of some module, A, to LibraryTools:-ShowContents.

   currentdir("C:/tmp/"):
   libname := "C:/tmp/my_library.mla",libname:
   exports(A);
                             B,C
   L := A;
                            L := A

That's why it doesn't work for you.

Also, in your original Question you wrote that you want the names of the modules in the library archive. And my Answer shows how that literal request can be accomplished. You didn't write up front that you wanted the names of submodules of such stored modules in the archive (and any further recursion of membership). To get that you could write short code to recursively test using op(3,...) of found modules, a modification of my answer to your previous Question.

@nm You need L to be the (string) name of the library archive file that you want to examine.

I only used libname[1] as an example.

@nm I mistakenly used m:-_pexports, where I ought to have used exports(m) . Sorry. I copy&pasted the wrong version from that older Answer of mine.

Does this do better?

H := proc(m::`module`) local res;
  local oldOM := kernelopts(':-opaquemodules'=false);
  try
    res := select(p->type(m[p],procedure),
                  [exports(m)[],op(3,eval(m))]);
  catch:
    res := [];
  finally
    kernelopts(':-opaquemodules'=oldOM);
  end try;
  res;
end proc:

If you already have kernelopts(opaquemodules=false) , so as to be able to trace the local procedures, then the short form of my code would be,

select(p->type(m[p],procedure),
       [exports(m)[],op(3,eval(m))]);

@NanaP Please do not spawn another, wholly separate Question thread on this TriangularTypeII procedure or re-parametrizing a triangular distribution.

It's not clear what you want.

Do you hope to substitute numeric values of t for the unknown variable a inside the Matrix?

What do you want the plot of a single instance (single numeric value) of t to look like?

@Rouben Rostamian  The OP's attachment was last saved in Maple 2021.

If I run your worksheet in Maple 2021.2 then it throws an error when forming Matrix assigned to IC.

But it succeeds if I first do,
   with(Physics):
at the start of the worksheet.

@Aung Please don't start additional (duplicate) Question threads for this.

@sursumCorda The different qualities of data structures can lend them to different kinds of good use.

For example, use of a list has been highly optimized within the Maple kernel/engine, in terms of memory management, especially for lightweight creation at small sizes. But it's not actually a mutable data structure and should not be used as such.

As an indexable, mutable data structure that can store numeric data in contiguous memory blocks (and thus allow no-copy transfer to externally linked code) the rtable (Matrix/Vector/Array) is great. It has "growable" functionality, but not in the same class as the mutable table hashed data structure.

The uniquification functionality of the set is also tuned.

These different data structures provide quite different functionality benefits, and suitability for different kinds of task. Unfortunately, I'm not aware of any good book or documentation chapter which focuses primarily on this through close explanation accompanied by example.

One of the few logical duplications is the (lowercase) table-based matrix & vector. The last-name-evaluation allowed for in-place (no copy) semantics when being passed as argument in a procedure call. The overlap with more modern Matrix/Vector is less evident, due to deprecation.

ps. There are several other additional data structures available for use in Maple. I just wanted to mention these basic & commonly used ones, to help illustrate a point.

ps. Mma also has more than one flavour of data structure. It's packed array shares some qualities with Maple's rtable, allowing for no-copy access by external functions. But it too has some optimal use-cases that are non-trivial in general, eg. use of ToPackackedArray, NumericArray. In fact Mathematica has many flavours of data structure, and knowing which to use optimally, and how, is also complicated.

@Anthrazit We all have such moments, now and then.

@Danish Toheed I asked whether your NM procedure can actually do root-finding sucessfully because it's not clear to me that it has been correctly implemented.

If there are no starting values (ie, x0) for which it converges to the roots (say, when the funciton is x^3-1) then won't it be problematic to try and use it for computing basins of attraction?

Please consider that an addition to my previously list of queries above. In my opinion those are still germane to the goal of plotting basins of attraction.

@Danish Toheed Can you demonstrate that your NM procedure can actually be used to return approximations of the three complex roots of k^3-1 ?

Please don't start a duplicate Question thread for this.

If you have revisions to your code you can attach them in Replies here.

@Danish Toheed You've repeated much of the information you had previously given, but you haven't answered my queries, and you haven't added the missing, crucial, details. Your latest Reply hasn't really provided additional information.

You may have noticed that your iterated augmentation of sol_coordinates is muddled up and not working properly. Your code has an outer loop, (for i from 1 to nIteration do...). Now, I don't think that you understand what I meant before by "inner loop". There is an inner loop, in the lines,
   sols := [op(sol_coordinates), x];
   for sol in sols do
      sol_coordinates := [op(sol_coordinates), [sol, 0]];
   end do;

And it's not clear what you're hoping that inner loop would accomplish. It seems its purpose is to form the final numeric point data for the plot. But, as written, it's creating a muddled structure rather than well structured actual numeric data points (eg. a list of lists of numeric pairs). In order to fix it, we should be told the exact goal for it. Your code has no comments that might make the intended structure clear. 

You use the plot command, which is for 2D plots. So, what do you intend that the horizontal/vertical data pairs will represent, at each plotted point -- if constructing sol_coordinates were actually successful?

For example, are the horiz/vertical point pairs just going to be the i and x values in the outer loop?  If so, then why did you you write the inner loop?! What do you think that your inner loop would do?

Also, your code appears to use a single intial value, x0, and then iterate. How would using a single initial value be a way to construct a plot of a basin of attraction?

Moving on... are you trying to make Newton's method work in the complex plane? It seems so, to me, judging by your phrase, "rectangle D ∈ C of size [−2, 2] × [−2, 2]". But I don't see that in your code, or your choice initial point x0, or your attempt at assembling data from the iterations, etc. Please clarify.

ps. Why differentiate to obtain the expression assigned to df, if it's not going to be used?

I'm afraid that if you cannot answer these queries I would not be able to help you.

@Saha Duplicate queries against this example/problem will be flagged as such, and may be deleted.

@Saha To apply the sin command to x you need to enter it as,

   sin(x)

without spaces between the "sin" and the "(" if you are using 2D Input mode.

First 71 72 73 74 75 76 77 Last Page 73 of 594