Maple 2021 Questions and Posts

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

I can't figure what is going on here. I have an expression, where when I run the program, I see inside the debugger that the result of evalb(simplify(tmp_1)) where tmp_1 is the expression, gives false

When I copy the same tmp_1 expression to new worksheet and do evalb(simplify(tmp_1)) it gives true.

I added print statements in the code to print tmp_1 and print result of simplify(tmp_1) and for some reason, it gives false when I run the program, but it gives true when I do the same thing in a work sheet, by copying tmp_1 and trying it there.

Never seen anything like this, as expression is all numbers. Here is the print out when I run the program

Here is the same thing in worksheet

restart;
tmp_1 :=-(2*ln(-2))/7 - ln(-1)/7 = ln(1) - (2*ln(-2))/7 - ln(-1)/7;
simplify(tmp_1);
evalb(simplify(tmp_1));

                      true

and if you think I made mistake somewhere, here is also screen shot from the debugger window itself

 

again, same thing gives true in separate worksheet, copying same exact expression from above

There seem to be something loaded when I run my program that causes this difference, but I have no idea now what it is.  This has nothing to do with the debugger loaded btw, I am just using the debugger to show the details. When I run the program, without the debugger, I get false for the above, and I was trying to find why.

Any suggestions what to try and what to check for and what could cause this? Should it not give true when I run the program also? Could it be some Digits setting changed when the program run? I do not change any system defaults of any sort when running the program. 

Maple 2020.1

edit june 12, 2021

Here is another manifestation of the same problem I just found. There is something seriously wrong for it to behave this way.

This is an expression called tmp_1 in a local variable in a proc inside a module. There are not even any local symbols in it. When I run the program, all the attempts to show it is true fail. Some give FAIL and some give false when the result should be true

When I simply copy the expression from the debugger window to an open worksheet, I get true

Here is the screen shot

 

Only when I did is(expand(tmp_1)) did it give true

But when I copy the expression to the worksheet, it gives true using all the other attempts:

restart;
tmp_1:=1 = 5/4*exp(0)+1/4*piecewise(0 <= 1,-1,1 < 0,exp(-2)):
is(tmp_1);
is(simplify(tmp_1));
is((rhs-lhs)(tmp_1)=0);
is(simplify((rhs-lhs)(tmp_1)=0));
evalb(simplify((rhs-lhs)(tmp_1)=0));
is(expand(tmp_1))

I can't make a MWE so far, since these problems only show up with I run my large program. I think Maple internal memory get messed up or something else is loaded that causes these stranges problems.

For now, I added expand() to the things I should try. My current code now looks like

if is(tmp_1) or is(simplify(tmp_1)) or is((rhs-lhs)(tmp_1)=0)
               or is(simplify((rhs-lhs)(tmp_1)=0)) or evalb(simplify((rhs-lhs)(tmp_1)=0))
               or is(expand(tmp_1)) then    
   ....

Maple 2021.1

 

 

... and two suggestions to the development team

POINT 1
In ?DiscreteValueMap (package Statistics) it's given an example concerning rhe Geometric distribution along with this comment:
"The Geometric distribution is discrete but it necessarily assumes integer values, so (bold font is mine) it also does not have a DiscreteValueMap"

This sentence seems to indicate that "because a distribution is discrete over the set of integers, it cannot have a DiscreteValueMap", some sort of logical implication...

But my feeling is that the Geometric distribution (or any other discrete distribution) does not have a DiscreteValueMap because this attribute has just not been specified when defining the distribution.

restart:
with(Statistics):

GeomRV := RandomVariable(Geometric(1/2)):
f := unapply(ProbabilityFunction(GeomRV, n), n):

AnotherGeomRV := Distribution(
      'ProbabilityFunction'=f,
      'Support'=0..infinity,
      'DiscreteValueMap'=(n->n),
      'Type'=discrete
):
DiscreteValueMap(AnotherGeomRV , n);

Thus having the set of natural numbers as support doesn't imply that DiscreteValueMap cannot exist.

Suggestion 1: modify the ?DiscreteValueMap help page so that it no longer suggests that some discrete distributions cannot have a .DiscreteValueMap 

