Maple 2021 Questions and Posts

These are Posts and Questions associated with the product, Maple 2021

What/Whare are the maple initialization files.

I have a problem with libname.

According to maple help, I should create/modify ~/.mapleinit.

> cat ~/.mapleinit

libname := "/usr/local/Maple2021/lib","/home/tomdean/maple/toolbox/maplev/lib","/home/tomdean/maple/toolbox/Syrup/lib";

But, when I start maple (in emacs), libname is only the first part, "/usr/local/Maple2021/lib",

I installed the cloud version of Syrup with xmaple, by clicking the cloud icon, etc. It is loaded with xmaple and cmaple. But, not in maple running in emacs.

with(Syrup);
(**) Error, invalid input: with expects its 1st argument, pname, to be of type
{module, package}, but received Syrup
(**) 

Tom Dean

I am attempting to use maplev mode for emacs. Ubuntu 20.04.3, Emacs 26.3, maplev-mode from git, release-2.36-59-g142c03. maple 2021.

I copied mload from an older computer and added a line to define maple, after the original maple definition line.

MAPLE=${MAPLE:-maple} # Maple script
MAPLE=/usr/local/Maple2021/bin/maple  <=== added

I compiled and installed maplev-mode. I had to touch doc/version.texi because the file did not exist. But, otherwise, I saw no errors.

I added lines to my emacs init.el as per the README.md.

maplev-mode seems to load when I edit a .mpl file.

However, mint is not defined.  Where should I change to define the location of mint?

/usr/local/Maple2021/bin/mint

Tom Dean

In this example, i have a top module A. Inside it, I have module named my_RECORD (which happened to be option object) that I want to return back to caller when they call a proc.

Maple allows me to declare the proc to return my_RECORD. No problem., But when making a local variable inside the proc and using o::my_RECORD it complains  that my_RECORD does not exist. 

The solution is to change o::my_RECORD to o::A:-my_RECORD

My question why it did not complain the same way on the return value on the proc?   for me, they are both semantically the same. One says the proc returns this type, and the other says the local variable is this type. So why had to do A:-my_RECORD on one but not the other? 

Here is an example. Maple 2021.2 on windows 10.

restart;

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

3

A:=module()
 #this is the RECORD to return
  local module my_RECORD()
   option object;
   export data::string:="";
  end module;
   
  export do_analysis:=proc()::my_RECORD;   
    local o::my_RECORD; #error here. But this is the same above line above?    
    o:=Object(my_RECORD);
    o:-data:="test";
    return o;        
  end proc;
end module;

_m2642451182336

A:-do_analysis()

Error, (in do_analysis) type `my_RECORD` does not exist

#FIXED BELOW
restart;

A:=module()
    #this is the RECORD to return
    local module my_RECORD()
        option object;
        export data::string:="";
    end module;
   
    export do_analysis:=proc()::my_RECORD;
          local o::A:-my_RECORD;    
          o:=Object(my_RECORD);
          o:-data:="test";
          return o;        
    end proc;
end module;

_m2642339719872

A:-do_analysis()

module my_RECORD () export data::string; option object; end module

 

Download A_no_lib.mw

Hi, I am trying to enter into the Mini-Course Computer Algebra for Physicists from the help, but instead of going to the page I get the help page of Physics[FeynmanIntegral]. Can anyone confirm that this happens to them on Maple 2021.2?

Kevin

Correction

Please ignore this question. dsolve does hang, but I had typo in the timelimit command itself when I wrote the test. Fixing this, now it timesout OK.

Maybe someone can look why dsolve hangs on this ode. But since timelimit does work, there is a workaround.

Original question

I was checking Maple's dsolve on this textbook problem

The book gives the answer in the back as

When using Maple's dsolve, I found it hangs. The stange thing, is that adding timelimit() also hangs. I can understand dsolve() hanging sometimes. But what I do not understand is why with timelimit it also hangs?

I've waited 20 minutes and then gave up. As you see, the timelimit is 20 seconds. May be if I wait 2 hrs or 20 hrs or 20 days, it will finally timeout. I do not know but can't wait that long.

