[go: up one dir, main page]

Items tagged with error

Feed App Center

I do not know if this is how it always been in Maple. But now I noticed when I set assertlevel to 2, in order to catch wrong assignment type in my code, the try/catch do not catch such an error.  

My question is: Has it always been like this in Maple? May be it was, I am just asking for confirmation. I seem to remember I was able to trap such error before.

Here is MWE

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1793 and is the same as the version installed in this computer, created 2024, August 25, 9:6 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

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

 

foo:=proc();
local C_sol::list;
   try
      C_sol := 1;
   catch:
      print("error detected in my code");
   end try;
end proc:

foo(); #unable to catch assignment error

Error, (in foo) assertion failed in assignment to C_sol, expected list, got 1

 

 

Download why_trap_do_not_catch_assignment_error.mw

Can solve give internal Maple error of division by zero to the caller?

Also when I run this using kernelopts('assertlevel'=1): or kernelopts('assertlevel'=2):, then not able to catch the internal error any more, which is division by zero using try/catch.

Only when kernelopts('assertlevel'=0).  can try/catch trap the error.

This means now I have to set kernelopts('assertlevel'=0) before calling solve to be able to trap the error and set it back to kernelopts('assertlevel'=2) after that, else the whole program halts.

But my main question is: can solve throw internal error of division by zero? I mean, is this expected sometimes to happen? I would have thought Maple should internally catch this and simply return no solution if can't solve it.

This equation is auto generated and the program calling solve on it to see if it can solve it.

Here is the worksheet

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1792 and is the same as the version installed in this computer, created 2024, August 22, 12:6 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

eq:=1 = 1/((exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X + exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0 + 2*Y + 2*y0)^2*Y*(exp(X*Y)^2*exp(X*y0)^2*exp(x0*Y)^2*exp(x0*y0)^2*X + exp(X*Y)^2*exp(X*y0)^2*exp(x0*Y)^2*exp(x0*y0)^2*x0 + 2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X*Y^2 + 4*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X*Y*y0 + 2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X*y0^2 + 2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y^2*x0 + 4*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y*x0*y0 + 2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0*y0^2 - X^2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0) - 2*exp(X*Y)*exp(X*y0)*x0*exp(x0*Y)*exp(x0*y0)*X - exp(X*Y)*exp(X*y0)*x0^2*exp(x0*Y)*exp(x0*y0) - 2)):

kernelopts('assertlevel'=2):
try
   solve(identity(eq,X),[x0, y0]);
catch:
   print(lastexception);
end try;

Error, (in unknown) assertion failed

kernelopts('assertlevel'=1):

try
   solve(identity(eq,X),[x0, y0]);
catch:
   print(lastexception);;
end try;

Error, (in unknown) assertion failed

kernelopts('assertlevel'=0):

try
   solve(identity(eq,X),[x0, y0]);
catch:
   print(lastexception);
end try;

unknown, "numeric exception: division by zero"

 


 

Download division_by_zero_solve_identity_august_23_2024.mw

