Items tagged with variables variables Tagged Items Feed

I'm writing some code that computes a positive integer N and I'd like Maple to define a function of N variables. I've tried writing 

f := (seq(t[i],i=1..N))-> MY EXPRESSION;

but I receive the error

Error, invalid parameter; functional operators require their parameters to be of type symbol or (symbol::type)

Is there anything I can do here?

Hi all,

I'm using MAPLE 13 and I'd like to know if someone knows how to generate the variables associated to the CodeGeneration for C code. At this moment I need to create manually the variable generated from the C code.


JJ := Jacobian(convert(Pint, Vector), [P1xenu, P1yenu, P1zenu, roll, pitch, yaw, D1xbody, D1ybody, P2xenu, P2yenu, P2zenu, ROLL, PITCH, YAW, D2xbody, D2ybody]);

CodeGeneration['C'](JJ, optimize);


t1 = cov2 * cov2;
t2 = cov1 * cov1;
t4 = 0.1e1 / (t1 + t2);

And in the C code I need to create:

double t1, t2, t3..... manually

I can I solve this issue?

Best regards

André Dias

I want to sum over several variables at once.


For example, something like


sums over 3 variables. But this can only be done if I know the number of variables in advance. I want to write a code that will sum over m variables, with m being supplied on demand.


Maple can do this for integrals. If I write


the integral is computed over m variables, for any m.


How can something like this be implemented for summation?


I'm having some trouble maybe someone can point out my error please. I'm using the Maple 18 worksheet to try some basic linear equations. The trouble is in the last step.


1.) I start with 2 ordered pairs (2, 14) and (14,18)

Then I put in my formula to discover the slope. I confirm it looks correct in the Variables window.

m := (y2-y1)/(x2-x1);


2.)  Next I input the values for my ordered pairs. I also confirm thru the Variables window.

x1 := 2;

y1 := 14;

x2 := 3;

y2 := 18;


3.) Now I can type m and expect to get an answer to what my slope is.


4.) Now I want Slope/Intercept form of y=mx+b. When I put in the formula y-y1=m(x-x1) i get a strange result


When I execute this formula, the result is y-14=4. (or thru context menu I tell it to solve for y, then I get y=18)


When I manually input the values, the output is y-14=4x-8 (or thru context menu I tell it to solve for y, then I get y=4x+6)

y-14 = 4*(x-2)




Why is my equation (y-y1=m(x-x1)) not executing properly?

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 Maple-Prime-ers!

I have a system of equations, containing 18 variables and 13 equations, making this a 5 degree of freedom (DOF) system.  I would like to analytically solve each of the equations in terms of each of these DOFs.  Normally I would use solve(system, dof_variables) to accomplish this, but it doesn't return anything.  Not even [].

I can solve this system by hand.  I've included a hand-solution involving isolate() and subs() in the attached worksheet.  I'm looking to incorporate this in an optimization algorithm with varying system, so I would like an automated way of doing this.

Does anybody have any suggestions to get solve to work as intended?


Here is the system I am talking about:



The free variables are:  {FD_T, FD_W, ICE_T, EM2_T, BRAKE_T}


I'm looking for a solution in this form:






How can I use maple and separation of variables ,solve the wave equation utt=uxx for a string of lengh 4 with u(x,0)=sin (Pi/2 x) e-x . ut(x,0)=0.u(0,t)=0 and u(4,t)=0.

I am trying to write a procedure that have the following input:  expr, xdata,ydata. [dependent variables list]

I want a procedure to calculate Rsquare following the method described in


But I want the proc to take any abitary function and be able to identify the  dependent can I approach it? what function can I use to match [dependent variable list] in expr??





Ok, I am not able to find about this after 30 minutes search (my limit of giving up :).

