Items tagged with procedure procedure Tagged Items Feed

Using Maple 18, I solved for minimum and maximum price. Instead of using fsolve I wanna use procedure programming structure in order to get the same results. How can I do it?

min_sol := fsolve([bc_cond, slope_cond, x[G, 1] = w[aggr, 1]], {p = 0 .. 1, x[G, 1] = 0 .. w[aggr, 1], x[G, 2] = 0 .. w[aggr, 2]}); p_min := subs(min_sol, p); max_sol := fsolve([bc_cond, slope_cond, x[G, 2] = w[aggr, 2]], {p = 0 .. 1, x[G, 1] = 0 .. w[aggr, 1], x[G, 2] = 0 .. w[aggr, 2]}); p_max := subs(max_sol, p);
{p = 0.3857139820, x[G, 1] = 127.8000000, x[G, 2] = 38.99045418}
{p = 0.8841007104, x[G, 1] = 44.30160890, x[G, 2] = 164.2000000}

I have the following procedure to do the above. It works but it returns [9,10],[10,9],[12,1] for n=1729(for example). How do I modify this to 

a) to count 9,10 and 10,9 as the same and hence only show one of them

b) get 1,12 to show as a solution?

global listcub:=table();
local k:=0, x:=iroot(iquo(n,3),3),y:=x,x3:=x^3,y3:=y^3;
if 3*x3 <> n then x=x+1; x3:=x^3;y:=x;y3:=x3 end if;
while x3<=n do
y:=iroot(n-x3,3); y3:=y^3;
if(x3+y3 = n) then k:=k+1; listcub[k]:=[x,y]end if;
x:=x+1; x3:=x^3;
end do;
end proc:


So i got a procedure test, she is kind of numeric, i whant to optimaze test([.5, .5, .5], 1, 3, 100, 100, true, [x, 0, 0, 0, 0])=0 by x. But optinization substitutes x like a symbol, i tryed all methods but they all do the same.

f := proc (x) options operator, arrow; abs(test([.5, .5, .5], 1, 3, 100, 100, true, [x, 0, 0, 0, 0])-.4) end proc; Minimize(f(x));
Error, (in test) cannot determine if this expression is true or false: 0 < -43.0+100*x

Can i some how use optinization on such procedure?

file link  - >

I have a nice family of functions of the form:

W:=(p,n,mu,w)->sum(w[k] * (n-k)* mu(n-k),k=1..n)

which can be evaluated for different p's using the operator mu*diff(...,mu)

The recursion begins with p=0 and proceeds using mu*diff(W(p,n,mu,w),mu) = W(p+1,n,mu,w).

Can anybody implement this procedure in Maple

Thank you 

Hi all,

I'm having some trouble trying to make it so the answer Max(3,1,x,4) turns into Max(x,4), that is, only the greates number and the non numerical values are returned. I've tried a bunch of different things, but have gone out of ideas.

This is the link to the Maple file and this is the code:


#Improve the general Max procedure on page 224 so that Max(3,x,1,4)returns Max(x,4). That is, the procedure returns the maximum numerical value along with all nonnumerical values.

Max:=proc() local m, i;
for i in (args) do
  if not type(i, numeric) then
    return 'procname'(args):
  end if;
  if i>m then
  end if;
end do;
end proc;

proc () local m, i; m := -infinity; for i in args do if not type(i, numeric) then return ('procname')(args) end if; if m < i then m := i end if end do; m end proc



Max(3, 1, x, 4)




Would really appreaciate your help with this


I am trying to find the root of an equation that involves a procedure and a definite integral (solved numerically). Of course, I don't need the root to be found symbolically, but numerically would be fine. The problem is, I keep getting the error

"Error, (in fsolve) Can't handle expressions with typed procedures"

whenever I try to solve it. Anyone have any ideas? My worksheet is here: 


I noticed, when using


That some procedures have lost all its formating. No line numbers, no spaces in between, very hard to read. For example, dsolve() in maple.mla is like this. While other procs are well formated and easy to read.

Is there a reason for this? And is there a way to fix this in Browse() to be able to read the source? It is impossible to read it like this readlly. Maple 18.02 on windows.



I've encountered a problem with Maple.