______________________________________________________________________________________

POINT 2
I think there exists a true problem with the definition of discrete distributions in Maple: the ProbabilityFunction of a (discrete) random variable) takes non zero values outside their definition set.
For instance

ProbabilityFunction(GeomRV, Pi);  # something non null


To ivercome this problem I defined a new Geometric distribution this way (not entirely satisfying):

restart:
with(Statistics):

GeomRV := RandomVariable(Geometric(1/2)):
f := unapply(ProbabilityFunction(GeomRV, n), n):
g := n -> (1-ceil(n-floor(n)))*f(n)    # (1-ceil(n-floor(n))) = 1 if n in Z, 0 otherwise

AnotherGeomRV := Distribution(
      'ProbabilityFunction'=g,
      'Support'=0..infinity,
      'DiscreteValueMap'=(n->n),  # is wanted
      'Type'=discrete
):
ProbabilityFunction(AnotherGeomRV, 2);
                 1/8
ProbabilityFunction(AnotherGeomRV, Pi);
                  0

PS: None of the statistics based upon the  ProbabilityFunction (Mean, Variance, ... ) is correctly computed with the previous construction. This could be easily overcome by completing this definition, just as its done in Maple, for all the requires statistics, for instance 

AnotherGeomRV := Distribution(
      ....
      'Mean'=1   # or more generally (1-p)/p form Geometric(p)
):


Suggestion 2: modify the way discrete distributions are defined in Maple in order to avoid ProbabilityFunction to return wrong values.

I need to change any occurance of   anything*sqrt(anything)  to say Z in any large expression.  (later, I can add the correct replacement once I know how to do it for Z).

I can change   sqrt(anything) with the help of the answers in Substitution-Of-Sub-Expressions-Is  but not  anything*sqrt(anything)

Here is an example to make it clear. Given

expr:=(-x + sqrt(9*x^2*exp(2*c) + 8)*exp(-c)+99)/(4*x)+ (a*sqrt(z)-99+sin(c*sqrt(r+4)+20))/3+10+1/(c+exp(-x)*sqrt(exp(x)))+sqrt(h)

Need to all some transformation on  those subexpressions circled above. For now, lets say I wanted to replace them with so it should becomes this

I can do this

subsindets(expr,anything^({1/2,-1/2}),ee->Z)

But I need to have the term (if any) that multiplies the sqrt as well included.

And that is the problem. Can't figure how to do it. When I try

subsindets(expr,anything*anything^({1/2,-1/2}),ee->Z)

Maple says Error, testing against an invalid type Ok. So anything*anything^({1/2,-1/2}) is not a type. What to do then?  Tried also subsindets(expr,t::anything*anything^({1/2,-1/2}),ee->Z) same error

And 

applyrule(t1::anything*sqrt(t0::anything)=Z, expr);

gives  which is wrong.

How to make this work in Maple using subsindets? Can one use pattern with subsindets? How to make a type for

               anything*sqrt(anything) 

Maple 2021.1

 

I want to plot a 2D graph without labels. The labes=["",""] option does half of the job—it prints the empty string for labels (that's good) but it reserves room for them (that's bad).  In the following code I use a large size labelfont in order to exaggerate the effect:

restart;
plots:-setoptions(labelfont=[TIMES,64]);  # large labelfont selected on purpose
p1 := plot([[0,0],[1,1]], labels=["", ""]);

Note the large blank space at the bottom reserved for the the non-existent label.

I know one way to eliminate the label altogether:

p2 := subs(AXESLABELS=NULL, p1);

This does the right job but is there a more orthodox way of doing that?

Afterthought:  It would be good if the labels option to the plot command  accepted none as argument, as in labels=[none, none].

Why Maple likes to extract exp() outside the sqrt when its argument has minus sign vs. not?  Compare the following

restart;
eq2 := ln(2*u^2 + u - 1) = -c - 2*ln(x);
sol:=[solve(eq2,u)]:
simplify(sol[1])

and

eq2 := ln(2*u^2 + u - 1) = c - 2*ln(x);
sol:=[solve(eq2,u)]:
simplify(sol[1])

I like the above much better than the first one. Mathematica keeps both same form (i.e. keeps the exp() inside):

