zenterix

310 Reputation

4 Badges

3 years, 97 days

MaplePrimes Activity


These are replies submitted by zenterix

@acer I have a few questions here. Multiple things I am unaware of.

- You said that you only have the top src directory in the include-path. Are you referring to the libname path? From what you wrote, that top src contains mpl files. The "include path" I am aware of is related to libname, which looks for mla files as far as I know. Shouldn't it rather be the lib folder that is in the "include path"?

- What is an .mm file?

- I am assuming that you keep .mla files in a lib directory because Maple can find them there? I've read about this behavior concerning lib folders, but haven't been able to replicate it.

- any example repository? The link you sent of Maple Cloud has a list of "projects/packages?" and when I download they come as a .maple file, yet another file type I am not sure about what it represents.

EDIT: so I looked a bit on Github and here is a repository where the author has included the files that "build" the project.

The file basically creates an .mla file on the fly, defines a module that includes tons of other files and exports a ton of stuff, and in the end saves the module to the .mla file.

It would really make things easier if .mla in lib were part of the libname search path.

@Ronan 

How did you find Sublime Text? I've never really used it before.

At some point like two years ago I was using Vscode, and I just googled and found this plugin which looks promising. I'll check it out later today.

Also will check out this jEdit that I've never heard of before.

@Carl Love 

I'm not really sure if what you say is correct about the error.

The first of the two worksheets I sent you has the code

module NumberGenerator()    
option object;    
local defaultSeed;      
defaultSeed:=100;        

export setSeed:=proc(newSeed)          
defaultSeed:=newSeed:      
end proc:

export getSeed:=proc()          
return defaultSeed:      
end;

end;

If I insert a "code edit region" in the same worksheet, and simply copy and paste the problematic module code that isn't being parsed, then it works.

Here is an updated worksheet example with the code edit region: Number_Generator_Module.mw

@tomleslie 

Let me tell you a bit of the context of why I am asking this question to address some of your comments.

I am helping a researcher with the programming aspect of a problem in quantum physics. I don't understand the physics nor much about the specific differential equations. Let me address some of your comments directly

Here is the worksheet you sent updated with some missing parts (like a procedure gen): OPevents2.mw

1) the reason I am setting method, abserr, and relerr is that in the original problem using the classical method always works, but we want to use rkf45 but dsolve did not work for this method without setting the other two parameters. Recently I asked a question where I posted a simplified version of the issue

But basically, to summarize, there are two differential equations and they are each defined with a stochastic multiplicative term. This seems to mess with the error correction of dsolve with rkf45. The solution I found was to set the abserr and relerr.

In the worksheet I posted in the current question, i(x) is supposed to be a way to access a discrete variable in the differential equations at each iteration step. I would like to be able to know which iteration we're on. With this information I can access data from, say, a matrix. This is just one strategy to speed up obtaining the stochastic terms I mentioned earlier.

2) as for the specific syntax you addressed, consider the following

events = [[0, 2 - x<0], [i(x) = i(x) + 1]]

As far as I can tell from the documentation, this is the following in the documentation

So I was just trying to tell Maple: if x>2 in any iteration, then trigger the event and the action is to increment i by 1.

@ecterrab 

I discovered that there is an inline code editor in Maple. Would you recommend this feature?

Does Komodo have support for Maple-style syntax? I use Atom but it doesn' seem to have any plugin for Maple.

EDIT: I've just been writing my code in the inline editor. Just experienced weirdness. Part of the code disappeared, but it wasn't actually gone (because it still would run, and if I tried to add in what seemed missing then it would give an error). Man, it's quite painful this Maple.

@Carl Love 

One thing you might note is that I am literally trying to learn about Maple from the official documentation. I simply use what is there. Initially I was reading Chapter 8 about Modules of the Programming Guide using syntax like

export getSeed, setSeed;

getSeed := proc() ...

setSeed := proc() ...

Then I moved on to Chapter 9 about objects. In section 9.7 I saw in the examples that I could actually just add the export keyword as follows

export getSeed := proc() ...

export setSeed := proc() ...

So I did this, and Maple started telling me it couldn't parse anymore. This is the sort of thing I run into frequently while reading the docs and trying to simply emulate. 

As for the worksheet I posted, it is just a prototype. I deleted a lot of code to try to get it down to a very simple example of something not working as expected. Here I have a version of the worksheet with an error: Number_Generator_Module.mw

Note that there are two modules: one is one I wrote that seems 100% correct but doesn't parse. The second is code from the documentation in section 9.8 of the Programming Guide. This one works. Yet I can't really tell the two modules apart syntax-wise.

Do both modules work for you?

