MaplePrimes Questions

Search Questions:

Latest Questions Latest Questions Feed

For people new to Maple, an easy way to learn how to code may be Tutor Syntax, that is the technique of generating code by selecting everything in a Tutor dialog Maple Command window and then copying it to a current session.

The code can then be edited to tailor it to user’s needs. A problem with this technique is the copied syntax contains many single quotes (‘ ‘). The single quotes, which are usually not needed if the program in current session is short and specific, increase the difficulty when editing copied syntax. The attached file ( shows a method which removes the single quotes by using the SubstitueAll command in the StringTools package. One drawback: any strings inside the original syntax (e.g., “#78000E”) must be removed before the syntax can be converted to a string.

Is there a better way to generate code from Tutor dialog so it can be edited (without single quotes) in user’s current session?

hi.please help me for remove error'' 

Error, illegal use of an object as a name''




Parse:-ConvertTo1D, "first argument to _Inert_ASSIGN must be assignable"

Error, illegal use of an object as a name

"restart:Digits :=15: beta:=10:alpha:=100: xi:=.5: upsilon:=0.2841945289:n:=3: aa:=1:b:=1:N_x:=0.4:N_y:=0.4:N_xy:=0: hl2:=1:mu:=65.8e9:E:=169e9: delta0:=1:delta1:=1: mus:=3:D1:=2;h:=1: lambda:=0.1: D2:=5:A1:=-2:A2:=-2:A3:=-6:A4:=7:A5:=7:A6:=7:A7:=7:A8:=8:A9:=7:A10:=7:A11:=1: A12:=1:tau:=4.730040745:t:=0: g2:=sin(theta):g3:=cos(theta):g1:=cos(theta):a:=0.0:with(Student[Calculus1]): a1:=evalf((A1*ApproximateInt(g3^2,theta=a..1,method=simpson)  ) ) : a2:= evalf(A2*ApproximateInt(g3*((ⅆ)^2)/((ⅆtheta)^2)g3,theta=a..1,method=simpson)): a3:=evalf(A3*ApproximateInt(g3*g3,theta=a..1,method=simpson)) : a4:=evalf(A4*ApproximateInt(g3*g3,theta=a..1,method=simpson)) :a5:=evalf(A5*ApproximateInt(g3^2,theta=a..1,method=simpson)) : a6:=evalf(A6*ApproximateInt(((ⅆ)^2)/((ⅆtheta)^2)g3*g3,theta=a..1,method=simpson)) :a7:=evalf(A7*ApproximateInt(g3*g3,theta=a..1,method=simpson)): a8:=evalf(A8*ApproximateInt(g3^2,theta=a..1,method=simpson)):a9:=evalf(ApproximateInt(A9*(g3*g3 )     ,theta=a..1,method=simpson)) :a10:=evalf(A10*ApproximateInt(g3*g3,theta=a..1,method=simpson)):a11:=evalf(ApproximateInt(1,theta=a..1,method=simpson)):a12:=evalf(ApproximateInt(1*(1-1/2 (1)),theta=a..1,method=simpson)):dsys3 := { f3(x)*(a1)+ f3(x)*(a2)  +((ⅆ)^2)/((ⅆx)^2) f3(x)*(a3) +f3(x)*a4+ f3(x)*(a5) +((ⅆ)^2)/((ⅆx)^2) f3(x)*(a6) +f3(x)*a7= ((ⅆ)^2)/((ⅆx)^2) f3(x) *(a8)   + a9*(ⅆ)/(ⅆx) f3(x) +f3(x)*a10+ a11+a12  , f3(1) =0,f3(0) =0 , D^(1)(f3)(1) = 0, D^(1)(f3)(0)=0,D^(3)(f3)(1) = 0, D^(3)(f3)(0)=0}    :dsol5 := dsolve(dsys3, 'maxmesh'=2024, numeric,abserr=.0001, range=0..1, output=listprocedure):fy3:= eval(f3(x),dsol5):with(CurveFitting):fy33:=PolynomialInterpolation([[0,fy3(0)],[.1,fy3(0.1)],[.2,fy3(0.2)],[0.3,fy3(0.3)],[.4,fy3(0.4)],[.5,fy3(0.5)],[0.6,fy3(0.6)],[0.7,fy3(0.7)],[0.8,fy3(0.8)],[0.9,fy3(0.9)],[1,fy3(1)]],x): d1:=A1*ApproximateInt(((ⅆ)^6)/((ⅆx)^6)fy33*fy33,x=a..1,method=simpson)   :d2:= A2*ApproximateInt(((ⅆ)^4)/((ⅆx)^4)fy33*fy33 ,x=a..1,method=simpson)   :d3:=A3*ApproximateInt(((ⅆ)^2)/((ⅆx)^2)fy33*fy33,x=a..1,method=simpson): d4:= A4*ApproximateInt(fy33*fy33,x=a..1,method=simpson):d5:=A5*ApproximateInt(((ⅆ)^4)/((ⅆx)^4)fy33*fy33,x=a..1,method=simpson)  : d6:=A6*ApproximateInt(((ⅆ)^2)/((ⅆx)^2)fy33*fy33,x=a..1,method=simpson)    :d7:=A7*ApproximateInt(fy33*fy33,x=a..1,method=simpson)  :d8:=A8*ApproximateInt(((ⅆ)^2)/((ⅆx)^2)fy33*fy33,x=a..1,method=simpson)      :d9:=ApproximateInt(A9*(((ⅆ)^1)/((ⅆx)^1)fy33*fy33 )   ,x=a..1,method=simpson) :d10:=A10*ApproximateInt(fy33*fy33,x=a..1,method=simpson)    :d11:=evalf(ApproximateInt(1,theta=a..1,method=simpson)):d12:=evalf(ApproximateInt(1*(1-1/2 (1)),theta=a..1,method=simpson))  : d sys4 := { h3(theta)*(d1)+((ⅆ)^2)/((ⅆtheta)^2) h3(theta)*(d2)+((ⅆ)^4)/((ⅆtheta)^4) h3(theta)*(d3)+ ((ⅆ)^6)/((ⅆtheta)^6) h3(theta)*(d4)+h3(theta) *(d5)+ h3(theta) *(d6) +((ⅆ)^4)/((ⅆtheta)^4) h3(theta)*(d7)= h3(theta)*(d8)  +d9*(ⅆ)/(ⅆtheta) h3(theta)  +((ⅆ)^2)/((ⅆtheta)^2) h3(theta)*(d10)  +d11+d12   ,h3(1) = 0,h3(0) = 0 , D^(1)(h3)(1) = 0, D^(1)(h3)(0)=0,D^(3)(h3)(1) = 0, D^(3)(h3)(0)=0}  :dsol6 := dsolve(dsys4, 'maxmesh'=2024, abserr=.0001, range=0..1, numeric, output=listprocedure):g33:= eval(h3(theta),dsol6):with(CurveFitting):g3:=PolynomialInterpolation([[0,g33(0)],[.1,g33(0.1)],[.2,g33(0.2)],[0.3,g33(0.3)],[.4,g33(0.4)],[.5,g33(0.5)],[0.6,g33(0.6)],[0.7,g33(0.7)],[0.8,g33(0.8)],[0.9,g33(0.9)],[1,g33(1)]],theta):"






When the Physics package is loaded, Maple returns the following error in connection with the simple statement 2*D[1]:

Error, (in TypeTools/ac_var_local) unable to determine the anticommutative character of D[1]

Why that? Although to no avail, for D[1] there is no problem. Note that the above error results even without having set up any anticommutative prefixes or the likes in Physics Setup.

PS: I am using Maple 17.

I would like to present you a recurring problem of mine.


It is very common, in Modeling and Simulation activities, to account for Uncertainties.

In order to set these ideas down, consider a computational code F (typically a code that solves a set of PDEs in space (M) and time (t) ) and its response Y = F(M,t) (here Y is a short for Y(M,t)).

This response Y usually depends also on some set P of parameters (each of them considered as a scalar quantity) .
A more convenient way to note Y  is Y(M, t | P) where the "|" character is used here to express that Y is considered as a function of M and t for each given value of P.
Generally one does not consider Y as a whole but more often one focuses on some quantity of interest (Q) derived from Y through applying it some operator G (for example the operator max(Y) over some space and time domain).

Applying G generally makes  Q to appear as a function of P alone.
In Uncertainty Quantification activities, a major concern is to understand how uncertainties about P modify the values of Q ?
The classical framework is to consider P as a (multi-dimensionnal) random variable. 
One of the most common problems is then to assess some basic characteristics of Q, where Q is considered as a function of P (a quick and notional notation is Q = H(P) = (G°F)(X, t | P)).

The simpler and faster method to do this is based on a Taylor expansion of H (provided some conditions hold) arround some particular point p* (p* could be the mean of the multi-dimensional distribution of P)
One writes, for every value p of P :

Q = H(p) = H(p*) + (H')t (p-p*) + 1/2 (p-p*)t H" (p-p*) ...

  H'  is the gradient vector of H according to P at point P = p*
  H" is the hessian matrix of H according to P at point P = p*
  (p-p*) is the vector of differences, assumed to be "small"

Let E the usual "mathematical expectation" operator.
Let us assume  p* denotes the mean of P.
Then, applying E to  the previous formula gives :

E(Q) = E(H(p*)) + E(...) + ....

Assuming some conditions hold, the first order mathematical expectation E(Q) of Q is simply E(H(p*)) = H(p*) = H(E(P))

Some little algebra gives the first order approximation of the variance V(Q) = E(Q^2)-(E(Q))^2 of Q : 

V(Q) = (H')V(P) H'  where V(P) is the variance matrix of P



I would like to define the operator E so that I could derive automatically approximations of the first 4 moments of Q, up to any desired order.
In particular, order 2 is often necessary as soon as (G°F) is highly non linear regarding P ; and estimations of the 3rd and 4th moments is of great help to determine how much symetric or flat is the distribution of Q.

The idea is to define an operator E with suitable properties and to apply it to a multivariate taylor expansion of Q^n where n is any positive integer

I tried to do this by my own (look to the supplied .mw file) but I do not have sufficient skill in Maple to complete the job.

Could someone help me ?

Even if I am not qualified in saying this, I believe that this type of approximation of the different moments of Q could be included in a future release of Maple ?

Thanks in advance 




The expression (D[1]@D[2])(f) is equivalent to D[1,2](f). On grounds of that, I would naively have expected that (D[1]@D[1])(f) was equivalent to D[1,1](f). But it seems not to be, their lprint-versions being different:

expr1 := (D[1]@D[1])(f):
expr2 := D[1,1](f):
simplify(expr1 - expr2);
simplify(expr1 - expr2,`@`);

D[1, 1](f)

I am curious to know why it has been implemented this way? Have I fundamentally misunderstood something?

I'm working in a tridimensional euclidean space, with vectorial functions of the type:



The two odes are of the type:


While there are other non-differential vectorial equations like:

eq1:=K4*F4''(t)=(K5*F5(t)&x<0,1,0>)/Norm(F6(t))+..., etc


Is there a way i can input this system in dsolve with vectors instead of scalars? And without splitting everything into its 3 vectorial components? I can't make maple realize some of the Fi(t) functions are vectors, it counts them as scalars and says the number of functions and equations are not the same.


Thank you!


Hope a nice day for all


#  *%   define the product of between two operators, and q real number
a*%b = q*b*%a+1;

# First I would like to give a simple for

# and                                    

them deduce a general for                                      


 where n, k and k greater than 1 and  n geater than k


Thanks for your help


If I am in the Maple debugger, stopped in a routine, how can I navigate between stack frames, such as looking at the variables of the calling function?

"outfrom" is not sufficient for this purpose as that continues execution until return, which would change the variables of the routine I am in, and could potentially take a long time. And more importantly for my particular purpose, the routine I am stopped in is a package's "I found an error" routine which is (deliberately) throwing an exception, so there will not be any return.

I can use where or where? to look at the name of the calling routines. Unfortunately, for the code I am debugging, the calling routine is being dynamically loaded so I do not have a file name for it and I cannot put a persistent breakpoint in it: I need to climb the tree of dynamic calls with their various parameters in order to figure out how the error occured.

Hi all

Is Ising a package?

for i = 1:12000

%while (1),

% Choose a random value between 0 and 1 for the interaction strength

J = rand()+1e-10;

% Perform a simulation

[M, N, E] = ising2(n_grid, J);

% Records the results

Ms = [Ms M/(n_grid^2)];

Es = [Es E/(n_grid^2)];

Ns = [Ns N];

Js = [Js J];

i = i+1;

Is there an elegant way to plot the region between the surfaces z=-y^2 and z=x^2, only on the domain of the XY-plane bounded by the triangle with vertices (0,0), (1,0) and (1,1)?

I am trying to simplify the square of a parameterized polynomial mod 2. My parameters are intended to be either 0 or 1. How do I accomplish this?

For example:


alias(alpha = RootOf(x^4+x+1))



z := alpha^3*a[3]+alpha^2*a[2]+alpha*a[1]+a[0]``



z2 := collect(`mod`(Expand(z^2), 2), alpha)








I would like to simplify the squared parameters modulo 2. a[3]^2=a[3], etc.

Any help would be appreciated. Elegant methods even more so!






How can i over come convergence error, i am unable to apply approxsoln appropriately and continouation as well. regards

N := 5;

-(1/2)*Pr*n*x*(diff(f(x), x))*(diff(theta(x), x))-(1/2)*Pr*(n+1)*f(x)*(diff(theta(x), x))-(1/2)*(n+1)*(diff(diff(theta(x), x), x))+Pr*gamma*((1/4)*(n^2-3*n+3)*x^2*(diff(f(x), x))*(diff(diff(f(x), x), x))*(diff(theta(x), x))+(1/4)*(2*n^2+5*n+3)*f(x)*(diff(f(x), x))*(diff(theta(x), x))+(1/4)*n(n+1)*x*f(x)*(diff(diff(f(x), x), x))*(diff(theta(x), x))+(1/4)*(2*n^2+3*n-3)*x*(diff(f(x), x))^2*(diff(theta(x), x))+(1/4)*(n-1)*x^2*(diff(diff(f(x), x), x))*(diff(theta(x), x))+(1/2)*n*(n+1)*x*f(x)*(diff(f(x), x))*(diff(diff(theta(x), x), x))+(1/4)*(n^2-1)*(diff(f(x), x))^2*(diff(theta(x), x))+(1/4)*(n+1)^2*f(x)^2*(diff(diff(theta(x), x), x))+(1/4)*(n-1)^2*x^2*(diff(f(x), x))^2*(diff(diff(theta(x), x), x))) = 0


bc := (D(theta))(0) = -Bi*(1-theta(0)), theta(N) = 0, f(0) = 0, (D(f))(0) = 0, (D(f))(N) = 1;

(D(theta))(0) = -Bi*(1-theta(0)), theta(5) = 0, f(0) = 0, (D(f))(0) = 0, (D(f))(5) = 1


a1 := dsolve(subs(beta = .1, n = .5, Pr = 10, gamma = .1, Bi = 50, {bc, eq1, eq2}), numeric, method = bvp[midrich], abserr = 10^(-8), output = array([seq(.1*i, i = 0 .. 10*N)]))

Error, (in dsolve/numeric/BVPSolve) initial Newton iteration is not converging





This week I am participating in 19th Ising lectures (see The Serguei Nechaev's talk inspired me to ask the question:
"How to simulate a random walk on an undirected and unweighted (and, of course, connected) graph
(All the paths from a vertex of degree k have the same probability 1/k.)?"
A Maple procedure to this end is welcome.

I want to create a matrix (B) from entries of other matrices (A) with a helper-function (helper). The helper function is defined such that it returns a certain matrix depending on the index variables. This is necessary because the inner matrices are constructed with another function.

Since the helper-function returns matrices, the big matrix is of datatype=matrix. Unfortunately, creating the big matrix with the correct size and forcing the datatype=float, does not yield the desired result. However, the manual definition using the constructor with a list of matrices does create the desired matrix.

How do I resolve a matrix of matrices?

Note: I know that I could write a convert function that copies the entries to a corresponding matrix, though this seems to be unnecessary effort to me.

This might not be minimal but shows the issue. (Compare B and test)


size_A := 2;
size_B := 3;





helper2 := proc(i::integer,j::integer);
  if i=j then
  elif i=j-1 or i=j+1 then
  end if;
end proc:

helper3 := proc(i::integer,j::integer);
  if i=j then
  elif i=j-1 or i=j+1 then
  end if;
end proc:

A := Matrix(size_A, size_A, helper2);
B := Matrix(size_B, size_B, helper3);
B := Matrix(size_B,size_B, helper3, datatype = float);
B := Matrix(size_B*size_A, size_B*size_A,[Matrix(size_B,size_B,helper3)], datatype = float)

A := Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})


B := Matrix(3, 3, {(1, 1) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (1, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (1, 3) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (2, 1) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (2, 2) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (2, 3) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 1) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (3, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 3) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})})


Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]


Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]


