7210 Reputation

19 Badges

10 years, 200 days

MaplePrimes Activity

These are questions asked by nm

It will be great if  DEtools:-convertAlg  which is designed to find coefficients of a linear ode, not to expand the coefficients it finds.

This caused my patterns to fail, as after putting the coefficients in a certain form, and then calling DEtools:-convertAlg later on somewhere else in the program, the patterns no longer worked due to this unexpected expansion.

It will be better if DEtools:-convertAlg returns the coefficients it find as is and not expand them. I could not find an option to use for this. Here is an example.

ode:=b*(x+x^2)*diff(y(x),x$2)+x*(2*a - 1)*diff(y(x),x)+c*y(x)=0;

After the call the coefficients become


You might ask that one can easily "fix" this afterwords. Sure. I can use collect on x. But the point is that in general, it might not be clear what to collect on or what the changes that were made are.

In principle, it is better to keep the coefficients in same form as they were in the ode so that the ode do not change form.

Maple 2022.1 on windows.

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

5 6 7 8 9 10 11 Last Page 7 of 142