Here is pretty much the same thing but now I placed everything in an inline code editor. The latter works, but the code using 2D math doesn't ("Error, unable to parse"): Number_Generator_Code_Editor.mw

As another example, a few days ago I tried to read about how to create my own package. I tried going through the docs but stuff just didn't really work as it was written. 

I would gladly write better documentation for things (and I probably will on Medium or something) but first I need to be able to do the tasks I want to write about.

@ecterrab 

Here is an example of a very small module that is problematic: Number_Generator_Module.mw

There is an object with a setter and a getter method for a local variable.

If I add the keyword "export" right before either of the methods there is a parse error. If I open a new worksheet and type in exactly the same thing it works, and if I convert it to 1D it also works.

I mostly use Maple for the symbolic math, so I want to use 2D Math. It is indeed beautiful, but more importantly, it is more legible as you said.

However, I am starting to use Maple as a programmer as well. What do I mean by that? Previously I would simply use Maple to compute something in, say, Calculus or Linear Algebra. 

But now I am trying to solve more complex problems that involve various stages - solving differential equations using random parameters, doing this in a loop, plotting results, creating animations.

There are various parts that I would like to make sort of automated, and that is why today I started to read about modules, objects, and packages.

In this usage, I write my own libraries, and so I am not doing math anymore really, but rather programming. Since I have worked as a programmer before, I am sort of looking for at least some of the things that made my life so nice and productive - like a nice code editor for starters.

But I sometimes run into things which are just maddening, like this issue in the worksheet above.

@Carl Love 

The original problem that prompted me to create this contrived example is a slightly more complicated system in the domain of quantum physics. The system represents the trajectory of a qubit, and the stochastic part is noise affecting the trajectory.

@C_R Isn't it weird though for there not to be any default output, or for the AllSolutions option not to be default? Am I missing something or is Maple sometimes not user-friendly.

@dharr 

Maddeningly, it doesn't seem to work for me. 

Here are the steps.

1. Create a directory "/Users/zenterix/test"

2. Create a file inside, testrepo.mla

3. Set the current working directory: currentdir("/Users/zenterix/test")

4. Define something: myX=5

5. Save to testrepo.mla: savelibname=("."); savelib('myX');

6. restart

7. Need to set the current working directory again: currentdir("/Users/zenterix/test")

8. I would expect that since the current working directory is /Users/zenterix/test and there is a repository testrepo.mla in it with a saved expression, I should be able to retrieve myX at this point. It is not retrieved, however.

9. Try to save the current worksheet in /Users/zenterix/test, open it again, and then try to retrieve myX. Still no success.

10. Note that myxyz does seem to have been saved. If I execute LibraryTools:-ShowContents("testrepo.mla") then I get [["myxyz.m", [2022, 11, 6, 11, 33, 37], 304128, 36]]

@acer here is a related mini-question. I was going through the documentation on writing a package (implemented as a module). There was the following snippet

"Packages generally include many lines of Maple code, so you will probably want to create and modify them in a specialized editor designed for programming such as vim or emacs. In the example above, the definition of the module SomeTools have been put in a file called SomeTools.mpl in the samples/ProgrammingGuide/ directory of your Maple installation). If you copy this file into the current directory, it can then be loaded in Maple by using the read command."

I went and looked for this SomeTools.mpl and found it. I opened it in a text editor, and then I tried opening it in Maple. Maple opens it and says it is read-only.

I also noticed that if I create a new document in Maple, it is not possible to save it as an mpl file. Is it not possible to write an mpl file in Maple?

After all, one of the advantages of separating procedures into separate files is so it is easier to work on the files in Maple at the same time.

@dharr Your solution definitely solves my question. 

However, to be honest, what I am actually interested in plotting is a composition of the least integer function

p1 := plot(1/floor(1/x), x = -2 .. -1/16, discont = true)

p2 := plot(1/floor(1/x), x = 1/16 .. 2, discont = true)

display([p1, p2])

 

Why the vertical portions on the positive part of the graph?

I was hoping that that option you used "discont=true" would show the open and closed circles at the discontinuous points. 

Do you know why this option isn't working in the example above?

I was hoping for something similar to the depiction below

 

In Maple, when I plot the positive and negative portions and display them together I get a plot that is generally correct, except that graph doesn't seem satisfactory in that the discontinuous points aren't displayed consistently

 

@acer 

So why exactly did my original attempt not work? Seems awfully complicated to plot a simple function like this. From what perspective are the original plots I obtained correct?

@Kitonum Not sure what you meant to express there. 

My question is if it is possible to write latex equations right here in this editor that I am writing in right now. For example, I want 

$f(x)=\begin{cases} 5, x \neq 0 \\  0, x=0 \end{cases} $

To appear as latex.

1 2 3 4 5 6 Page 6 of 6