Maple 2021 Questions and Posts

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

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

I only use latex() to convert Maple solution to Latex. I do not export whole document to Latex.

When I ask Maple to convert this solution of a PDE to latex, it generated strange Latex which is different, from the Latex it generates for same solution, when doing File->Export As->Latex.

The Latex it generated in the export case, is the one I want. The latex it generates from the latex() command, I am not able to use and is completely different. It has things like \mathit{Typesetting} and other different latex.  

Why is that? And how to make it generates the same Latex for this expression as in the export case?

First I show screen shot, then the worksheet to reproduce it

 

But Now when I save this worksheet (with only the expression I want) 

Using File->Export As->Latex, and then look at the latex for the "sol" in the latex file generated, this is what it shows (I am only showing the latex part of the above, not the whole file)

\begin{maplelatex}
\mapleinline{inert}{2d}{}
{\[\mathit{sol} \coloneqq u \left(r ,t \right)=\mathcal{L}^{-1}
\left(\frac{\mathrm{BesselJ}\left(0,10 \sqrt{-s}\, r \right) s}
{\mathrm{BesselJ}\left(0,20 \sqrt{-s}\right) \left(s^{2}+1\right)},s ,t \right)
-\mathcal{L}^{-1}\left(\frac{\mathrm{BesselJ}\left(0,10 \sqrt{-s}\, r \right)}
{\mathrm{BesselJ}\left(0,20 \sqrt{-s}\right) s},s ,t \right)
-\cos \left(t \right)+1\]}
\end{maplelatex}

The above latex I can compile standalone, and it does not have the problematic constructs found when using latex(sol)

One can see it is very different from the top one given earlier.

Why are the two latex different? Is there an extra setting one needs to adjust?  How make latex(sol) generate the same latex for the expression as found in the file generated by export as latex?

may_2.mw

update 1

Did some debugging. The problem happens when using `:-executeprintroutines`.  Tracing the latex() command in the debugger. At lines 42, it has the call

texlist := [latex:-Print(e,_rest,':-executeprintroutines',':- handleimaginaryunit',':-performonlyoncetasks',opt)];

Where above is the expression to convert to Latex. When I removed ':-executeprintroutines' the problems in latex went away. Here is an example

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
latex:-Print(sol)

Gives

"u ! left(r , t\right)", ` = `, `\\mathit{invlaplace} 
\\! \\left(\\frac{\\mathit{BesselJ}\\! \\left(0, 10 \\sqrt{-s}\\, r \\right) s}
{\\mathit{BesselJ}\\! \\left(0, 20 \\sqrt{-s}\\right) \\left(s^{2}+1\\right)}, s , t\\right)
-\\mathit{invlaplace} \\! \\left(\\frac{\\mathit{BesselJ}\\! 
\\left(0, 10 \\sqrt{-s}\\, r \\right)}{\\mathit{BesselJ}\\! \\left(0, 20 \\sqrt{-s}\\right) s}, s , t\\right)
-\\cos \\! \\left(t \\right)+1`

Now notice what happens when adding ':-executeprintroutines'

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
latex:-Print(sol,':-executeprintroutines')

it gives the problematic latex

