6928 Reputation

19 Badges

10 years, 74 days

MaplePrimes Activity

These are questions asked by nm

I have an expression and I want to select the part of the expression which has diff(y(x),x) in the expression.

Using select(has,expr,diff(y(x),x) works, except when the expression happend to be exactly diff(y(x),x) in this case select returns diff()

I understand why this happens. But I can not avoid this problem by say first checking if the expression has more than one operand, because nops(diff(y(x),x) is 2 and not one. Also 1+diff(y(x),x) has two operands. And I can not check if the expression is of type `+` or `*` before, because other types can have more than one operand also.

So now what I do is the folliwng: first check if the expression has diff(y(x),x). If so, convert the expression to D and now check if nops is more than one, and if so, only now call select.

This is becuase nops(D(y)(x)) is one, while nops(diff(y(x),x) is two.

Is there a better way to do this, in order to avoid calling select and getting diff() ? I suppose I could also just check if the expression is exactly diff(y(x),x) before even calling select or has and avoid all this?

Worksheet attached



`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

#the wrong way
if has(expr,diff(y(x),x)) then


#add extra check,  example 1
if has(expr,diff(y(x),x)) then
    if nops(convert(expr,D))>1 then
       print("expression is itself diff(y(x),x))");

"expression is itself diff(y(x),x))"

#add extra check, example 2
if has(expr,diff(y(x),x)) then
    if nops(convert(expr,D))>1 then
       print("expression is diff(y(x),x))");

"part_with_diff=", 3*(diff(y(x), x))


Download best_way_to_check.mw


expr:=c[2]*sin(sqrt(3)*x/2) + c[3]*cos(sqrt(3)*x/2);

How to change the second result above (with the tan) back the the original form it was in?

I tried all different convert and simplification commands, and non managed to get back the original form.


Maple 2022.1 on windows 10

I do not remember is this was asked before.

In other OOP languages such as Java, it allows one to name object variable name same as method name. I found this example on the net for java to illustrate

class Test {

  private boolean isVal;

  public boolean isVal() {
      return isVal;


In Maple, this is not allowed. So now I have to come up with new name for either the method or the variable that returns that hidden internal variable.

Here is an example

  option object;
  local is_valid::truefalse:=false;
  export is_valid::static:=proc(_self,$)::truefalse;
    return _self:-is_valid;
  end proc;
end module;

THis gives error

Error, (in A) exported variable `is_valid` cannot be multiply declared

It will be nice if Maple allows this. For now one has to rename either the variable or the method. Which is little annoying.

Is this something that could  be easily added to Maple in a future release?

I changed today my code to use DEtools:-odeadvisor(ode,y(x),[linear]); to check that the ode is linear or not before calling DEtools:-convertAlg 

The problem is that sometimes the advisor returns _linear on what is not linear ode (at least the way it is originally written). Here is an example

              (x+y(x))*diff(y(x),x) = 0;

From help page:


In the event that convertAlg cannot isolate for the proper list form (for instance, if the DE is not a linear ODE) then FAIL is returned.


So now I am worried  that using odeadvisor to check for linear ode is not the right method.

Is there a build-in method in Maple to check if an ode is linear or not? (I do have my own code to do this, but I thought it is better to use a buildin method, as it will be more robust).

Should DEtools:-odeadvisor(ode,y(x),[linear]) have returned _linear in this case?


`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

ode:=(x+y(x))*diff(y(x),x) = 0;
#check if linear ODE

(x+y(x))*(diff(y(x), x)) = 0






Download why_fail_sept_17_2022.mw

dAlmbert ode has the form


Also from Maple own help page, it agrees with Wikipedia and says:


Now, given this ode


Then clearly the above is not dAlmbert. Right? it is missing the x. But odeadvisor says it is:


What Am I missing here?


These are the rules I know about this ode. For y=x f(p)+ g(p). 

g(p) can be zero, yes, but in this case, f(p) has to be nonlinear in p for it to be dAlembert (else it will be either separable or linear.

I did not think f(p) can be zero and it remains dAlermber, even if g(p) remains nonlinear in p. So y=g(p) can not be dAlembert, even if g(p) is nonlinear.

May be Maple uses its own definition of dAlembert?. I do not know. This will be new definition to me. Is there a reference that mentions this case of y=g(p) classified as dAlembert for nonlinear g?

Maple 2022.1 on windows 10

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