Is it possible to create a procedure which both displays some plots and also returns a value?


When I write a simple example:


It plots a circle as expected.

But when I add return:


It returns value 2, but no plot is displayed.

Is it possible to do both, display and return a value?

I used to write two copies of procedure, one for plotting and one for returning value.

But thats not "pretty" solution.


Thanks for help.

Hallo, I have a list with derrivatives. I'd like to choose elements with highest derrivative.

Is there any procedure in Maple to determine order of derrivative?

Hi experts


In a procedure with no declared parameteres I would like to return (print) the passed arguments (expecting Matrix structures) in a modified form along with the name of the symbol holding the structure passed as arguments.


That is, the procedure just iterates through the _passed arguments in a for-loop to display the name of the the passed argument (the symbol), a colon and then the modified matrix structure.

My problem is that when looping from i to _npassed arguments, refering to _passed[i] gives me the evaluated form.Tat is what I need to modify the structure but not to list the symbol name.


Say I wanted to print a transposed version of my passed matrices. Then I would call



And the result I want would be

M: <<1,3>|<2,4>>

But I don't know if _passed holds the symbol names or just the evaluated versions of the passed arguments??

And theoretically the passed argument (assuming a matrix) could be the matrix structure put directly in the procedure call, in which case there is no symbol to refer to.


I hope you get my question and can help me out.





In this document, I think that is the relevent section. But I couldnt understand it.


I want something like this





>plot(sin(x),color=ABC); # error

>plot(sin(x),color=CBA);# error

optional, but works fine within a given sets of choices.


How do I write a procedure like that?



Hello people in mapleprimes,


I want to draw a graph of a procedure.


filter:=x->if x<10 then 1-x/10 else 0 fi;



works well. But, I don't know why it is needed for filter(x) is wrapped with foward quotte ' .

I changed that quote to back quote ` but, in this case the result hadn't appeared.

And, without the foward quote ', error appears.

And, even if I wrapped x with ' as in plot('filter(x)','x' =0..20),

a graph appeared properly, though I cannot understand why wrapped x, 'x' is right.


Please teach me the logic of the above code.

Best wishes.


taro yamada


So the pseudocode I'm trying to translate into maple is for the greedy vertex coloring algorithm.

The pseudo code is:

1. for i = 1 to n do
2. f[i] := 0 (: no color assigned yet to vertex i :)
3. end(for)
Main loop:
4. for i = 1 to n do
5. let f[i] be the smallest positive integer
which is not in the set {f(j) : j ∈ adj[i]}
6. end(for)
7 return f


The closest I've gotten though is:

greedy := proc (G)

local i, j, n, k, L::list;

description "Take simple graph G and return a coloring of the vertices with at most Delta(G)+1 colors";

n := nops(Vertices(G));
L := [seq(x, i = 1 .. n)];
L := subsop(1 = c(1), L);
j := 1;
for i from 2 to n do
L[Vertices(G)[i]] := c(0)
end do;

for i from 2 to n do
   for k to i do
        if member(Vertices(G)[i], Neighbors(G, Vertices(G)[k])) then j := j+1
       end if; 
   end do;
L[Vertices(G)[i]] := c(j)
end do;
return L;
end proc;

Basically my procedure is returning more than delta+1 colors for most graphs, how can I edit it to fix this? I'm guessing the problem is somewhere in my nested loops. Also, I cannot use commands like greedycolor or isvertexcolorable. Thanks.


Hi, I'm trying to write a maple procedure to differentiate a function from first principles and so far I have

First_Principle := proc (f); for f do A := simplify((f(x+h)-f(x))/h); Limit(A, h = 0) = limit(A, h = 0) end do end proc

and from there I have no idea where to go. Does anybody have any ideas? Thanks!

I have question about how to write the expression to get the order in the sequence?

For exmple, if I have this sequence,


I want to write a procedure that tells me the location of any input,x in the sequence E.

For example, if I choose x:=3, then the number 3 is actually between 2 and 7, so it will give me the answer C(x)=3 (because 7 is the third elemet).

I try to write the procedure but there always wrong! I do not know what expression should I write!

for i from 1 to nops(E) do
if x<=E[i] then

Please help! 

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