Items tagged with procedures procedures Tagged Items Feed

Here is one I have been struggling with lately:

I have a relatively large module with many procedures inside (plus some other data structures). In one of the procedures, it turns out that it would be convenient to have a subprocedure defined inside to both shorten the code by avoiding duplication as well as make it more error proof (once the subprocedure is debugged it'll be correct everywhere it is used). Here is the skeleton

Lattice:=module() option package;
export Track;   ...
   Track:=proc(arguments) uses LinearAlgebra;
   local trackElement;

      for ... do
         result:=trackElement(parms); # This does not work
      end do

      trackElement:=proc(arguments) uses LinearAlgebra;
      end proc; # trackElement

   end proc; # Track;

end module; # Lattice

The problem I have is that procedure trackElement is not recognized as i found out running the code in the debugger. I can make it work by taking trackElement out of Track and make it local to the Lattice module. While functionally this works (and it is how I have it now programmed), I do  not like it as every proc in the Lattice module can see trackElement. That should not be so, I want it local to procedure Track, which is where it belongs.

I really thought I could define procedures within procedures. Am I wrong? Or is there something else ging on?


Mac Dude

PS: The whole module is more than 100 kB of Maple code sitting in a library. I refrain from uploading it here as it would be non-trivial to get going even for a simple test case.

Hello guys, I have a question. Is there any possibility to calculate two or more procedures at same time in the maple18 ?. I m thinking about using of the Grid or threads tools.

My problem is:

Given two functions/ procedures, f1(x,y) and f2(x,y). I need make an parallel computation of f1 and f2 and after i need get

f3 = f1+f2.

I am very grateful for the help.

I created my own package and one procudure inside this package is to calculate the eigenvalues of a identity matrix, as shown below




Then, I use this package in another document, all other procedures work well except the procedure calculating egigenvalues, as shown below




How to solve this problem? Thank you.

I want to make a package that I have created work with the LinearAlgebra package that comes with Maple. My package loads into a worksheet fine, but when I try to use one of my procedures, most of which depend upon procedures in the Linear Algebra package, the executable part of my procedure from my package is simply echoed to the screen and not executed. If I then copy the echoed part to a command prompt then it executes fine. How do I make my package use the commands in the Linear Algebra package?

I have three procedures with calling struture:


    > call B (argseq)

    > call C (argseq)

     > etc code

     > return results

end A()

Procedures A, B, C are defined in a single MAPLE .mw worksheet, and each time I use them I have to reload them by pressing return.

Please can you suggest the best course of action?  I have been reading about modules but am not certain that A knows about B and C in the dame module when it calls them

Can anyone help please?





In a simulation code I use "module-factory" concepts (where a module has a proc; the proc in turn returns another module that has all the procs one wants) a fair bit to keep the code readable and maintainable.

At this point I have the code mostly doing what I want it to, but the run time could be improved (read: I want it to go faster). So I have started working with CodeTools:-Profiling. Quickly I am running into the Profile() function apparently not being able to deal with my generated procedures.

Is there a way out? In other locations I read about procs to be profiled having to be in a Maple library; this is the case for my routines (it all is in a big module with procs, submodules etc.). I'd rather not rewrite the code extensively just to allow profiling (in particular I would not really like to abandon the module-factory scheme), but of course I can do some modification.

Any suggestions?



I have couple questions on displaying/printing items I see from ShowContents(LibLocation). Here is an example


First quesionNow, when I do
then I see

When is "%?.m" there? Is this suppoed to be an actual function one can print?

second question

c[30]; gives

But when I do:


I get listing that ends up calling

proc(n::{algebraic, algebraic .. algebraic})
local fn;
   1   if nargs <> 1 then
   2     error "wrong number of arguments"
       end if;
   3   fn := traperror(evalf(n));
   4   if type(fn,'numeric') and not type(n,'posint') or type(fn,('numeric') .. ('anything')) and not type(op(1,n),'posint') or type(fn,('anything') .. ('numeric')) and not type(op(2,n),'posint') then
   5     error "expecting positive integers in argument"
       elif type(n,('integer') .. ('integer')) and op(2,n) < op(1,n) then
   6     NULL
   7     ('AiryBiZeros')(n)   <----- Is this C function/compiled that is why it does not show?
       end if
end proc

Which is the same name I printed. So it seems to be another internal procedure with same name? How can I print it as well?

Is there a better way to print Maple procedures/command than what I am doing above so one gets full listing?
I tried Browse(); command in LibraryTools, but found it very cluncky to use (keeps losing listing and screen become blank. Very buggy)

I do have some m files and they containing procedures where i am interested in
How can i read those procedures in a m file

Thanks in advance


I've written a Maple's procedure but when I execute it some warning messages have been displayed as follows:

read "My_Proc.mpl":
Warning, `L` is implicitly declared local to procedure `My_Proc`
Warning, `P` is implicitly declared local to procedure `My_Proc`
Warning, `V` is implicitly declared local to procedure `My_Proc`

So, how can I get rid of such warnings?
Thanks in advance.


I have a mistake in these lines but I d'ont know the exact error. There is no numeric value of g(1,1)=4???????????????  Thanks for your help.

g(1,1);  No display of the value 4

To those who read this post.


I have a question about the property of local variables in a procedure.

Are names at the local variables in procedures, strings not names? 

If so, why can strings be evalated to have Integer, which is numbers for counting for continuing repetition? 

This is the code which searches for the maximum value. 


Max2 := proc()

local i, m :: string;
if nargs = 0 then
return -infinity
end if;
m:= args[1];
for i from 2 to nargs do
if args[i] > m then
m := args[i]
end if;
end do;
end proc:



              this answer was true.

type(1, string)

              this answer was false, of course.


I limited the values of local variables to be string.

But, to the sequence 1,7,5,4,6,10,35,63.5,-10,5, any error messages wouldn't appear.

I hope any of you will give me an answer.

Thank you in advance.


taro yamada






Hi everyone

I am currently trying to make my own simple package including a few procedures. So far I have been able to write some "code" that actually works when I open the document and hit "enter". I would, however, like to save the package so it can be accessed during any Maple session using the command "with". I have unsuccesfully tried to comprehend the Maple help pages regarding this question but I definitely don't want to mess things up.

This is what I have written:

mat := module ()
description "useful procedures for mathematics, physics and chemistry";
export AtomicWeight;
option package;

   AtomicWeight := proc (x) description "returns the average atomic mass of the naturally ocurring element";
   Units:-AddSystem(NewSystem, Units:-GetSystem(SI), u);
   return evalf(ScientificConstants:-Element(x, atomicweight, system = NewSystem, units))
   end proc

end module;

What should I do to save it correctly?

Thank in advance,





It would be nice if Maple had a procedure which could turn a procedurelist into a listprocedure.
I use these words in the sense they are used in dsolve/numeric.
Thus by a procedurelist I mean a procedure returning lists (of numbers).
By a listprocedure I mean a list of procedures all having the same formal parameters and each returning one number.
Thus a `convert/listprocedure`should accept a procedurelist p as input and give as output the corresponding listprocedure [p1,p2, ... pN] where N is the number of elements in the output from p.

I tried making a `convert/listprocedure` myself and in doing so found that it was not totally trivial.
I had lots of problems but did end up with something that seems to work.

But my main point is that Maple ought to have some such facility either as described available to the user or by changing fsolve, complexplot or what have you, so that procedurelists are accepted.

Hi everyone,

I am a new user of maple and i want to know the procedures to follow when solving 4 differential equations simultaneously.






Any help will be highly appreciated. Regards

Good day,

I was wondering what goes wrong with the procedure I wrote.
I inserted a short example, otherwise I didn't know how to explain it.

When looking at the Maple sheet:
It concerns determining the eigenfrequency and then specify a factor to that eigenfrequency.
The first plot is the 'critical range expressed in FREQUENCIES'. I plotted this using a procedure.
Now in the second plot I converted the first plot, which is expressed in FREQUENCIES, to a certain critcal range in LENGTH.

Now my point is that I would like to view the reductiefactorvoetgangers(lengte) when I type in for example lengte:=22; but it gives an error. I don't understand why it does that.

In case of the first plot (expressed in FREQUENCIES), i can just simply fill in eigenfrequentiesysteem:=1.7 and then it gives me an answer for reductiefactorvoetgangerseigenfrequentie(eigenfrequentiesysteem) which is equal to 1 (which is correct).

So if anyone can tell me what I do wrong, I would appreciate.
Thank you


1 2 3 4 5 6 7 Last Page 1 of 12