Maple's answers are correct ofcourse, I just do not understand the logic why when there is a minus sign on it likes to format it differently as shown.

Is there a way to make not do that?

 

I am trying to export a 3D plot from Maple (2021) in a vector format that can be imported into Adobe Illustrator without too much trouble. The graphic artist says the PDF files are not useful (“at the base of every PDF is an image file, inside layers and layers of clipping paths; not helpful”). “SVG does not appear to produce usable vectors – well, maybe not, but the one you sent me was super difficult to wrangle”. She had hoped that EPS would be useful, but she was unable to open the EPS file I created (not enough memory).

Here is the example that I have been using as I've asked others for help with this question.

restart;
with(plots);
with(plottools);

T := torus([0, 0, 0], 1/2, 1/2);
C0 := spacecurve([cos(t), sin(t), 0], t = 0 .. 2*Pi, color = red, thickness = 9);
C1 := spacecurve([0.5*cos(t), 0.5*sin(t), 0.5], t = 0 .. 2*Pi, color = red, thickness = 9);
C2 := spacecurve([0.5*(1 + cos(t)), 0, 0.5*sin(t)], t = 0 .. Pi, color = blue, thickness = 9);
C3 := spacecurve([0.5*(-1 + cos(t)), 0, 0.5*sin(t)], t = 0 .. Pi, color = blue, thickness = 9);
Fig9510 := display([T, C0, C1, C2], view = [DEFAULT, DEFAULT, 0 .. 1/2], scaling = constrained, transparency = 0.75);

Direct links to the worksheet and the PDF, EPS, and SVG files on DropBox are provide below in the hope that something will be useful to somebody. (MaplePrimes links are provided for the MW and PDF files are also provided - but EPS and SVG files are not permitted.)

  1. 3DPlotExample.mw: https://www.dropbox.com/s/mx1hg1ntuqihnu3/3DPlotExample.mw?dl=0
  2. Fig9510.pdf: https://www.dropbox.com/s/bnzfqrh060gw84g/Fig9510.pdf?dl=0
  3. Fig9510.eps: https://www.dropbox.com/s/h9bjyn0uwm8w5ct/Fig9510.eps?dl=0
  4. Fig9510.svg: https://www.dropbox.com/s/u2xfntnqvbhu810/Fig9510.svg?dl=0

This question has been asked for more than ten years. The best solution to has been to use the command-line-interface version of Maple.

  1. Is the command-line interface still the best/only option for vector-based graphics output?
  2. If so, how do i access the command-line version of Maple 2021 on MacOS?

The attached worksheet is a stripped down version of some notes I am creating concerning the solution of vector equations in geometric algebra.  For the purposes of explanation it is best to show the math in its conventional typeset form before showing how to solve the equations in maple. The non-excutable math is in the text which is contained in a paragraph inserted before the execution group. In the first instance, the typesetting engine seems content to leave the text alone, but in the second case (which I created in the same way) it insists on parsing the equations and generating errors. I have tried repeatedly to make the second set of equations non-executable (since in maple terms they are nonsense) to no avail.
Can anyone suggest how I can use maple's text features to make the explanatory text inert.

Note that I have included the calls to my geometric algebra module in case they have some relevance to the problem, but they will not execute without the module.

Sample worksheet:  nonexecmatherror.mw

When I click on the "install" option for the update to the Physics Package, get the following error message:

Fetching package "Physics Updates" from MapleCloud...
ID: 5137472255164416
Version: 988
URL: https://maple.cloud

An error occurred, the package was not installed: 
Unable to log into Maplesoft account: Forbidden (403)

In Maple 2021.1

restart;
int(cos(3*x)/(-(-1+8*cos(x)^2)^(1/2)+(3*cos(x)^2-sin(x)^2)^(1/2)),x)

gives

Error, (in SumTools:-DefiniteSum:-ClosedForm) numeric exception: division by zero

But in Maple 2020.2 it works OK giving an answer. (A very long one)

btw, the answer should be

