Maple 2021 Questions and Posts

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

Hello

I have a couple of large lists that will be further processed.  One of the steps is to index a list using another list (a list of indices).  A short example will be something like

L:=[2,1,4,3,7,6,8,3,4,5];
ind:=[2,2,3,3,5,6,7,1,4,10];

The solution 

L1:=L[ind]:

does not seem to be a good choice since it takes longer than the following solution

 

L1:=Threads:-Map(w->L[w],ind):

 

Since I am not a Maple expert, it is very likely that is a faster solution.   

 

Many thanks

 

hey guys, I'm curious if there is any way to do a group assignment like the following

JointNum := 3;
                    
seq(alpha[i], i = 1 .. JointNum) := 0, 0, 0;

which should as result be the following assignment

alpha[1], alpha[2], alpha[3]:=0,0,0

which is a valid assignment standalone but not works in the sequence style form . how can I implement this type of assignment

Hi, when I tried the simple example of Java OpenMaple on Mac, I can compile the code but couldn't run it. It complained about not finding libjopenmaple.jnilib. I checked that library directory, there was /libjopenmaple.jnilib but not libmaplec.dylib. Any suggestions?

> java -Djava.library.path=/Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX -classpath "$MAPLE/java/externalcall.jar:$MAPLE/java/Maple.jar:." test

Error loading libraries: java.lang.UnsatisfiedLinkError: /Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX/libjopenmaple.jnilib: dlopen(/Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX/libjopenmaple.jnilib, 1): Library not loaded: @rpath/libmaplec.dylib
  Referenced from: /Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX/libjopenmaple.jnilib
  Reason: image not found
java.lang.UnsatisfiedLinkError: /Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX/libjopenmaple.jnilib: dlopen(/Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX/libjopenmaple.jnilib, 1): Library not loaded: @rpath/libmaplec.dylib
  Referenced from: /Library/Frameworks/Maple.framework/Versions/2021/bin.APPLE_UNIVERSAL_OSX/libjopenmaple.jnilib
  Reason: image not found
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:316)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:282)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2440)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:809)
    at java.base/java.lang.System.loadLibrary(System.java:1893)
    at com.maplesoft.openmaple.Engine.<clinit>(Engine.java:23)
    at test.main(test.java:22)
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'long com.maplesoft.openmaple.Engine.getKernel(java.lang.String[], com.maplesoft.openmaple.EngineCallBacks, java.lang.Object, java.lang.Object)'
    at com.maplesoft.openmaple.Engine.getKernel(Native Method)
    at com.maplesoft.openmaple.Engine.<init>(Engine.java:44)
    at test.main(test.java:22)

 

 

Dear Community,

I try to slove a simple 2nd order ODE describing a simple pulley. Unfortunately dsolve does not like what I'm trying to do, and I get en error message. My goal is to plot travel distance, velocity and acceleration (  h(t), dh(t)/dt, d2h(t)/dt2 ) of the lifted weight. Could you pls. have a look what I'm doing wrong?

Also is there a way to transform this worksheet to a MapleSim document somehow? Worksheet attached.

tx in advance,

best regards

Andras

SimplePulley.mw

 

Since I installed Maple 2021 I have noticed a problem with the left corner of the menu and toolbar.  See the screenshot attached. I don't know if this is a general problem in Win10 or is this a problem with my installation.

Edit

I found the problem. Let me rephrase it. I keep original question below. 

This causes an error

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=module()
   export module_A1;
   local person_type;

   module person_type()
       option object;
       export name::string; 
       export age::string; 
    end module;

   module_A1:=module()
        export boo;
        boo:=proc()
          local X::A:-person_type;  #THIS LINE CAUSES ERROR
          #local X::person_type;    #THIS LINE ALSO CAUSES ERROR
          #local X;                 #THIS WORKS. No error
          X:=Object(person_type);
          return X;
       end proc;
    end module:
end module:

A:-module_A1:-boo();
           Error, (in boo) module does not export `person_type`

If I change  local X::person_type;  to just local X;  then no error is generated:

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

A:=module()
   export module_A1;
   local person_type;

   module person_type()
       option object;
       export name::string; 
       export age::string; 
    end module;

   module_A1:=module()
        export boo;
        boo:=proc()
          local X;  
          X:=Object(person_type);  #now this works
          return X;
       end proc;
    end module:

end module:

A:-module_A1:-boo();

              `Object<<person_type,1822742359104>>`

So the problem was in the variable declaration. Maple for some reason does not like   local X::A:-person_type;  and does not like local X::person_type; but things seem to work by just removing the ::type altogother. 

So this solves this problem for me for now, I can keep person module local, and still use it in other child modules. Even though I do not understand why Maple complains about it when I use ::

original question. Can be ignored now.

I have one main module, with 2 submodules (child modules) A1 and A2. The child modules are all exported so they can be called from outside the main module.

But I want to have one additional module X as object, to share among the child modules A1 and A2, but without having to also export module X.

But Maple wants me to also export module X in order to use it inside the child modules A1, and A2.