test := Matrix(4, 4, [
                [Matrix([[1,2],[0,9]]), Matrix([[3,6],[0,9]])],
                [Matrix([[3,4],[7,8]]), Matrix([[7,6],[5,5]])]
               ]); # is converted to a matrix of floats

test := Matrix(4, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (1, 4) = 6, (2, 1) = 0, (2, 2) = 9, (2, 3) = 0, (2, 4) = 9, (3, 1) = 3, (3, 2) = 4, (3, 3) = 7, (3, 4) = 6, (4, 1) = 7, (4, 2) = 8, (4, 3) = 5, (4, 4) = 5})


Hi guys,

I have written a program in Maple 2016 (Windows 7) made of two parts :

  1. An initialization step where a formal system of algebraic equations (some non linear) is built
    Let S(U, P) this system, where U denotes a set of unknowns and P a set of parameters (see step 2 below)
  2. An iterative step where this system is solved with respect to U for different values of parameters P
    This loop has to be executed N times for values P1, ..., Pn, ... of P

I observe that the size of the memory (bottom right of the Maple window) inflates as the value of n increases.

I was able to isolate in the loop corresponding to step 2, the procedure MyProc I wrote which is responsible of this memory inflation.
Now I would like to manage this inflation (typically the memory size grows up to 3 GiB for n about one thousand) because of its very negative effects on the computational time (probably Maple does spend a lot of time in swapping operations).

Suspecting the remember process to be the source of this problem, I tried simple tricks such as

  • systematically write   > quantity := 'quantity';   for fome intermediate quantities
  • use forget  : for example MyProc contains a call to fsolve and,  after "local" declarations, I inserted  the command  forget(fsolve)   
  • in the the loop over n,  I even inserted the command forget(Myproc).

None of these tricks was to some extent efficient to contain the memory inflation.

I suppose it is a very common situation that people who use to develop code are familiar with. So maybe some of you could provide my some advices or move me towards "strategies" or "methodologies" to prevent this situation ?
My purpose here is not to ask you to solve my problem, but rather to ask youy to give me hints to be able to manage such kind of situations by myself.

Maybe this question is unorthodox and doesn't have its place here ?
It that case please let me know.

Thanks In Advance

PS : it would be very difficult for me to provide you the code : if it is a necessary condition for you to help me, just forget it, I will understand

2 3 4 5 6 7 8 Last Page 4 of 1313