"u ! left(r , t\right)", ` = `, `\\mathit{Typesetting}\\mcoloneq \\mathit{msup}\\! 
\\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mi}\\! 
\\left(\\text{\`\`$\\mathcal\\{L\\}$"}\\right), \\mathit{Typesetting}\\mcoloneq 
\\mathit{mrow}\\! \\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mo}\\! 
\\left(\\text{\`\`$-$"}\\right), \\mathit{Typesetting}\\mcoloneq \\mathit{mn}\\! 
\\left(\`\`1"\\right)\\right), \\mathit{Typesetting}\\mcoloneq \\mathit{msemantics}=\\text{\`\`atomic"}\\right)\\! \\left(\\frac{J_{0}\\! \\left(10 
\\sqrt{-s}\\, r \\right) s}{J_{0}\\! \\left(20 \\sqrt{-s}\\right) \\left(s^{2}+1\\right)}, s , t\\right)-
\\mathit{Typesetting}\\mcoloneq \\mathit{msup}\\! \\left(\\mathit{Typesetting}\\mcoloneq 
\\mathit{mi}\\! \\left(\\text{\`\`$\\mathcal\\{L\\}$"}\\right), \\mathit{Typesetting}\\mcoloneq 
\\mathit{mrow}\\! \\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mo}\\! \\left(\\text{\`\`$-$"}\\right), 
\\mathit{Typesetting}\\mcoloneq \\mathit{mn}\\! \\left(\`\`1"\\right)\\right), 
\\mathit{Typesetting}\\mcoloneq \\mathit{msemantics}=
\\text{\`\`atomic"}\\right)\\! \\left(\\frac{J_{0}\\! \\left(10 \\sqrt{-s}\\, r \\right)}
{J_{0}\\! \\left(20 \\sqrt{-s}\\right) s}, s , t\\right)-\\cos \\! \\left(t \\right)+1`

I do not know what :-executeprintroutines does and how one can tell latex() not to call it at the user level. I asked about :-executeprintroutines before here

  https://www.mapleprimes.com/questions/231230-Why-Latex-Removes-Constant-From-Expression

And I could not find any documenation on it.  

I tried to define my own executeprintroutines proc() which does nothing. But it did not help

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
executeprintroutines:=proc()
   NULL;
end proc;
latex(sol)

The Latex was not fixed. It is same. 

May be the above will help find the issue.

 

Hello,

I am trying to calculate the Dirichlet integral with the residue theorem and the LineInt command. I use the classic lace (Cf below) and the function exp(iz)/z. I don't understand why the LineInt function returns zero on the top semicircle. The result should depend on r and only be zero for limit(%, R = infinity).

Thanks for your help.

Attached is a worksheet containing a simple assignment that gives an "illegal use of an object as a name" error. I created the superscripted name in the following way.

1)  type b.

2) click on the Insert|Typesetting|Superscript  item in the insert menu.

3) enter 1 at the cursor in the superscript position.

4)  the result is a name b with superscript 1, but this symbol does not constitute a valid name for an assignment.


 

Parse:-ConvertTo1D, "first argument to _Inert_ASSIGN must be assignable"

Error, illegal use of an object as a name

"b^1:=2+3;"

 

NULL


 

Download errorws.mw

I trying to display factorials in a matrix as e.g 6!4!/5! not 144.
 

restart

with(InertForm)

[ConvertToString, Display, FromMathContainer, MakeInert, NoSimpl, Parse, SameStructure, ToMathContainer, ToMathML, Typeset, Value]

(1)

M := Matrix(4, 4); for m from 0 to 4 do for n from 0 to 4 do M(m+1, n+1) := factorial(NoSimpl(2*m+3*n))/(factorial(NoSimpl(m+2*n+1))*factorial(NoSimpl(m))*factorial(NoSimpl(n))) end do end do; M

Matrix(%id = 36893490820101234804)

(2)

NULL


 

Download How_to_display_factorial_unevaluated.mw

n := 3;
Digits := 10;
R_const := 8.314;
currentdir();
const := [1, 1, 1];
b := 20;
W := readdata("data20.txt", 2);
W := [seq([W[i, 2], W[i, 1]], i = 1 .. nops(W))];
Tempset := seq(W[i, 1], i = 1 .. nops(W));
Rateset := seq(W[i, 2], i = 1 .. nops(W));
Temp := [seq(W[i, 1], i = 1 .. nops(W))];
pdata := plots[pointplot](W, color = red);
pdata;