Any idea why calling solve(eqs,unknowns) gives Error, (in is/internal) type does not exist when the unknowns are in a set, but the error goes away when the unknowns are in a list? Is this expected or is this a bug?


 

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1779 and is the same as the version installed in this computer, created 2024, July 25, 8:56 hours Pacific Time.`

restart;

eqs:={0 = ln(2)+ln(-a*sech(1/2*2^(1/2)*b)^2), 1 = -tanh(1/2*2^(1/2)*b)*a^(1/2)*2^(1/2)};
unknown:={a, b};

{0 = ln(2)+ln(-a*sech((1/2)*2^(1/2)*b)^2), 1 = -tanh((1/2)*2^(1/2)*b)*a^(1/2)*2^(1/2)}

{a, b}

solve(eqs,unknown)

Error, (in is/internal) type `a` does not exist

solve(eqs,unknown)

Error, (in is/internal) type `a` does not exist

restart;

eqs:=[0 = ln(2)+ln(-a*sech(1/2*2^(1/2)*b)^2), 1 = -tanh(1/2*2^(1/2)*b)*a^(1/2)*2^(1/2)];
unknown:={a, b};

[0 = ln(2)+ln(-a*sech((1/2)*2^(1/2)*b)^2), 1 = -tanh((1/2)*2^(1/2)*b)*a^(1/2)*2^(1/2)]

{a, b}

solve(eqs,unknown)

Error, (in is/internal) type `a` does not exist

restart;

eqs:=[0 = ln(2)+ln(-a*sech(1/2*2^(1/2)*b)^2), 1 = -tanh(1/2*2^(1/2)*b)*a^(1/2)*2^(1/2)];
unknown:=[a, b];

[0 = ln(2)+ln(-a*sech((1/2)*2^(1/2)*b)^2), 1 = -tanh((1/2)*2^(1/2)*b)*a^(1/2)*2^(1/2)]

[a, b]

solve(eqs,unknown)

[]

 


 

Download is_internal_error_from_solve_maple_2024_1.mw

Update

Reported to Maplesoft support.

 

Is it possible to use the Maple command timelimit(time, procedure(.......)) inside a loop of the type "for j                     do        procedure(.......)                   end do" without getting the error 'time expired" that forgets that value of j and  continue with the next value of j. How?

For example when I run a worksheet, if there is an error, maple simply prints the error and moves on to the next step. Is there a way to do that with loops.
The try and catch statements are a bit cumbersome and sometimes you have to predict the kind of error statements you may face.

fig([L1(color = blue), L2(color = blue), L3(color = green), C1(color = black), C2(color = black), C3(color = orange), C4(color = orange)]);
point(oo, [0, 0]);
                               oo

rotation(fig1, fig, oo, Pi/2, 'counterclockwise');
Error, (in geometry:-rotation) wrong type of arguments why thos error ? Thank you;
 

I am using some custom procedures which return error messages if something doesn´t work as planned and would need to make a distinction (when using try..catch) between these errors and all the other potential error messages Maple can return. Is there a way to do this efficiently - without having to list all of the error messages from my own procedures after catch?

I have my code in mla. Using try/catch, I am able to capture an error that happend deep in some call chain. But it is hard to know the exact location where this error happened.

I use StringTools:-FormatMessage( lastexception[2..-1] inside the catch clause to print the exception. But this only prints the message. It does not tell me exactly which line/function/module this happened.

Is there a way to display these information?  Using debugger and stoperror all did not help at all. It does not stop at the line where the error happened. not sure why. I tried it many times. may be I am not using it correctly?

Is it possible to display may be the trace of the calls inside the catch of the try? To know the actual statement that generated the error? Now each time I get an exception, I have to step into the debugger line by line until  I get to the place where the error was which is time consuming. Here is a MWE

 

restart;
A:=module()  
  local B:=module()
     export foo:=proc(n)
         1/n;
     end proc;
  end module;

  export main:=proc()
    try
       B:-foo(0);
    catch:
      print("error happened", StringTools:-FormatMessage( lastexception[2..-1] ));
    end try;
  end proc;

end module;

And now

    A:-main()

                "error happened", "numeric exception: division by zero"

I'd like to get more information than the above as I said. Line number/proc name/module name or stacktrace showing the calls made up to where the exception started (similar to output from where command in debugger).

The above was done in worksheet. My actual code in inside .mla build from lots of .mpl files.

Maple 2021.2 on windows

Apparently when raising an error exception, Maple stops further code.

Is there any possibility to just show a popup message, and then continue with the code after the message?

ErrorGoOn.mw

What is the reason that error accepts its arguments without being inside paranthesis? This is different from all other Maple functions I've seen. For example, both these below work the same

f := proc (x) 
     if x<0 then 
        error "invalid x: %1", x; 
     else 
        x^(1/2); 
     end if 
end proc:

And

g := proc (x) 
     if x<0 then 
        error("invalid x: %1", x); 
     else 
        x^(1/2)
     end if 
end proc:

One can't do for other Maple functions. For example sin x  gives an error. It must be sin(x)

Looked at help page for error and did not see something about this difference.

Hello everyone,

I am trying to represent a set of data using the errorplot command as follows

plotlims50 := ErrorPlot(xcoords = vectorl, sigmasl50, yerrors = [0.1e-1, 0.4e-1, 0.1e-1, 0.3e-1, 0.3e-1, 0.6e-1, 0.6e-1, 0.1e-1, 0.4e-1, 0.6e-1, 0.5e-1, 0.3e-1, 0.2e-1, 0.2e-1], color = "green")

I guess it's okey, but I would like to have that kind of small lines at the end of the bar and perpendicular to it (like in the image below). Is it possible?

Thank you so much in advance

Hello,
I am trying to write a program that will return a partial or complete list of points on an elliptic curve.
In order to do this using examples provided to me, the command "msqrt" was used, which would return FAIL if the conditions were not met.
However, as I am using Maple 2018, this was replcaed with "ModularSquareRoot" which returns an error message.
My question; Is there anyway to circumvent this error message, as it is really causing me a lot of headache. Thanks.

In a do loop with a try... catch statement I had placed an assignment to a vector element after catch: but before the line printing the lastexception. That the loop didn't perform as expected, but resulted in an error about ListTools:-FormatMessage wanting its first argument to be a string surprised me. Putting the assigment to the vector after the exception printing worked fine.
It seems that rtables are the exception (no pun intended) to the order being irrelevant.
 

restart;
V:=Vector():
for j from 1 to 5 do
  try
   V(j):=j/(j-1)
  catch:
   V(j):=17; # clears lastexception apparently
   printf(cat(StringTools:-FormatMessage(lastexception[ 2 .. -1 ] ),"\n"));
  end try
end do:
#####
restart;
V:=Vector():
for j from 1 to 5 do
  try
   V(j):=j/(j-1)
  catch:
   printf(cat(StringTools:-FormatMessage(lastexception[ 2 .. -1 ] ),"\n"));
   V(j):=17;
  end try
end do:

These simple lines confirm my observation:

restart;
lastexception;
5/0;
lastexception;
5/5;
lastexception;
x:=47;
lastexception;
table();
lastexception;
[1,2,3];
lastexception;
rtable();
lastexception; # Now cleared!


 

Can anyone tell me what is the command to calculate maximum absolute error in mapple.

Sorry I am just having difficulties understanding what this error means exactly, normally maple returns an error message stating the procedure that was being executed when the error was encountered, but in this situation it says (in unknown) which doesnt really make sense, i mean how can a procedure unknown to maple be being executed in the first place, or is this a procedure name itself?

1 2 Page 1 of 2