3/4*arcsin(2/3*sin(x)*3^(1/2))-3/4*arctan(sin(x)/(-1+4*cos(x)^2)^(1/2))-3/4*arctan(sin(x)/(-1+8*cos(x)^2)^(1/2
))+5/8*arcsin(2/7*sin(x)*14^(1/2))*2^(1/2)-1/2*sin(x)*(-1+4*cos(x)^2)^(1/2)-1/2*sin(x)*(-1+8*cos(x)^2)^(1/2)

 

Is this a known issue? I know Maple int has went some changes and improvements in Maple 2021 from the release notes. May be this was caused by some of these changes?

https://www.maplesoft.com/products/maple/new_features/

  • Integration has been enhanced with improved algorithms for indefinite integration, and the ability to easily specify which integration method should be used and to compare the results from different methods."

Maple 2021.1 on windows 10

update July 2, 2021

These are additional failed integration in 2021.1 that throw exceptions now. no errors in 2020.2

#427
int(cos(3*x)/(-(-1+8*cos(x)^2)^(1/2)+(3*cos(x)^2-sin(x)^2)^(1/2)),x)

#533 #no error in Maple 2020, it does not evaluate there. But no error
int((-3+exp(7*x))^(2/3)/exp(2*x),x)

#26/11 #no error in Maple 2020, it does not evaluate there. But no error
int((b*x+(b^2*x^2+a)^(1/2))^(1/2)/(b^2*x^2+a)^(1/2),x)


 

dsolve accept system of first order ode's in the form x'=A x, where x' is vector, A is matrix of coefficients and x are the dependent variables. This is convenient since one does not have to convert things to a list.

But  dfieldplot and phaseportrait and DEplot do not accept this form. One must convert things to list first.

Here is an example

restart;
sys:=Vector([diff(x(t),t),diff(y(t),t)]) = Matrix([[1,2],[0,3]]).Vector([x(t),y(t)]);
dsolve(sys)

But

DEtools:-dfieldplot(sys,[x(t),y(t)],t=0..4,x=-4..4, y=-4..4);

Error, (in DEtools/dfieldplot) system must have same number of dependent variables as DE's.

workaround is to write the system as list

new_sys:=[diff(x(t), t)=x(t) + 2*y(t),diff(y(t), t)=3*y(t)];
DEtools:-dfieldplot(new_sys,[x(t),y(t)],t=0..4,x=-4..4, y=-4..4);

I know one can automate the conversion. But still, it would be better if dfieldplot would accept sys as dsolve did.

Same for 

DEtools:-phaseportrait(sys,[x(t),y(t)],t=0..4,[[x(0)=1,y(0)=0]],x=-4..4, y=-4..4);
#
DEtools:-DEplot(sys,[x(t),y(t)],t=0..4,[[x(0)=1,y(0)=0]],x=-4..4, y=-4..4);

They gives same error.

Since dsolve can do it, may be these other functions can also support taking a system of ode's in vector/matrix form? Any reason why not?

Maple 2021.1

 

 

There seems to be an "issue" when using a indexed name (say x[4]) as the loop index in a seq() mul() or add() command - the indexed name is assigned once the command exits!!

This never(?) happens if the loop index is not an indexed name. A bug??

See the attached which illustrates the issue for the add() command, where x[4] is assigned on exit from add(). The same thing happens if add() is replaced with seq() or mul()

  restart;

#
# x[4] should not be assigned on exit from add() !!
#
  add( u(x[4]), x[4]=1..10);
  x[4];
#
# x__4 is not assigned on exit from add()
#
  add( u(x__4), x__4=1..10);
  x__4;
#
# j is not assigned on exit from add()
#
  add( u(j), j=1..10);
  j;

u(1)+u(2)+u(3)+u(4)+u(5)+u(6)+u(7)+u(8)+u(9)+u(10)

 

10

 

u(1)+u(2)+u(3)+u(4)+u(5)+u(6)+u(7)+u(8)+u(9)+u(10)

 

x__4

 

u(1)+u(2)+u(3)+u(4)+u(5)+u(6)+u(7)+u(8)+u(9)+u(10)

 

j

(1)

 


 

Download aBug.mw

 

 

I do not remember if there was a post on this before or not
Maple 2021.1

int(arcsin(x)/(1+(-x^2+1)^(1/2)),x)