Is there a way to share X  among child modules, without exporting it? I only want X be visible to child modules (i.e. modules inside the main module)

The module X has option object and I want to use it as just a type basically (instead of using Record).

Here is an example

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=module()
   export module_A1,module_A2;
   local person_type;

   module person_type()
       option object;
       export name::string; 
       export age::string; 
    end module;

   module_A1:=module()
        export boo;
        boo:=proc()
          local X::A:-person_type;
          X:=Object(A:-person_type);
          return 1;
       end proc;
    end module:

   module_A2:=module()
        export boo;
        boo:=proc()
          local X::A:-person_type;
          X:=Object(A:-person_type);
          return 1;
       end proc;
    end module:

end module:

Now the call A:-module_A1:-boo(); fail with Error, (in boo) module does not export `person_type`

This can be fixed by changing local person_type;  to export person_type;  but this means person_type can now be seen from outside the main package.

In Ada, it is possible to have private data type shared among child packages. How to do the same in Maple?

 

 

Whenever i press F5, Maple will switch to nonexecutable math so I have to press it once more to go to math. This is very annoying. I would very much like to have it just switch between math and text when i press F5 like it used to do. 
How do I make it so?

Please help.

I have plain text files with comma delimited fields. Some fileds are strings and some are numeric.

When importing the file using

data:=Import(file_name,format="CSV",output=Matrix);

Maple changes any field which is string but contains a number inside it, as in "1"  to number 

And this causes all sorts of problems for me when processing the matrix data, since the program expects some fields to be strings. 

I looked at all options, but do not see how to tell Maple to keep a string as string, even if what is inside it is a number.

Here is an example file  "t.txt"

1,2,"0",4
1,2,"1",4
1,2,"A",4

I read it as follows

restart;
file_name:="C:/TMP/t.txt";
data:=Import(file_name,format="CSV",output=Matrix);

And Maple returns 

You see it changed "0" to 0 and "1" to 1.

This might be how CSV is supposed to work?. Does Maple have any option to override this default behavior in order to keep strings as strings, even though there is a number inside the string. I'll try to see if there is another format other than CSV to try which might behave better.

Maple 2021 on windows 10.

I could not find a function in StringTools package which removes all substrings (not single characters) from one long string directly. 

For example given a Latex string 

s:=" \\left \\int x \\,dx \\left";

And I want to remove all "\\left"  from it, which results in "  \\int x \\,dx "

In Mathematica, there is a function called StringDelete which removes all occurances of the substring in one call. Like this

s = " \\left \\int x \\,dx \\left";
StringDelete[s, "\\left"]

In Maple, I tried StringTools:-Remove(x->evalb(x="\\left"),s) and this did not work.Also tried

s:=" \\left \\int x \\,dx \\left";
StringTools:-Remove(x->StringTools:-Compare(x,"\\left"),s)

But this returned "leftintxdxleft"

And StringTools:-Delete needs a range, which one then has to first find.

I found this:

s:=" \\left \\int x \\,dx \\left";
idx:=[StringTools:-SearchAll("\\left",s)]; #returns index of first character in the string
StringTools:-Delete(s,idx[1]..idx[1]+4); #this only remove the first one. Need to loop to remove all.

Which returns the first substring. So one has to make a loop and keep removing all substrings found from the call to StringTools:-SearchAll

This is all too much work. But can be done.

The question is: What is the simplist way to remove all substrings from one string? All substrings are the same and the substrings can be more than one character.

Here is another example

s:="1234566X6Y67890A6BC66DEFGH";

And want to remove all "66" substrings, so the result will be

"12345X6Y67890A6BCDEFGH";

I am sure there must be an easier way to do this in Maple than having to call 2 or 3 functions and using a loop, but I could not find it so far. 

What would be the closest function in Maple to Mathematica's StringDelete? 

 

Hi there.

Following by https://www.mapleprimes.com/questions/232199-Bug-In-EllipticCPi

there is some strange behavior of EllipticPi - this function return complex answer when nu>1

WolframAlpha and some another online calculators return real values - just real part of Maple's value.

Why Maple's EllipticPi return complex answer?

Hi there.

It seems like EllipticCPi(n,k) has a bug when n close to 1:

Both answers should be equal by definition and first is true.

ell_error.mw

Hello everybody

In a course on numerical calculation in seismology (with jupyter notebook but I tried to adapt them in Maple), we use the Lagrangian interpolation:

