nm

11353 Reputation

20 Badges

13 years, 14 days

MaplePrimes Activity


These are questions asked by nm

I am not able to even trap this Maple exception.

Any suggestions what to do? It is not a problem if it can't solve it, but I need to at least be able to  trap the exception in order to go to the next one, else the whole program now stops when it hits this.

I used try..catch but this exception just ignores this and escapes to top level. This is not the first time I've seen Maple exception escape the try/catch. I do not understand why some do that and some not. I

Is this another bug?

interface(version);

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

restart;

eq:=1 = -X*(-1/4*(-40*(X + x0)^(5/3) - 20/3*(X + x0)^(2/3)*Y - 20/3*(X + x0)^(2/3)*y0 - 32*A*(X + x0)^(1/3))/((X + x0)^(5/3)*(Y + y0)) + 5/12*(-15*(X + x0)^(8/3) - 4*(X + x0)^(5/3)*Y - 4*(X + x0)^(5/3)*y0 - 24*A*(X + x0)^(4/3) + 12*A^2)/((X + x0)^(8/3)*(Y + y0)))/(Y*(1/(Y + y0) + 1/4*(-15*(X + x0)^(8/3) - 4*(X + x0)^(5/3)*Y - 4*(X + x0)^(5/3)*y0 - 24*A*(X + x0)^(4/3) + 12*A^2)/((X + x0)^(5/3)*(Y + y0)^2)));

1 = -X*(-(1/4)*(-40*(X+x0)^(5/3)-(20/3)*(X+x0)^(2/3)*Y-(20/3)*(X+x0)^(2/3)*y0-32*A*(X+x0)^(1/3))/((X+x0)^(5/3)*(Y+y0))+(5/12)*(-15*(X+x0)^(8/3)-4*(X+x0)^(5/3)*Y-4*(X+x0)^(5/3)*y0-24*A*(X+x0)^(4/3)+12*A^2)/((X+x0)^(8/3)*(Y+y0)))/(Y*(1/(Y+y0)+(1/4)*(-15*(X+x0)^(8/3)-4*(X+x0)^(5/3)*Y-4*(X+x0)^(5/3)*y0-24*A*(X+x0)^(4/3)+12*A^2)/((X+x0)^(5/3)*(Y+y0)^2)))

try
   sol:=solve(identity(eq,X),[x0,y0]);
catch:
   print("trapped the error");
end try;

Error, (in anonymous procedure called from type/realcons) too many levels of recursion

 

 

Download how_to_trap.mw

Update 3 years later. FYI. This error still shows in Maple 2025. It will be nice if Maple returns no solution than an internal error that can not be trapped which means the whole program crashes.

restart;

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

Physics:-Version();

`The "Physics Updates" package is not available for the version of Maple under development`

restart;

eq:=1 = X*(2*cos(X)*cos(x0)-X*sin(X)*cos(x0)-2*sin(X)*sin(x0)-X*cos(X)*sin(x0)-x0*sin(X)*cos(x0)-x0*cos(X)*sin(x0))*(2*Y*ln(Y+y0)+Y+2*y0*ln(Y+y0)+y0)/Y/(X*cos(X)*cos(x0)-X*sin(X)*sin(x0)+x0*cos(X)*cos(x0)-x0*sin(X)*sin(x0)+sin(X)*cos(x0)+cos(X)*sin(x0))/(2*ln(Y+y0)+2*Y/(Y+y0)+1+2*y0/(Y+y0));

1 = X*(2*cos(X)*cos(x0)-X*sin(X)*cos(x0)-2*sin(X)*sin(x0)-X*cos(X)*sin(x0)-x0*sin(X)*cos(x0)-x0*cos(X)*sin(x0))*(2*Y*ln(Y+y0)+Y+2*y0*ln(Y+y0)+y0)/(Y*(X*cos(X)*cos(x0)-X*sin(X)*sin(x0)+x0*cos(X)*cos(x0)-x0*sin(X)*sin(x0)+sin(X)*cos(x0)+cos(X)*sin(x0))*(2*ln(Y+y0)+2*Y/(Y+y0)+1+2*y0/(Y+y0)))

solve(identity(eq,X),[x0, y0])

Error, (in signature) too many levels of recursion

normal(eq);

1 = (Y+y0)*(2*ln(Y+y0)+1)*(2*cos(X)*cos(x0)-X*sin(X)*cos(x0)-2*sin(X)*sin(x0)-X*cos(X)*sin(x0)-x0*sin(X)*cos(x0)-x0*cos(X)*sin(x0))*X/((2*ln(Y+y0)+3)*(X*cos(X)*cos(x0)-X*sin(X)*sin(x0)+x0*cos(X)*cos(x0)-x0*sin(X)*sin(x0)+sin(X)*cos(x0)+cos(X)*sin(x0))*Y)

solve(identity(%,X),[x0, y0])

Error, (in signature) too many levels of recursion

expand(eq);

`[Length of output exceeds limit of 10000]`

solve(identity(%,X),[x0, y0])

Error, (in signature) too many levels of recursion

 

 

Download internal_error_march_27_2025.mw

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.

restart;
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

L:=DEtools:-convertAlg(ode,y(x))

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


 

interface(version)

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

#the wrong way
expr:=diff(y(x),x):
if has(expr,diff(y(x),x)) then
   part_with_diff:=select(has,expr,diff(y(x),x));
fi;

diff()

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

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

#add extra check, example 2
expr:=1+3*diff(y(x),x):
if has(expr,diff(y(x),x)) then
    if nops(convert(expr,D))>1 then
       part_with_diff:=select(has,expr,diff(y(x),x));
       print("part_with_diff=",part_with_diff);
    else
       print("expression is diff(y(x),x))");
    fi;
fi;

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


 

Download best_way_to_check.mw

Given

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

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.

convert(expr,sincos);
simplify(expr,size);
#etc...

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

A:=module()
  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?

First 62 63 64 65 66 67 68 Last Page 64 of 199