nm

11353 Reputation

20 Badges

13 years, 12 days

MaplePrimes Activity


These are replies submitted by nm

@vv 

But this approach does not really work in practice. I have 10's of thousands of ode's with different dependent variables not just y. They could be z(t)  or w(t) and so on. It does not make sense to define such functions for each letter..

It would be better if Maple would read 2D directly from input files.

@vv 

Thanks for the workaround, but I prefer not to use eval for defining/setting initial/boundary conditions. It can cause problems. According to an experienced Maple programmer:

"The only form of derivative for initial and boundary conditions containing derivatives that's consistently supported by the documentation is D. If some component accepts another form, that's merely grace (to use Preben's word) or a bonus (to use Vv's word). So it's only at the highest level of evaluation---inside the mind of the programmer---that they could be considered equal."

From  what is the difference between D(y)(0)=C1 and eval(diff(y(t),t),t=0)=C1;

@Joe Riel 

Yes, I did try it. But it did not "work". By this I mean, the debugger did not STOP at the line where the exception was caused. WHich is what I assume should have happened. Here is a MWE

restart;

A:=module()
  local B:=module()
     export foo:=proc()
        print("in A:-B:-foo()");
     end proc;
 end module;
end module;

C:=module()
  export foo:=proc()
    local n:=1;
    DEBUG();
    #this now will cause an exception since A module above does not export B
    #when I stop here in debugger, then typed 
    #     stoperror(traperror["module"]);
    #but it did not actually stop on this line (or line after) when 
    #hitting the NEXT button. Is it supposed to have stopped here?
    A:-B:-foo(); 
    n:=n+1;
 end proc;
end module;

And now in the worksheet I typed

          C:-foo();

now the debugger came up. Then I typed in the debugger

         stoperror(traperror["module"]);

The clicked on the NEXT button in the debugger.   All what I got is end of the sessions and back to the worksheet

        C:-foo();
        Error, (in foo) module does not export `B`

If I understand what you meant, is that the debugger is supposed to STOP at the call where this exception happend so I can where it happend. right? if so, this is not what happens.

So this did not tell me really which line the problem was at.

Maple 2021.2 on windows.

@Joe Riel 

Thanks. But I do not know what the cause of the exception before it happened. The example I posted was just an exampleof 1/0.

The exception could be generated for many other reasons. In the case I am looking at , it is 

             Error, module does not export `%1`, name_of_module_here

I just did (in the debugger) 

stoperror("all")

also to try. This did not work. I ended up insid the top level catch: clause as before which only tells me the message. Same when I tried stoperror all

I want to know the exact location where this exception was generated.

I tried your suggestion of 

stoperror(traperror);

in the debugegr before I hit continue, but this now stops at many places in the Maple own code which I am not interested in and had to keep jumping over that.

So is there no way, from the catch: location, to print the stack showing where the exception was generated?  

As I said, I can find the location by stepping in the debugger, until I hit it, but this takes time. But I just found it and fixed it. Took 10 minutes to step line by line until I found the error in the name.

It would be nice if Maple had a way to view exceptions like with Ada   https://www.adacore.com/gems/gem-142-exceptions    but may be this is asking too much from a dynamic CAS langauge :)  

There are more example of printing exception stack trace at https://stackoverflow.com/questions/6822968/print-the-stack-trace-of-an-exception

you must have something wrong in your set up somewhere. It works OK for me on Maple 2021.

I can't imagine it would make a difference for int if you use lower case letter or upper case letter in any Maple version. 
 

interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;
y:=expand(sqrt(a^2-(x-a)^2));

(2*a*x-x^2)^(1/2)

f:=expand(simplify(sqrt(1+diff(y,x)^2)))

(a^2/(x*(2*a-x)))^(1/2)

int(f,x)+K

(-a^2/(x*(-2*a+x)))^(1/2)*x*(-2*a+x)*ln(-a+x+(-2*a*x+x^2)^(1/2))/(x*(-2*a+x))^(1/2)+K

y:=expand(sqrt(R^2-(x-R)^2))

(2*R*x-x^2)^(1/2)

f:=expand(simplify(sqrt(1+diff(y,x)^2)))

(R^2/(x*(2*R-x)))^(1/2)

int(f,x)+K

-(R^2/(x*(2*R-x)))^(1/2)*(2*R-x)*x*ln(-R+x+(-2*R*x+x^2)^(1/2))/(-x*(2*R-x))^(1/2)+K


There is slight difference in how the terms are written in second case due to typographical letter ordering sorting but they are mathematically the same. 

Download int_ok.mw

It will also help if you explain what do you mean when you say Wrong Integral  i.e. why it is wrong, and where it is wrong. 

@Joe Riel 

Thanks Joe. I am really looking forward for using your emacs interface once you have it updated. I spend a lot of time in the debugger and a better interface will make debugging much easier.

I use Maple on windows not linux but emacs can be used on windows also.

@Preben Alsholm 

OK, fair enough., Adding NULL fixed the error. But I still do not understand why.  Since in the map, the output of the proc f() is not used at all. 

           map(Z->f(Z),r);

so each time f() is called, the return list (which happened to be current value of L) is discarded by map. its current value remain the global variable L. Return value from f() is not used inside map.

So who is adding different length lists?  And where is that happing? map() itself has no idea that L is being used in first place. it just calls f().

@Kitonum 

THanks. I was trying permute for 20 minutes. But was typing something like combinat:-permute([1,-1],4); and this returns [].  I did not know the trick 

[1$n,-1$n]

if you are using []  for making nice math notation (subscripts), why not use __ instead? I think __ is better than using index for making subscripts. I myself use indexed variables for making a variable of type table() with numerical intger index. Not for making subscripts.