Do others see same problem on this ode? Does it hang for you? How about on the mac or Linux?

During this time, I see mserver.exe running at very high CPU. I restarted Maple few times, but this did not help.

Maple 2021.2 on windows 10. May be one day Maplesoft will fix timelimit so it works as expected. 

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 1122 and is the same as the version installed in this computer, created 2021, December 22, 16:3 hours Pacific Time.`

restart;

ode:=x*diff(y(x),x)=y(x)*cos(ln(y(x)/x));
try
   timeout(20,dsolve(ode));
catch:   
   print("timedout");       
end try;   
print("OK");

x*(diff(y(x), x)) = y(x)*cos(ln(y(x)/x))

 

Download test_ode_hang.mw

on DLMF page, they show this transformation on independent variable for second order ode

https://dlmf.nist.gov/1.13#Px7

About half way down the page, under Elimination of First Derivative by Change of Independent Variable section.

I tried to verify it using Maple dchange. But the problem it looks like dchange wants the old variable to be on the left side (z in this example) and the new variable (eta in this example) to be on the right side in the transformation. But on the above web page, it is the other way around.

Here are my attempts

restart;
ode:=diff(w(z),z$2)+f(z)*diff(w(z),z)+g(z)*w(z)=0;

tranformation:=eta=int(exp(-int(f(z),z)),z);

PDEtools:-dchange({tranformation},ode,known={z},unknown={eta});
PDEtools:-dchange({tranformation},ode,{eta},known={z});
PDEtools:-dchange({tranformation},ode,{eta});

All give errors

Error, (in dchange/info) missing a list with the new variables
Error, (in dchange/info) the new variables are not contained in the rhs of the direct transformation equations
Error, (in dchange/info) the new variables are not contained in the rhs of the direct transformation equations

The problem it does not seem possible to invert the transformation shown on the webpage, so that the old variable z show on the left side and the new variable (eta) on the right side.  

Why is this restriction on dchange  Since one tells it which is the new variable and which is the old variable? May be I am not using dchange correctly in this example.

Any suggestion for a workaround to use dchange to verify the above result?

Here is my hand derivation (pdf file attached also)

Can the above be done using dchange?

Maple 2021.2 on windows 10

sol.pdf

Has somebody experienced something like that before?

I was searching for a bug in a sheet, and was absolute unable to find out why some results in a sheet were different from another sheet.

Found out that it actually was a pure graphics problem. With normal zoom (100%) the minus signum is not visible.

Blowing up the zoom to 125% shows the signum again.

I would like to open a specially formatted document from start/new document. I set  up one with a fixed width table to make it easy to print to A4. I find the very useful for taking notes.

Currently I just save it as  a usual document. The attached shows the basic setup I use. Contents arn't too relivant.

restart

``

 

 

 

"R(m2,m3,m4,...)&equiv;((2 m2+3 m3+4 m4+...)!)/((1+m2+2 m3+3 m4+...)!m2!m3!m4!...)"

 

 

  

Xterm := factorial(2*m+3*n+4*p+5*q)*c[2]^m*c[3]^n*c[4]^p*c[5]^q/(factorial(1+m+2*n+3*p+4*q)*factorial(m)*factorial(n)*factorial(p)*factorial(q))

factorial(2*m+3*n+4*p+5*q)*c[2]^m*c[3]^n*c[4]^p*c[5]^q/(factorial(1+m+2*n+3*p+4*q)*factorial(m)*factorial(n)*factorial(p)*factorial(q))

(1)

k := 5

5

(2)

x := add(add(add(add(Xterm, q = 0 .. 4*k), p = 0 .. 3*k), n = 0 .. 2*k), m = 0 .. k)

nops(x)

22176

(3)

NULL

nops(TestPoly)

1

(4)

ldegree(TestPoly)

1

(5)

NULL

NULL

NULL
NULL

mtaylor(TestPoly, [c[2], c[3], c[4], c[5]], k+2)

TestPoly

(6)

C1 := 1; C2 := -2; C3 := 3; C4 := -4; C5 := 5

5

(7)

Poly1 := expand((y+C1)*(y+C2)*(y+C3)*(y+C4)*(y+C5))

y^5+3*y^4-23*y^3-51*y^2+94*y+120

(8)

NULL

Poly1 := Poly1/coeff(Poly1, y, 0)

(1/120)*y^5+(1/40)*y^4-(23/120)*y^3-(17/40)*y^2+(47/60)*y+1

(9)

NULL

Poly1 := expand((y+C1)*(y+C2)*(y+C3)*(y+C4)*(y+C5))

y^5+3*y^4-23*y^3-51*y^2+94*y+120

(10)

NULL

Poly1 := Poly1/coeff(Poly1, y, 0)

(1/120)*y^5+(1/40)*y^4-(23/120)*y^3-(17/40)*y^2+(47/60)*y+1

(11)

fsolve(Poly1, y)

-5., -3., -1., 2., 4.

(12)

coeff(Poly1, y, 1)

47/60

(13)

Poly2 := algsubs(y = -z/coeff(Poly1, y, 1), Poly1)

-(6480000/229345007)*z^5+(324000/4879681)*z^4+(41400/103823)*z^3-(1530/2209)*z^2-z+1

(14)

"(->)"

-0.28254e-1*z^5+0.66398e-1*z^4+.39876*z^3-.69262*z^2-1.*z+1.

(15)

"(->)"

 

solve(Poly2, z)

-47/30, -47/15, 47/12, 47/20, 47/60

(16)

-%/coeff(Poly1, y, 1)

2, 4, -5, -3, -1

(17)

NULL

 

 

``

``

NULL

Download A4_format.mw

I can't move files in the navigator window anymore in Maple 2021.2.

Anyone else with the same problems?

sometimes complicated equation is generated and attempt to solve it fail, which is OK. But there is a case, where Maple generates an internal error from solve(). The problem is that it is not possible to even capture this error using try...catch... end try so the whole program crashes.

Is there a way to trap such errors, so at least it can bypass it without solving it but without terminating the whole program? 

According to help it says

The try statement provides a mechanism for executing statements in a controlled environment, where errors will not just cause the execution to halt with no warning.

Well. The above is not really true.

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 1115 and is the same as the version installed in this computer, created 2021, December 15, 10:0 hours Pacific Time.`