gives

Error, (in Utils:-TransformAndApply) numeric exception: division by zero

The correct answer should be

((-1 + Sqrt[1 - x^2]) ArcSin[x])/x + ArcSin[x]^2/2 -  Log[1 + Sqrt[1 - x^2]]

I had to go back to Maple 2018, to get no exception:

May be this could be looked at for next Maple version?

My PC is dual-booted (Win10 and Ubuntu 20.04+KDE). After creating a plot (even the simplest one) and enabling Probe Info as described in  https://www.maplesoft.com/support/help/maple/view.aspx?path=worksheet%2Fplotinterface%2Fpointprobei I do not see tooltip with cursor position. All other tooltips (Palettes, Toolbar etc.) work fine, it is only the probe Info tooltip that does not work. The same plot done while running Maple on Win10 works as expected - tooltip is visible. 

Can someone confirm whether it works for them using Linux? I wonder whether this could be Java-related problem when running on Linux KDE with compositing and using Nvidia driver (e.g. color of tooltip is white on white, or rendering does not work as expected).

I do not remember whether it ever worked on Linux. At this moment I am using Maple2021 but for testing purposes I reinstalled Maple2020 and the problem is the same.

Thanks,

Alex

I have plain text file generated, where each line has mixed numbers and strings. Some of the strings are latex. So they have "\" in them. The data is rectangle. same number of fields on each line, separated by commas.  I use CSV format to read the data to Maple.

I simply want to read this file using Import , which reads it into a matrix (using CSV format), and export it back right away using either ExportMatrix or Export and end up with the same exact file.

But Maple always adds extra "\" each time I export the matrix back to the file. So if I have initially "\sin x" in the file, after reading/writing the file 5 times without touching the data inside Maple, I end up with something like "\\\\\\\\\\\sin x" in the file at the end.

I could ofcourse not use ExportMatrix nor Export and write the data back to the file manually using fprintf using correct format for each field. But it is easier if I can get ExportMatrix to work since there are many fields some are integers, some are real and some are strings.

Here is a simple MWE which shows the problem. Originally I have this file on disk. Called test.txt and has 2 lines in it

1,"\sin x"
2,"this is second line"

Now after doing the following

data:=Import("test.txt",format="CSV",output=Matrix):  
ExportMatrix("test.txt",data,target=csv);

The file on disk now becomes

1,"\\sin x"
2,"this is second line"

And repeating the above one more time, the file becomes

1,"\\\\sin x"
2,"this is second line"

This ofcourse breaks all the latex strings in there.

Is there a way to prevent Maple from doing this? I looked at all the options in help, but do not see on so far.  I also tried Export but that did not work at all. So I'd like to see if ExportMatrix can do it, without adding an extra "\", otherwise, will have to use fprintf directly to export the data back to file.

edit

fyi, I ended up using fprintf to write the data back to disk. May be if there is a solution using ExportMatrix, will change back. This is what I ended up doing

File before

1,"\sin x"
2,"this is second line"

Now run this code

data:=Import("test.txt",format="CSV",output=Matrix):  
file_id := fopen("test.txt",WRITE):
nRows:=LinearAlgebra:-RowDimension(data);
for n to nRows do
    if n<nRows then
       fprintf(file_id,"%d,\"%s\"\n",data[n,1],data[n,2]);
    else
       fprintf(file_id,"%d,\"%s\"",data[n,1],data[n,2]);
    fi;
od;
fclose(file_id);

File after

1,"\sin x"
2,"this is second line"

Now the file is exactly the same as before reading it.

My actual data is more than the above two fields, but that makes the format string longer, that is all.

 

We have just released an update to Maple, Maple 2021.1.

Maple 2021.1 includes improvements to plotting, export to PDF and LaTeX, the user interface, the mathematics engine, and more. We strongly recommend that all Maple 2021 users install these updates.

This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2021.1 download page, where you can also find more details.

In particular, please note that this update includes fixes to the sometimes missing plotting toolbar, the misplaced plot annotations on export, and a workbook saving problem, all reported on MaplePrimes.

Thanks for the feedback!

 

First 32 33 34 35 36 37 38 Page 34 of 40