h[5] := 1;
h[4] := 8.5733287401;
h[3] := 18.059016973;
h[2] := 8.6347608925;
h[1] := 0.2677737343;
p[5] := 1;
p[4] := 9.5733223454;
p[3] := 25.6329561486;
p[2] := 21.0996530827;
p[1] := 3.9584969228;
r := x -> local m; exp(-x)*add(h[m]*x^(m - 1), m = 1 .. 5)/(x*add(p[m]*x^(m - 1), m = 1 .. 5));

q := (i, x) -> -Temp[1]*exp(-E_sim[i]/(R_const*Temp[1])) + E_sim[i]*r(E_sim[i]/(R_const*Temp[1]))/R_const + x*exp(-E_sim[i]/(R_const*x)) - E_sim[i]*r(E_sim[i]/(R_const*x))/R_const;

for i to n do
    R[i] := [seq(1 - exp(-A_sim[i]*const[i]*q(i, Temp[j])/b), j = 2 .. nops(Temp))];
end do;
for i to n do
    Der[i] := [seq(c_sim[i]*A_sim[i]*const[i]*exp(-E_sim[i]/(R_const*Temp[j]))*(1 - R[i][j]), j = 1 .. nops(Temp) - 1)];
end do;
Deriv := add(Der[i], i = 1 .. n);
model := [seq([Temp[i], Deriv[i]], i = 1 .. nops(R[1]))];
objective := add((W[i, 2] - model[i, 2])^2, i = 1 .. nops(Temp) - 1);
with(GlobalOptimization);
infolevel[GlobalOptimization] := 3;
Results := GlobalOptimization[GlobalSolve](objective, {add(c_sim[i], i = 1 .. 3) <= 1}, c_sim[1] = 0.05 .. 0.06, c_sim[2] = 0.85 .. 0.88, c_sim[3] = 0.05 .. 0.6, E_sim[1] = 33880 .. 33890, E_sim[2] = 40220 .. 41230, E_sim[3] = 23230 .. 23235, A_sim[1] = 2453 .. 2455, A_sim[2] = 190 .. 192, A_sim[3] = 1830 .. 1832, timelimit = 7200);
          [GetLastSolution, GlobalSolve, Interactive]

Results := [Float(undefined), [A_sim[1] = 2454.85789978944, 

  A_sim[2] = 190.143107633747, A_sim[3] = 1831.19959951461, 

  E_sim[1] = 33883.8826959700, E_sim[2] = 40796.6139830241, 

  E_sim[3] = 23230.4022199775, c_sim[1] = 0.0558944062681716, 

  c_sim[2] = 0.851532317382881, c_sim[3] = 0.0845465106500359]]


DEV_perc := 100*sqrt(Results[1]/(nops(Temp) - 3*n))/max(Rateset);
       DEV_perc := Float(undefined) + Float(undefined) 

Unsolved for Maple?

Thanks for reading.

I am just evaluating Maple 2021 under Windows 10 and I have something strange happening when I press F1 for Help or I select Maple Help in Help Menu. The first time the help window will appear but if I close it then impossible to view it again by pressing F1 or by selecting it in the Help menu. Also the same for other choices in the help menu like

Maple Help F1
Maple Portal
Study Guides
What's New

But any choices inside On the web will always work.

I am using Windows 10 latest release in french and the keyboard layout in ENG I don't think it is related but just in case someone ask me.

Have you notice the same problem ?

I have used the open source maxima quite a bit, and variable replacement was easy. For example:

3x+2y,x=20,y=5

3x+2y,x=3m-4p,y=(a+b)^2

I could combine very easily, like:

a=3x+2y             (%1)

4a-2b,%1

%1,x=5,y=7

and so on...I use variable replacement in equations VERY regularly, and so far, all I have found is having to use a mouse and select "Evaluate at a point". I'm not even sure I could put other equations in there if I wanted to. Even if it does work, the more complicated scenarios that I did routinely in maxima would still be virtually impossible this way.

Thus, the question is, is there doc somewhere on how to make various variable replacements, and equation combining like this easy?

First 34 35 36 37 38 39 40 Page 36 of 40