restart;

eq:=-t^m*y+1/12*(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2)+1/12*6^(1/2)*((-(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2)*(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y*(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2)+72*(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3)/(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2))^(1/2) = t^(m-1)*(-y+1/12*(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2)+1/12*6^(1/2)*((-(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2)*(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y*(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2)+72*(108+12*(6144*y^3+81)^(1/2))^(1/3))/(108+12*(6144*y^3+81)^(1/2))^(1/3)/(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2))^(1/2)):

sol:=solve(eq,m)  assuming t>0;

Error, (in PolynomialSystemSolvers:-PseudoResultant) too many levels of recursion

try
    sol:=solve(eq,m)  assuming t>0;
catch:
    print("Cought error");
end try;

Error, (in PolynomialSystemSolvers:-PseudoResultant) too many levels of recursion

 

Download dec_16_2021.mw

Other than saving few bytes of memory, why would one use ::static for methods of Object?

I found that if I use ::static, then I have to add prefix _self:- each time an object data member is referenced anywhere, making the code very hard to read.

Imagine having to write  _self:-x + 3* _self:-x^2 + 2* _self:-y^3 and so on all the time, instead of just x+3*x^2+2*y^3. (where it is assumed here that x,y happened to be object private data members and not local variables for a proc inside the module).

But then I found if I remove  ::static now _self:- no longer needed and can still get the benefit of using the object and the code works as before, but the code is now much more readable. 

I know that by not using static, then a copy of each method is made for each new object.

I am OK with that. As I do not use that many objects any way (few at a time before GC cleans the ones I used).

But the benefit of much more readable code far outweights the little extra memory needed, and memory is cheap these days anyway. I got lots of RAM. An extra few MB's is not a big deal.

What Am I missing here? Why does all the Maple help and documenation say that one should use static for object methods then? But do not mention that by not using static:: then the code will become more readable since _self:- is not needed to be appeneded to each variable or method name.

Here is an example below to compare. 

First example uses ::static methods, and the second does not.

One can see the difference The code is more clear in the second.   Is there something else I am overlooking by not using ::static . I am still learning OOP in Maple, and could be overlooking something else. I definitly do not want to code using _self:-variable_name all the time if I have to use OOP in Maple as it makes the code hard to read. 

Notice that in both examples, and for the exported methods, I used _self as first argument. This is OK. This is meant to allow client of the object to call it using object:-method() syntax which is what I prefer instead of method(object,....). syntax.

I am talking about the execssive use of _self internal to the module/object code when having to use ::static. methods.

restart;

person_class_STATIC:=module()
   option object;
   local age:=5;   

   export set_age::static:=proc(_self,age,$)      
     _self:-age:=age:
   end proc:      

   export update_age::static:=proc(_self,age,$)      
      do_the_update(_self)
   end proc:      

   local do_the_update::static:=proc(_self,$)
      _self:-age:=_self:-age+1;
      _self:-age:=sqrt(_self:-age^2+3);
   end proc;

   export get_age::static:=proc(_self,$)      
     return _self:-age;
   end proc:      

end module:

o:=Object(person_class_STATIC);
o:-set_age(100);
o:-get_age();
o:-update_age();

o2:=Object(person_class_STATIC);
o2:-get_age();

_m1982588380672

100

100

2*2551^(1/2)

_m1982698669216

5

person_class_NO_STATIC:=module()
   option object;
   local age:=5;   

   export set_age:=proc(_self,_age,$)      
     age:=_age:
   end proc:      

   export update_age:=proc(_self,$)      
      do_the_update()
   end proc:      

   local do_the_update:=proc()
      age:=age+1;
      age:=sqrt(age^2+3);
   end proc;

   export get_age:=proc(_self,$)      
     return age;
   end proc:      

end module:

o:=Object(person_class_NO_STATIC);
o:-set_age(100);
o:-get_age();
o:-update_age();

o2:=Object(person_class_NO_STATIC);
o2:-get_age();

_m1982698652256

100

100

2*2551^(1/2)

_m1982698629312

5

 

Download OOP.mw

Without trying it or looking down more, should these two code fragments give same output or not

# CASE 1

restart;
A   :=   2;
B   :=   x+2*y;
t^2 * ( A * B );


#CASE 2
restart;
t^2*( 2 * (x+2*y)  );

One would expect both to give same output, right? CASE 1 just uses variables and CASE 2 just uses the values of these variables. I mean the semantics of CASE 1 and 2 are the same, given that Maple replaces each variable with its value when evaluating.

But Maple does not give same result.

One way to force same result when using variables is to use t^2*(eval(A*B));

My question is why CASE 1 gives different result from CASE 2?  I would have expected same output.

Maple 2021.2 on windows 10. Worksheet.

interface(version);

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

restart;

A:=2;
B:=x+2*y;
t^2*(A*B);

2

x+2*y

2*t^2*(x+2*y)

restart;

t^2*(2*(x+2*y));

t^2*(2*x+4*y)

restart;

A:=2;
B:=x+2*y;
t^2*(eval(A*B));

2

x+2*y

t^2*(2*x+4*y)

 

Download why_different.mw

How do i code when i have to locate all maximum and minimum values, intervals of increase and decrease, and inflection points.

Thanks 

Why would simplify(t^2*x^2+t^2*y^2)  give  (x^2 + y^2)*t^2 but with seemingly same input except changing `+` to `-` fails now to simplify it?  simplify(t^2*x^2-t^2*y^2) gives t^2*x^2-t^2*y^2

Just trying to understand the logic behind this behavior.

In Mathematica both do simplify as can be seen below, which is what one would expect.

First 10 11 12 13 14 15 16 Last Page 12 of 28