restart;
eq3__130:= Psi__fd = L__ffd * i__fd + L__f1d * i__1d -L__ad * i__d;

I do not know why maple puts 1.0 there for  the index as I do not use index for notation, I use __ instead.

@Joe Riel 

"Full disclosure, I also rarely use the builtin debugger, instead relying on an Emacs-based version with a better interface."

I use the builtin debugger but the interface us hard to use. I am not sure I understand what you mean by the above. Do you mean if one uses Maple in emacs, the debugger can still be used but the interface is no longer a line based interface as it is with the builtin version? 

Do you have screen shots of how the debugger interface looks like using emacs editor?  In this case I will switch to emacs just to use the debugger from it.  Will this work on windows or does one need to run Maple on Linux?  Is there a web site that explains how to set this up as that would be useful.

@Thomas Richard 

normal(w,expanded) does not always work as expected. Here is an example, where now only the simplify(evalc(w)) give me the desired output. 

Here is an example

w := 4*sqrt(3)*sqrt(2 + 30*I*sqrt(3))/(3*(-1 + sqrt(3)*I)*(sqrt(3)*I - 2*x - 1)) + 4*sqrt(3)*sqrt(2 - 30*I*sqrt(3))/(3*(1 + sqrt(3)*I)*(sqrt(3)*I + 2*x + 1));

(4/3)*3^(1/2)*(2+(30*I)*3^(1/2))^(1/2)/((-1+I*3^(1/2))*(I*3^(1/2)-2*x-1))+(4/3)*3^(1/2)*(2-(30*I)*3^(1/2))^(1/2)/((1+I*3^(1/2))*(I*3^(1/2)+2*x+1))

normal(w,expanded);

((3*I)*(2+(30*I)*3^(1/2))^(1/2)*x-(3*I)*(2-(30*I)*3^(1/2))^(1/2)*x+(3*I)*(2+(30*I)*3^(1/2))^(1/2)-(3*I)*(2-(30*I)*3^(1/2))^(1/2)+3^(1/2)*(2+(30*I)*3^(1/2))^(1/2)*x+3^(1/2)*(2-(30*I)*3^(1/2))^(1/2)*x-3^(1/2)*(2+(30*I)*3^(1/2))^(1/2)-3^(1/2)*(2-(30*I)*3^(1/2))^(1/2))/(6*x^2+6*x+6)

simplify(expand(numer(w))/expand(denom(w)));

(-(3*I)*x*3^(1/2)+I*x*(2+(30*I)*3^(1/2))^(1/2)+x-16)/(2*x^2+2*x+2)

simplify(evalc(w))

(-2*x-8)/(x^2+x+1)

simplify(w);

(8*x+32)/((I*3^(1/2)-2*x-1)*(I*3^(1/2)+2*x+1))

simplify(w,size);

(4/3)*3^(1/2)*(2+(30*I)*3^(1/2))^(1/2)/((-1+I*3^(1/2))*(I*3^(1/2)-2*x-1))+(4/3)*3^(1/2)*(2-(30*I)*3^(1/2))^(1/2)/((1+I*3^(1/2))*(I*3^(1/2)+2*x+1))

 


For comparison, I wanted to see how Mathematica will handle this. Simplify did not do it this time, but FullSimplify did it.

Download complex_2.mw

It is always tricky figuring the correct command to simplify something each time.

@vv 

If you look at the function step3 in the paper (starting at page 66) where this `@W`(var) is used, you will see there is no procedure `@W` anywhere to be seen. I did not see anywhere in the list a proc with name W.

That is why I asked. Could it be some built-in function that was defined in Maple 3?

@Carl Love 

thanks, that worked. I did not think of trying that, since it says one needs to use static on function objects. But I think it worked here since this function is special case, it overrieds the base class. Same for removing external. 

I would really have expected Maple to give this error, without the need to set 

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

@Carl Love 

FYI, I found a problem with your solution. When adding 

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

Now Maple gives an error 

Error, (in anonymous module) type `static` does not exist
I could not find a solution around this myself. I need to keep interface(warnlevel=4); and kernelopts('assertlevel'=2): and can't remove these a they help catch problems in the code. 

Without the ability to do extension and overriding behavior of base class, then there is no polymorphism. Without polymorphism there is no OO. So I do not know why Maplesoft calls this OOP in its documenation. Everything else except for polymorphism can be done just as easily using standard modules and structured programming.  

 

interface(version)

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1123. The version installed in this computer is 1122 created 2021, December 22, 16:3 hours Pacific Time, found in the directory C:\Users\me\maple\toolbox\2021\Physics Updates\lib\`

restart;

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

 animal:= module()
option object;
export
    data1,
    move::static:= proc(_self, $)
        print("In Animal class. moving ....")
    end proc
;
end module;
 
#create class/module which extends the above
dog:= module()
option object(animal);
    move::static:= proc(_self, $)
        print("In dog class. moving ....")
    end proc  
end module;

3

_m2321929286240

Error, (in anonymous module) type `static` does not exist

 

Download OOP_error_12_29_2021.mw

@Preben Alsholm 

That is a good example.

I will try to summarize things to make sure I understood it: in simplify(expr, assume=[...])  the expression is evaluated first, then simplify only now use the assumptions on the evaluated expression to simplify it.  But in  simplify(expr) assuming .... , simplifes sees the assumptions early on before evaluating the expression. This can effect the result of simplify.

I think what I want is the first version above. I have to go change my code and change all the  simplify(expr) assuming ....  to simplify(expr, assume=[...])  and run full tests again and hopefully this will not break anything.

If the expression does not need evaluating (as your example), now both give same output

restart;
simplify(sqrt(a^2), assume=[a<0]);
simplify(sqrt(a^2)) assuming a<0;

both give -a. 

First 33 34 35 36 37 38 39 Last Page 35 of 91