MaplePrimes Questions

Hi friends, I have a set of polynomials, 'a', and I want to calculate the product of all possible combinations by taking 3 elements at a time. Like this:

a := {x+1,x+2,x^2+1,x^2+x+2}

I have a larger 'a' set so I was looking for a simple method to perform these operations.
Thank you.

How can I use fdiff within Optimization:-NLPSolve and get rid of this error?

Here is an example


# with exact gradient
obj := proc(v)
         10*v[1]^2 - 2*v[1]*v[2]^2 + v[2]^4 + 1 - 2*v[2] + v[2]^2
       end proc:

objgrad := proc(v, w)
        w[1] := 20*v[1] - 2*v[2]^2:
        w[2] := -4*v[1]*v[2] + 4*v[2]^3 - 2 + 2*v[2]
end proc:

NLPSolve(2, obj, objectivegradient=objgrad);
[0.276597509679878506, [0.0364560120817733,0.603788442821000]]

# with approximated gradient estimated "by hand"
objgrad := proc(v, w)
        local eps  := 1e-8:
        w[1] := ( obj(v+~[eps, 0]) - obj(v-~[eps, 0]) )/(2*eps):
        w[2] := ( obj(v+~[0, eps]) - obj(v-~[0, eps]) )/(2*eps):
end proc:

NLPSolve(2, obj, objectivegradient=objgrad);
[0.276597509679878562, [[0.0364560121188285,0.603788442801479]]

# with approximated gradient computed with diff
objgrad := proc(v, w)
        w[1] := fdiff(obj, [1], v);
        w[2] := fdiff(obj, [2], v);
end proc:

NLPSolve(2, obj, objectivegradient=objgrad);
Error, (in Optimization:-NLPSolve) invalid input: fdiff expects its 3rd argument, X, to be of type {algebraic, equation, list(algebraic), list(equation), set(equation)}, but received Vector[row](2, {(1) = 1.0, (2) = 1.0}, datatype = float[8])

Thanks in advance


I have a function of 3 variables (PiM) which I can use in plot3d given the first argument while the other two arguments are functions of the two variables I use in plot3d.

In the code I attached below, I am plotting 2 planes using plot3d, but I cannot implicitplot where these two planes intersect. COuld you please take a look at my code?




I have a huge trigonometric expression in Maple with an approximate length of length(.)=397593353.

When I compute this expression in Matlab, I receive another expression with a much smaller length, and the reason is that Matlab is using subexpressions to calculate the main expression. However, I need to do this in Maple.

I have already tried to simplify, but it didn't work.
The maple worksheet & a screenshot of the Matlab subexpression is attached.

See below file for expression in maple (Please run the "Main.mpl" in the attached file.):

And part of the expression in Matlab is shown in the below picture

Where the subexpressions (again in Matlab) are shown below:

Let a,b,c,d and E be constants.

Prove that Laplace{at^-c+bt^-d} = E{as^-c+bs^-d}

if and only if c+d=1 and E= +or-  sqr(pi*csc(c*pi))

Given the property of Gamma:

Gamma(p)Gamma(1-p)=pi/(sin(p*pi)), 0<p<1

This is from an old Schaums outline on Laplace Transforms.

By hand i get  E{as^-d+bs^-c}.

Cant figure out how to get Maple to express this.

Greeting to all of you, I'm having problem in searching for R in this silmutaneious equation. How do I solve this?


Please help me to solve the system of nonlinear ordinary differential equations with the help of the Homotopy perturbation method in MAPLE. I have attached a worksheet please check.  Please please help me.

Thank you


Is there a way to change the font type and size when printing a table of data using DocumentTools:-Tabulate? Also can I change the column width?

I have calculated z=f(x,y) for x from 0 to 5 and y from 0 to 5 by taking step size 0.5  and stored it in a matrix M. Now I am trying to plot the resultant matrix having order 11x11. Where x and y values are ranging from 0 to 5. But If I use this command
matrixplot(M, heights = histogram, colorscheme = ["Blue", "Green", "Yellow", "Red"])
It is taking 0 to 11 on both x and y axis. It must be 0,0.5,0.1,0.15...5.
How to change the values of x and y axis manually?

hi! how can I write it correct?

this is the parametric curve in cartesian coordinates:

spacecurve([2*t^3 - 2*t, 4*t^2, t^3 + t], t = -1 .. 1, color = black, numpoints = 1000, orientation = [90, 90, 90]);

and this should be the same curve but in spherical coordinates:

spacecurve([sqrt(5)*(t^3 + t), arccos(1/sqrt(5)), arccot((t^2 - 1)/(2*t))], t = -1 .. 1, coords = spherical, color = black);

I rewrite that parametrization using formula from this page

why doesn't it work?

help on structured type says

| identical(expr) an expression identical to expr


The type identical(expr) matches the expression expr identically. If there is more than one expr (i.e. identical(expr1,expr2,...)), then this type matches any one of the exprN identically.

Then why does the following produce the same output?

select(type,expr,'`*`'({anything, identical(x^2)}));
select(type,expr,'`*`'({anything, identical(x)}))



I would have expected only the second select to find x*A[2].

What do I need to only select anything*x^2 without selecting anything*x ?

Actually anything in identical gives same result

select(type,expr,'`*`'({anything, identical(zzzzz)}));


So I must be misunderstanding something about identical and how it works.  I want to match only anything*x^2 and nothing else. How to do that?

all these things are trivial to do use pattern matching. But in Maple, one is supposed to use structured types.


I can't figure this one out.

I need to pick out the subexpression   anything*sin(3*x) from an expression.

it works, when the expression is   anything*sin(3*x)+something else. But when the expression is exactly  anything*sin(3*x) then select returns and not anything*sin(3*x) as I was expecting.

So I must be doing something silly, but do not see it.

TypeTools:-AddType('type_1', '`*`'({anything,identical(exp(3*x))}));

returns true. good. Now I test it on 

select(type,expr+sin(x),type_1) ;

and this returns what is expected. 25*A[1]*exp(3*x) but when I type

select(type,expr,type_1) ;

it return

reading select help page did not help.  Tried flatten, inplace.

I can do this using patmatch


But why is select not working in the above? What is the correct way to do this so it works for a*expr+anything and also for a*expr only? This is done inside a function and not interactive. So I need it to work for both cases, since the input can be anything, but I only need the term anything*exp(3*x) pulled out.



As I am continuing to use Maple, I find I use multiple customized worksheets and documents as well as a maple student guide or AEM guide.......How can I save the workspace with these other documents so that I don't have to rebuild them everytime I use that customized Maple system?

Thanks for your help!


When I work with the fsolve and the number of variables is greater than 9, I have to use the op very carefully, because the order of the variables changes. The same thing happens when working with dsolve(numeric), which is especially inconvenient. For example, the RootFinding [Isolate]  works fine.
I ran into this a very long time ago and I have examples with 15 variables. It is completely unclear why such was done.
How to work with it or how to avoid it?
Example of the same solution using  fsolve and RootFinding [Isolate]

 CD1 := -.5; CD2 := 2; CD3 := 1.; 
 g1 := 5.; g2 := 3.; g3 := 2.; 
 cg1 := 0.; cg2 := 3.7; cg3 := 1;
 cd1 := 7.5; cd2 := 0; cd3 := 0; 
 L1 := .72; L2 := 8.6; L3 := 5.5; L4 := 1.25; L5 := 3.102; L6 := 5.1; L7 := 7.; 
f1 := (CD1-x4)^2+(CD2-x5)^2+(CD3-x6)^2-L1^2; 
f2 := x1-5; 
f3 := x5-1.45; 
f4 := (g1-x1)^2+(g2-x2)^2+(g3-x3)^2-L3^2; 
f5 := (x7-x1)^2+(x8-x2)^2+(x9-x3)^2-L2^2; 
f6 := (cg1-x7)^2+(cg2-x8)^2-(cg3-x9)^2-L4^2; 
f7 := x7+x8-1.2*cg2; 
f8 := (x4-x7)^2+(x5-x8)^2+(x6-x9)^2-L5^2; 
f9 := (cd1-x10)^2+(cd2-x11)^2+(cd3-x12)^2-L6^2; 
f10 := (x1-x10)^2+(x2-x11)^2+(x3-x12)^2-L7^2;
f11 := x11-.1*x12; 
f12 := x1-x2-x3-x4+x5+x6+x7+x8+x9+x10+x11-x12; 
fsolve({f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12}); 
RootFinding[Isolate]([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12], [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12])[4];
  {x1 = 5.000000000, x10 = 6.265979021, x11 = 0.4923895285, 
  x12 = 4.923895285, x2 = 7.363909611, x3 = 5.347580157, 
    x4 = -0.4802494112, x5 = 1.450000000, x6 = 0.5357695462,
    x7 = 2.014012007, x8 = 2.425987993, x9 = -1.029002454}
[x1 = 5., x2 = 7.363909611, x3 = 5.347580157, x4 = -0.4802494112, 
  x5 = 1.450000000, x6 = 0.5357695462, x7 = 2.014012007,
  x8 = 2.425987993, x9 = -1.029002454, x10 = 6.265979021,
  x11 = 0.4923895285, x12 = 4.923895285]


My first day attempting Maple so probably something simple about environment variables.

I'm trying to use Digits in an expression to set and use the preceision. It seems to set the value if used in a procedure but seems to update the variable after the execution of multiple commands executed together - also setting a variable from Digits, updating it, then using that in evalf doesn't help.

Digits := 1

Digits := Digits + 1; Digets; 1.0/3;

Gives 1 digit, Setting of Digits takes affect after the evaluation.

f := proc() Digits + 1; 1.0/3; end proc


2 digits - so the setting of Digits takes effect before the evaluation. Looks like the procedure is executed as separate commands.

So repeated executes of 

f(); Digits++;

Will increment the precision as will

f := proc() Digits++; print(evalf[Digits](1.0/3)); return Digits; end proc; Digits := f();


a := 1; a := a + 1; evalf[a](1.0/3);

Gives 2 digits

a := Digits + 1; evalf[a](1.0/3);

Gives 1 digit.

a := eval(Digits + 1); evalf[a](1.0/3);

Gives 1 digit.

First 80 81 82 83 84 85 86 Last Page 82 of 2122