One can ofcourse make a local variables in a proc. But sometimes I need to make a temporary variable within the proc, say inside an to use for some local temporary computation. There is no need for this temporary variable to be declared at the whole proc() scope, since it is used only inside some limited scope.  I am not able to find how to do this in Maple. Here is some silly example

     local x;
     if x<10 then
        local z;
     end proc;

the above is illegal. I can do this:

     local x;
     if x<10 then
        end proc;    
     end proc;
which compiles , but does not do what is expected. The body of the `if` statement is not called. I added a print statments there and they are not being called. (I guess since it is non-named proc(), it is not called, I thought it will fall through....

I looked for some kind of BLOCK , or DECLARE construct or such in Maple but can't find it.

is it possible to introduce a temporary local scope within a proc()? What would be the syntax? That would be really useful. Ada has this feature.


Consider the differential equation zZ'' + Z' + a2Z = 0,  where Z = Z(z).  Using the change of variables x = \sqrt{z/b}with b a constant,  obtain the differential equation Z'' + (1/x)Z' + c2Z = 0, where Z = Z(x) and c = 2a \sqrt{b}.

I tried Maple help and it offers the dchange command, and what I have tried is shown below;


DE:= ...

tr:= {z = x2b}

dchange(tr, DE)

This did not return anything however.  I am thinking I need to specify that b is a constant, however, I am a little unsure on how to do this. Is the above the correct way to proceed?  I don't see how I have specified anywhere that in the final PDE, I require Z=Z(x).

Thanks for any help.  This is my first post here, so apologies for the typesetting. If there is inbuilt latex, I will use it next time.

The purpose is to display the projection of a 3D plane, defined by the points of P. "res" contains the points projected on a 2D plane and all variables beginning with "vlak" contain the points from res that should be connected to form a plane. The command polygonplot connects the points. Every time, it gives the error message "Error, (in plots:-polygonplot) points are not in the correct format". When I copy the code to a place outside the procedure, I discovered some variables are not defined.

restart:with(linalg):with(LinearAlgebra):with(VectorCalculus):with(plots): eerste:=proc(V,N,P) local M,M1,M2,I4,NT; NT:=Transpose(N); M1:=V.NT; I4:=IdentityMatrix(4); M2:=(N.V).I4; M:=M1-M2; M.P; end proc: tweede:=proc(OS,r,s,P1) local VC,K: K:=Matrix(4,3,[r,s,OS]); VC:=(MatrixInverse(Transpose(K).K)).Transpose(K); VC.P1; end proc: project:=proc(P,V,N,OS,r,s) local P1,P2,i,j,n: P1:=eerste(V,N,P); P2:=tweede(OS,r,s,P1); n:=ColumnDimension(P2); for i from 1 to n do for j from 1 to 2 do P2[j,i]:=P2[j,i]/P2[3,i]; end do: end do: DeleteRow(P2,3); end proc: P:=Matrix([[ 0 , 10 , 10 , 0 , 0 , 10 , 10 , 0 , 5 ], [ 0 , 0 , 10 , 10 , 0 , 0 , 10 , 10 , 5 ], [ 0 , 0 , 0 , 0 , 30 , 30 , 30 , 30 , 40 ], [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]]): V:=Vector([60,60,50,1]); N:=Vector([1,0,0,0]); OS:=Vector([10,10,0,1]); r:=Vector([0,1,0,0]); s:=Vector([0,0,1,0]); Vector[column](%id = 18446744073889448174) Vector[column](%id = 18446744073889448414) Vector[column](%id = 18446744073889448534) Vector[column](%id = 18446744073889448654) Vector[column](%id = 18446744073889448774) translatie:=t->Matrix([[ 1 , 0 , 0 , 1*t ], [ 0 , 1 , 0 , 1*t ], [ 0 , 0 , 1 , 0 ], [ 0 , 0 , 0 , 1 ]]); [1 0 0 VectorCalculus:-*(1, t)] [ ] [0 1 0 VectorCalculus:-*(1, t)] t -> [ ] [0 0 1 0 ] [ ] [0 0 0 1 ] f:=proc(t) local volgende,res,vlak_onder,vlak_links,vlak_voor,vlak_rechts,vlak_boven,vlak_achter,vlak1,vlak2,vlak3,vlak4,pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8,pp9,pp10: volgende:=MatrixMatrixMultiply(translatie(t),P): res:=project(volgende,V,N,OS,r,s): vlak_onder :=Transpose(Matrix([Column(res,1),Column(res,2),Column(res,3),Column(res,4)])): vlak_links :=Transpose(Matrix([Column(res,1),Column(res,2),Column(res,6),Column(res,5)])): vlak_voor :=Transpose(Matrix([Column(res,2),Column(res,3),Column(res,7),Column(res,6)])): vlak_rechts:=Transpose(Matrix([Column(res,3),Column(res,4),Column(res,8),Column(res,7)])): vlak_achter:=Transpose(Matrix([Column(res,1),Column(res,4),Column(res,8),Column(res,5)])): vlak_boven :=Transpose(Matrix([Column(res,5),Column(res,6),Column(res,7),Column(res,8)])): vlak1:=Transpose(Matrix([Column(res,8),Column(res,7),Column(res,9)])): vlak2:=Transpose(Matrix([Column(res,8),Column(res,7),Column(res,9)])); vlak3:=Transpose(Matrix([Column(res,8),Column(res,5),Column(res,9)])); vlak4:=Transpose(Matrix([Column(res,5),Column(res,6),Column(res,9)])); pp1:=polygonplot(vlak_onder): pp2:=polygonplot(vlak_links): pp3:=polygonplot(vlak_voor): pp4:=polygonplot(vlak_rechts): pp5:=polygonplot(vlak_achter): pp6:=polygonplot(vlak_boven); pp7:=polygonplot(vlak1); pp8:=polygonplot(vlak2); pp9:=polygonplot(vlak3); pp10:=polygonplot(vlak4); {pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8,pp9,pp10}: end proc: display(f(0),scaling=constrained); Error, (in plots:-polygonplot) points are not in the correct format

Above, you can see the code. When only pp1->pp7 is displayed, and pp8->pp10 is placed between commenting marks, it works fine. Otherwise it doesn't work, it looks like Maple does not define the variables pp8->pp10. I don't understand because there is no difference between pp7 and pp8.

Thanks in advance

Dear all,

I'm trying to substitute a combination of variables in an equation that is partly covered in a summation.

For example consider the equation with two variables A and B, and two function W(t) and q(z):

eq1:=A*B*(sum(W[n](t)*q[n](z), n))

now I want to do the substitution:

Hi, I am hoving trouble understanding how variables are meant to be declared. I have global variables that I wish to use that are tabled values such as m[1], ie: m subscript 1.However, when declaring parameters, local, or global variables within a procedure it does not allow them to be tables values. Why is this? and How should i be declaring these values?for example:Range:=proc(b[1]).... b subscript 1 will generate invalid parameter declarationRange:=proc(b) local c[1]...c subscript...

Dear Maple Users

I am mainly in favor of the new rules concerning subscripts. Using Ctrl+-- (double underscore) it is pretty straight forward to get a literal subscript and it displays much better in the palette Variables than was the case i Maple 16. Also the purple coloring of a variable containing a literal subscript makes sense, because it can be distinguished from the usual subscript (now Ctrl+shift+-). Good that you can remove the coloring in the View Menu (Atomic Variables...


i want to minimizez the "Eq1(h[1],h[2],...h[n])" for all the h[i] in the ranges of -1<h[i]<1.  "n" (number of unknown variables) can be determined during the code and was not know before. how can i do this?

It must be stated that when i have Eq1 and two unknown variables such as h[1] and h[2], i wrote the following code and it works good, but i dont know how can i write mentioned command for unknown number of variables.


thanks for your attention in advance

1 2 Page 1 of 2