Maple Questions and Posts

These are Posts and Questions associated with the product, Maple


I would like to enable/disable the Explore(plot(...), parameters=[...]) command according to some boolean value.
First idea (note that ending the previous command by : instead of ; doesn't prevent a figure to be displayed) was to encapsulated this Explore command within a conditional structure:
if T then Explore(...) end if.

But I prefered trying to define my own command by doing something like this:

EXPLORE := proc(TF::boolean)
  if TF then 
  end if:
end proc:

with a call made this way:
EXPLORE(true, 'plot(a*x, x=0..1)', 'parameters=[a=-1.0 .. 1.0]');
wich ended with this error
Error, (in Explore) No parameters to explore

I also tried this without any more success:
EXPLORE := proc(TF::boolean)
  if TF then 
    Explore(_passed[1], parameters=_passed[2])
  end if:
end proc:

with a call made this way:
EXPLORE(true, 'plot(a*x, x=0..1)', [a=-1.0 .. 1.0]);
I get no more error but this warning and an inactive Explore
Warning, expecting only range variable x in expression a*x to be plotted but found name a


Can you help me to fix this?

Thanks in advance



ddesys := {diff(x(t), t, t) + 2/25*diff(x(t), t) + 4*x(t) = 1/25*diff(x(t), t, t)*piecewise(t - 6/7 < 0, cos(t - 6/7), x(t - 6/7)) + 2/3*diff(x(t), t)*piecewise(t - 6/7 < 0, cos(t - 6/7), x(t - 6/7)) + 5/2*piecewise(t - 6/7 < 0, cos(t - 6/7), x(t - 6/7)), h(t) = diff(x(t), t, t), x(0) = cos(0), z(t) = diff(x(t), t), D(x)(0) = -sin(0)}

tdsn := dsolve(ddesys, numeric):

plots[odeplot](tdsn, [[t, x(t), color = red]], 0 .. 20, labels = [t, ""]);

I wish to make a simulation of a solution of  Neutral Delayed Differential  Equation (second order) whose initial condition is the history function cos(t) for t <0.
unfortunately Maple considers the history function as a constant and not a function, the simulation I tried to do by Maple is therefore not good.
Could somebody help me please ?




pde := diff(w(x, t), x $ 4) + diff(w(x, t), t $ 2)/c^2 = 0;

diff(diff(diff(diff(w(x, t), x), x), x), x)+(diff(diff(w(x, t), t), t))/c^2 = 0


test1 := w(x, t) = W(x)*cos(omega*t); pde1 := expand((eval(pde, test1))/cos(omega*t))

w(x, t) = W(x)*cos(omega*t)


diff(diff(diff(diff(W(x), x), x), x), x)-W(x)*omega^2/c^2 = 0


ode := algsubs(omega^2/c^2 = alpha^4, pde1); sol := dsolve(ode); sol := convert(sol, trig)

-W(x)*alpha^4+diff(diff(diff(diff(W(x), x), x), x), x) = 0


W(x) = _C1*exp(-alpha*x)+_C2*exp(alpha*x)+_C3*sin(alpha*x)+_C4*cos(alpha*x)


W(x) = _C1*(cosh(alpha*x)-sinh(alpha*x))+_C2*(cosh(alpha*x)+sinh(alpha*x))+_C3*sin(alpha*x)+_C4*cos(alpha*x)


L_collection := [indets(sol, specfunc({cos, cosh, sin, sinh}))[]]

[cos(alpha*x), cosh(alpha*x), sin(alpha*x), sinh(alpha*x)]



temp := collect(sol, [sinh, cosh, sin, cos])

W(x) = (-_C1+_C2)*sinh(alpha*x)+(_C1+_C2)*cosh(alpha*x)+_C3*sin(alpha*x)+_C4*cos(alpha*x)


CL := [coeffs(rhs(temp), L_collection)]NULL

[-_C1+_C2, _C1+_C2, _C3, _C4]


R:=[seq(cat(_D,i)=CL[i], i=1..nops(CL))]

[_D1 = -_C1+_C2, _D2 = _C1+_C2, _D3 = _C3, _D4 = _C4]


MX:= subs((rhs=lhs)~(R), temp);

W(x) = _D1*sinh(alpha*x)+_D2*cosh(alpha*x)+_D3*sin(alpha*x)+_D4*cos(alpha*x)


boundary_condition_1 := simplify(rhs(eval(diff(MX, `$`(x, 1)), x = 0))/alpha = 0)

_D1+_D3 = 0


boundary_condition_2 := simplify(rhs(eval(MX, x = 0)) = 0)

_D2+_D4 = 0


boundary_condition_3 := simplify(rhs(eval(diff(MX, `$`(x, 1)), x = L))/alpha = 0)

cosh(alpha*L)*_D1+sinh(alpha*L)*_D2+cos(alpha*L)*_D3-sin(alpha*L)*_D4 = 0


boundary_condition_4 := simplify(rhs(eval(MX, x = L)) = 0)

_D1*sinh(alpha*L)+_D2*cosh(alpha*L)+_D3*sin(alpha*L)+_D4*cos(alpha*L) = 0


boundary_condition_solve := solve([boundary_condition_1, boundary_condition_2, boundary_condition_3, boundary_condition_4]); MX := eval(MX, boundary_condition_solve)

Warning, solutions may have been lost


{L = L, _D1 = -_D3, _D2 = -_D4, _D3 = _D3, _D4 = _D4, alpha = 0}, {L = 0, _D1 = -_D3, _D2 = -_D4, _D3 = _D3, _D4 = _D4, alpha = alpha}, {L = L, _D1 = 0, _D2 = 0, _D3 = 0, _D4 = 0, alpha = alpha}


Error, invalid input: eval received ({L = L, _D1 = -_D3, _D2 = -_D4, _D3 = _D3, _D4 = _D4, alpha = 0}, {L = 0, _D1 = -_D3, _D2 = -_D4, _D3 = _D3, _D4 = _D4, alpha = alpha}, {L = L, _D1 = 0, _D2 = 0, _D3 = 0, _D4 = 0, alpha = alpha}), which is not valid for its 2nd argument, eqns





I have tried to solve these 4 equations to get the characteristic equation and finally the solution of the PDE.  But it shows some error. Can you please help with this issue?

How to draw an ellipse in a rectangle ? Thank you.


I tried to solve an inequality involving factorials using solve, but I failed. The code is 


n should be 7.

Maple returns me "Warning, solutions may have been lost" message. 

How can I solve an inequality like this using solve?

I worked around this with a for loop testing the value of the expression for every increasing value of n against the criteria. Is there a "magical" keyword that will help with solve? 



sqrt(4) gives 2 in CAS systems, since the principal root is returned by default. 

Is there an option to have Maple return all roots? Which in this case 2,-2?

I'll explain the context why I need this.

When I solve an ODE, I get a solution that I need to solve for constant of integration C from initial conditions. For an example assume the ODE becomes, after replacing initial condition the following  eq:=4^(1/2) = -2+_C1;

So now when solving for _C1  in maple and then calling simplify, gives one solution which _C1=4 (case root=2) which when replaced back into the general solution gives the particular solution.

But this means the second solution is lost, which is when _C1=0  (case root=-2) which could have been obtained from the non-principal root of 4^(1/2)

eq:=4^(1/2) = -2+_C;


And I would like to get {4,0} instead.

In practice, this becomes important.

Here is an actual ODE, which should have 2 solutions. Mathematica gives both solutions, and Maple gives one solution.  This is due to the above.


In Mathematica


The second solution above came from when constant of integration is zero. The first solution is the one Maple  gave (when expanded).

When I worked the solution by hand, I tracked this to issue with sqrt(4) giving 2 and not +2,-2 when doing solve() to solve for C at the end.

I could ofcourse leave C=sqrt(4)  and not call simplify  on it  and that works.

But I thought to ask here to see if there is some option in Maple, so that when it sees (n)^m to return all m roots when calling solve() and not just the principal one. Even for m=2. 

I looked at root and tried allsolutions=true but they did not help. Looked at solve/details and did not spot something. I tried only few of the options there, as there are so many.

Any suggestions what to try?


I'm searching for the codes in maple to calculate the Lie bracket and adjoint actions on the infinitesimal vectors. 

For eg. if I'm having my vector V3 and V4 as

I am trying to use this command

plot({0, 2*x^2, 2*x^2 - 2*x^3 + 8/3*x^4 - 4*x^5}, x = -10 .. 10, color = ["DarkGreen", "CornflowerBlue", "Burgundy"])

However, only the last function is showing up. 0 and 2x^2 is not showing up. I can't change the axes sizes because then the last function disappears.

I would like to plot results that combine numerical solutions from odes with polynomials (from a collocation procedure). Here is the part of the worksheet:

What is the best way to plot the approximate solutions here? 


Suppose that S={p1, p2, p3, p4},  where

              p1(x)=  71+73x−153x2−259x3−108x4+245x5,

              p2(x)=  37+189x+287x2−167x3+279x4−51x5,

              p3(x)=  -199−200x−62x2+59x3+262x4−70x5,

              p4(x)= 48+295x+18x2+235x3+209x4+279x5,  and

                p(x)= 6143+20711x+8974x2−30368x3+18964x4+17937x5.


To avoid typing errors, you can copy and past the following sequences to your Maple worksheet.




The polynomial p  is a linear combination of S  written in the form


αp1+βp2+γp3+δp4 .


Find a possible set of values for α, β, γ, δ.  Enter the values of α, β, γ, δ  as a sequence in the box below






Suppose that S={u1,u2,u3,u4,u5,u6}⊂ℝ5  where

u1=  < 

u2 = <-65, -11, -47, 18, -15>

u3 = <-240, 90, -265, 495, -175:>

u4= <-53, 70, 84, -80, 61>

u5= <9, 0, 46, -55, -37>

u6 =< 176, -280, -520, 540, -96>

Find a possible set of values for λ1, λ2, λ3, λ4, λ5, λ6, not all zero, such that  


λ1u1+λ2u2+λ3u3+λ4u4+λ5u5+λ6u6=0 .


Enter the values of  λ1, λ2, λ3, λ4, λ5, λ6  as a sequence in the box below


[λ1, λ2, λ3, λ4, λ5, λ6]= 


Hint: There are infinitely many solutions for λ1, λ2, λ3, λ4, λ5, λ6 .   The solution given by Maple will be in terms of parameters. To get one possible set of values, not all zero, choose some nice values for the parameters.



Dear All.

I hope we are all staying safe.

Please I want to solve Sine Gordon Equation using a numerical method I constructed (non-classical), I need to compare the result of the method with the exact solution to generate the errors. However, since the exact solution has two variables, x, and t, I really don't know how to accommodate the two in my coding.

Can someone be of help in this regard?

Thank you and kind regards






How can I use assmptions in partial differential equations?

For example consider the following differential equation

sol:=pdsolve(pde,build) assuming alpha=0

This gives me the same solution if alpha!=0

I also tried this


I again got the same result as if alpha!=0. Except this time there was a tilde on the right side of alpha (to my knowledge that means there are assumptions on alpha)

How do you apply assumptions in PDEs? 



Hi I was wondering if this is allowed and possible, because of the convienience of being able to call it up with the ?[command name] command, it would be an ideal scenario to write extensive notes for procedures and commands I write myself or written by others that are not part of the original maple install, I forget why and how to use alot of the things i write and this would be convienient for me to have quick access to, also to share with others on here or on stack exchange when maple has a stack exchange community.

How find one curve fitting exponential  equation (or any other curve fitting) for the points:

X := [-0.012, -0.010, -0.004, -0.002, -0.001, -0.0001, 0.0001, 0.001, 0.002, 0.004, 0.010, 0.012];
Y := [-0.695, -0.7, -0.74, -0.825, -0.95, -1.0, 1.0, 0.95, 0.825, 0.74, 0.7, 0.695];

I tried, but it wasn't. Look:

X := [-0.012, -0.010, -0.004, -0.002, -0.001, -0.0001, 0.0001, 0.001, 0.002, 0.004, 0.010, 0.012];
Y := [-0.695, -0.7, -0.74, -0.825, -0.95, -1.0, 1.0, 0.95, 0.825, 0.74, 0.7, 0.695];

f := c + exp(-b*x);
                       f := c + exp(-b x)

Statistics*[NonlinearFit](f, X, Y, x);

Statistics [NonlinearFit(c + exp(-b x), [-0.012, -0.010, -0.004,  -0.002, -0.001, -0.0001, 0.0001, 0.001, 0.002, 0.004, 0.010, 

  0.012], [-0.695, -0.7, -0.74, -0.825, -0.95, -1.0, 1.0, 0.95, 0.825, 0.74, 0.7, 0.695], x)]

The Maple not find the curve.

I should get a curve like that (exemple):


4 5 6 7 8 9 10 Last Page 6 of 1695