nm

8552 Reputation

19 Badges

12 years, 350 days

MaplePrimes Activity


These are questions asked by nm

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

restart;
ode := diff(y(x),x)/y(x)-(3*(4*x^2+y(x)^2+1))/(2*x*(4*x^2+y(x)^2-2-2*x))=0;
DEtools:-odeadvisor(ode);
sol:=dsolve(ode,y(x));

(diff(y(x), x))/y(x)-(3/2)*(4*x^2+y(x)^2+1)/(x*(4*x^2+y(x)^2-2-2*x)) = 0

[_rational]

Error, (in dsolve) invalid subscript selector

 

Download error_jan_27_2023.mw

I am a little not clear why Maple's odeadvisor gives [_2nd_order, _reducible, _mu_xy] as an ode type for a second order ode which is already exact as is.

When the ode is exact, then no integrating factor mu is needed (or rather mu=1). But Maple says the ode is "reducible" using an integrating factor mu(x,y)

restart;
ode:=x*diff(diff(y(x),x),x)+(y(x)-1)*diff(y(x),x)=0;
DEtools:-intfactor(ode);
DEtools:-odeadvisor(ode)

 

THis ode is Kamke's 6.78, it is alslo mentioned in this paper in table 1 at page 18

I am just little confused, about the terminology. I thought reducible means the ode reguire an integrating factor of the form mu(x,y) or my(x,y') or mu(y,y') when it is not exact in order to make it to an exact ode so it can be now solved.

Why would odeavisor then says an ode which is already exact is also reducible using mu(x,y)?

Maple 2022.2 on windows 10. I found another serious problem with timelimit. When changing the timelimit value, solve hangs.

i.e. timelimit do not timeout.  But that is not all. Unable to terminate the process running the worksheet. Clicking on the little ! circle at the top does nothing.  But that is not all. Killing the server.exe from the task manager, now I am not even able to close the worksheet. Maple hangs on closing the worksheet.

This code below on  my PC produces this. I used 60 seconds to make it hang. When using 10 seconds it does not hang. You might have to change these values depending on how fast/slow your PC is. If it does not hang for you using 60, you might to try 100 and so on.

Why does it hang so bad? This really makes using Maple for development not practical if one can't even put a timeout on an operation like this. What is a user to do?  Not use solve? reduce the timelimit to avoid maple lockin? To what value? If I reduce all timelimits to 5 seconds, this will cause problems as I could lose solutions that will show up with more time.

Anyone else can produce this? Make sure to save all your work before because you might not be able to close the worksheet after this.  I use worksheet mode only.
 

interface(version);

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):

eq:=1/24*ln(9*u + 2) + 1/8*ln(u) - 1/24*ln(3*sqrt(4*u + 1) + 1) - 1/8*ln(sqrt(4*u + 1) - 1) + 1/24*ln(3*sqrt(4*u + 1) - 1) + 1/8*ln(sqrt(4*u + 1) + 1) - 1/2*ln(x) - c[1] = 0;

try
   the_sol := timelimit(60,[solve(eq,u)]);
   print("finished before timeout");
  catch:
    print("Timed out OK");
end try;

 


 

Download solve_hangs_different_timing_dec_23_2022.mw

I want to make proc that returns expression sequence of two numbers, say. A,B

This will be the normal return, but if the proc encounters an error, it should return FAIL. But this is not possible, because if I type A,B:=foo(0) and foo() happenes to return FAIL then Maple will complain

Error, mismatched multiple assignment of 2 variables on the left side and 1 value on the right side

The three workarounds I see are these

Method 1

I could wrap foo() with try/catch and have foo throw an exception when it encouters an error instead of returning FAIL, but I do not like this. This will look like

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
foo:=proc(n::integer)::integer,integer;
  if n=0 then
     error ("encountered error");
  else
     return 1,2;
  fi;
end proc;

And now the caller will do

try
   A,B:=foo(0);
catch:
   print("encountered error");
end try;

method 2

Another option is to have foo() return ONE value back. In the case of an error it will be FAIL, and in the case of normal behavior, it will be a LIST of the two items, which then I have to extract.  Like this

interface(warnlevel=4);
kernelopts('assertlevel'=2):
foo:=proc(n::integer)::Or(list(integer),identical(FAIL));
      if n=0 then
         return FAIL;
      else
         return [1,2];
      fi;
end proc;

And now the caller will do this

L:=foo(1);
if L<>FAIL then
   A:=L[1];
   B:=L[2];
else
   print("failed call");
fi;

But this is not as easy as just calling foo() as   A,B:=foo() but I can't do this due to the mismatch problem.

Another method, commonly used in C programming is to have the function return status an additional output and this will indicate if the call was success or not. so the caller has to remember to always check for this before using the returned values. These are handled by errno, perror(), strerror(). But for now, lets make the function return the status.

So caller will first check if status is success first and if so, then it will read the actual returned values that follow it. Like this (status is true/false)

method 3

interface(warnlevel=4);
kernelopts('assertlevel'=2):
foo:=proc(n::integer)::truefalse,integer,integer;
  if n=0 then
     return false,0,0;
  else
     return true,1,2;
  fi;
end proc;

And the caller will do

status,A,B:=foo(1);
if status then
   print("call was success, A and B are ",A,B);
else
   print("call failed");
fi;

So the return values will always have status as first argument that the caller has to check before reading the rest of returned values.

From the above three options which you think is best?

Anyone can suggest alternatives to the above methods?

Encountered new exception using odetest which can't be cought. Is this new one? I do not have earlier version of Maple than 2022.2 to check. On windows 10.

btw, I could not update to latest Physics now, may be server problem.  Attached worksheet

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

Physics:-Version(latest)

Error, (in Physics:-Version) unable to determine the Physics Updates version, could you please report the problem to support@maplesoft.com

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1351. The version installed in this computer is 1348 created 2022, November 14, 15:59 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2022\Physics Updates\lib\`

restart;

 

sol:=y(x) = -LambertW(x/sin(x)*exp(c[1]/sin(x)))+c[1]/sin(x);
ode:=exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*diff(y(x),x) = 0;
odetest(sol,ode)

y(x) = -LambertW(x*exp(c[1]/sin(x))/sin(x))+c[1]/sin(x)

exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*(diff(y(x), x)) = 0

Error, (in tools/map) too many levels of recursion

try
sol:=y(x) = -LambertW(x/sin(x)*exp(c[1]/sin(x)))+c[1]/sin(x);
ode:=exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*diff(y(x),x) = 0;
odetest(sol,ode);
catch:
   print("error in odetest");
end try;

y(x) = -LambertW(x*exp(c[1]/sin(x))/sin(x))+c[1]/sin(x)

exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*(diff(y(x), x)) = 0

Error, (in tools/map) too many levels of recursion

 

Download problem_odetest_nov_20_2022.mw

I do not know what to do now, since if I can't catch the exception, the program can't run anymore and just stops.

First 21 22 23 24 25 26 27 Last Page 23 of 164