First, have done the calculation and get the right answer. But I had to do it manually in Maple (see document below for the question and my solution. The question is describe more explicitly. What I want to do is to make Maple do it automatically and taking into account that there is the restriction i<>j. Then when the lagrangian is calculated, it will be easy to calculate u bar.

Thank you in advance for your help.

Mario

Lagrange_interpolation.mw

I got some planar graphs and I 'd like show their planar drawing. But the graph layout displayed by maple may not so balanced.

In the example below, we can see that the area of ​​the triangle 678 is too small, vertices 9, 10, 11 are crowded inside. I need to reduce the vertex size to better show it. Three vertices, say 9,10,11, in following planar drawing are not the right size.

with(GraphTheory):
d:=ConvertGraph("J|tZHkD@gF_"):
DrawPlanar (d, stylesheet=[ ],font=["Courier",10])

 

 

 

 

 

 

Vertexpadding doesn’t seem to help with vertex size reduction.

Ps:The algorithm used is Tutte's spring (or rubber) method. 

 

Maybe there is a better solution.

If we don’t adjust the vertex size, I don’t know if there is any other solution to improve the overall layout. It is best not to appear crowded.

 

Maple generates latex for hbar as  \mathit{hbar}  instead of just \hbar which makes it not render in PDF.  Here is an example

expr:= hbar*x;
latex(expr)

The screen display is correct. But not the latex. When compiling the above in Latex this is the output

\documentclass[12pt]{article}
\usepackage{amssymb}

\begin{document}  

%Maple generated
\[
\mathit{hbar} x
\]

%default
\[
\hbar x
\]

%need amssymb for this
\[
\hslash x
\]
\end{document}

Compiling the above gives

So to use the standard hbar,  \mathit should not be used around it. 

ps. I like \hslash more myself than \hbar , so if there is a choice, will vote for \hslash for latex.

Maple 2021, windows 10. 

 

Physics:-Version()
The "Physics Updates" version in the MapleCloud is 973 and is 

   the same as the version installed in this computer, created 

   2021, May 3, 18:54 hours Pacific Time.


 

I was taking notes from a video and fromatting them in a table so I could pring them.

I an using the commands in the context panel to keep things neat.

I can't get this to work for the last row of the table. when I select the equation, the right context panel changes to information about the table and the commands for manipulating the equations are not available. This occurs on the tenth row or later. 

I have since tried interface(rtablesize = [12,12]) but that didnt help.

If I run the document I can get the 10th row to solve by displaying the output first and then using the commands from the context panel

         
             

2*a[0]*a[9]*c[2] + 2*a[1]*a[8]*c[2] + 2*a[2]*a[7]*c[2] + 2*a[3]*a[6]*c[2] + 2*a[4]*a[5]*c[2] + a[9]*c[1];
 
                              8            
                     1430 c[2]             
                     ---------- + a[9] c[1]
                           16              
                       c[1]                

                             "(->)"

solve( 1430*c[2]^8/c[1]^16 + a[9]*c[1]=0, a[9] );
                                     8
                            1430 c[2] 
                          - ----------
                                  17  
                              c[1]    

                             "(->)"

a[9] := -1430*c[2]^8/c[1]^17: 'a[9]';
                              a[9]


           

Edited:- to improve readability and add more information.

restart

 

NULL

NULL``

                                                           

 

a[0] := 0

2*a[0]*a[1]*c[2]+a[1]*c[1]+1 = 0"(->)"-1/c[1]"(->)"a[1]NULL

2*a[0]*a[2]*c[2]+a[1]^2*c[2]+a[2]*c[1] = 0"(->)"-c[2]/c[1]^3"(->)"a[2]NULL

2*a[0]*a[3]*c[2]+2*a[1]*a[2]*c[2]+a[3]*c[1] = 0"(->)"-2*c[2]^2/c[1]^5"(->)"a[3]

2*a[0]*a[4]*c[2]+2*a[1]*a[3]*c[2]+a[2]^2*c[2]+a[4]*c[1] = 0"(->)"-5*c[2]^3/c[1]^7"(->)"a[4]

2*a[0]*a[5]*c[2]+2*a[1]*a[4]*c[2]+2*a[2]*a[3]*c[2]+a[5]*c[1] = 0"(->)"-14*c[2]^4/c[1]^9"(->)"a[5]NULL

2*a[0]*a[6]*c[2]+2*a[1]*a[5]*c[2]+2*a[2]*a[4]*c[2]+a[3]^2*c[2]+a[6]*c[1]"(->)"-42*c[2]^5/c[1]^11"(->)"a[6]

2*a[0]*a[7]*c[2]+2*a[1]*a[6]*c[2]+2*a[2]*a[5]*c[2]+2*a[3]*a[4]*c[2]+a[7]*c[1]"(->)"-132*c[2]^6/c[1]^13"(->)"a[7]

2*a[0]*a[8]*c[2]+2*a[1]*a[7]*c[2]+2*a[2]*a[6]*c[2]+2*a[3]*a[5]*c[2]+a[4]^2*c[2]+a[8]*c[1]"(->)"-429*c[2]^7/c[1]^15"(->)"a[8]

2*a[0]*a[9]*c[2]+2*a[1]*a[8]*c[2]+2*a[2]*a[7]*c[2]+2*a[3]*a[6]*c[2]+2*a[4]*a[5]*c[2]+a[9]*c[1]

 

 

NULL


 

Download Table_solve_issue.mw

First 6 7 8 9 10 11 12 Page 8 of 12