Maple 2023 Questions and Posts

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

Here is an apparent instance: 

interface(version);

maximize((1+20230321)*x*y-(x^2+y^2)*(1/2))``

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

 

0

(1)

NULL

Download incorrectAgain.mw

Why???
Quite evidently, its supremum cannot be 0. (There are, of course, other approaches to compute it symbolically, yet I just wonder about the cause of this bug.)

Could someone explain to me why the Maple online help pages (see here) are still apparently matching the Maple 2021 release for the past few years? Does this mean that all the information on the Maple online help pages is out of date, or just this one specific page is terribly out of date?

I am trying make atomic variables stand out in the document, I thought they used to automatically change to a purple type colour.

So under Format, styles , I set the style to size 14, Bold, dark green.  The font changed on the existing ones but not the colour.

On new ones no setting occours just default text. I then restored to default settings under styles and they all turned purple including the new ones.

Then I made another one but no adoption of the default style (purple) occured. 

This fiddlyness needs to be improved  

Has anyone any suggestions to make the atomic variables adope their default colour etc?

I found a new problem in Maple 2023 on windows 10.  But it is more of an annoyonus. This is what happens:

I can have a worksheet open and running somecode with lots of output generated on the screen. Everything displays fine.

Now I go and open a new application not related to Maple at all, for example if I open the task manager, this causes the Maple screen to immediately go all BLANK ! Yes, all the display is gone. I have no idea why opening a new application in new window could cause this.

Everything disappears from the worksheet except for the worksheet frame. All the menus are gone also.

But resizing the worksheet window makes everything to appear agin due to the repaint process, But I need to resize the worksheet few times to get everything to repaint fully.

So the content is still there, but it just do not show/repaint.

Note that Maple does NOT freeze or anything, it is still running and the content is there, it is just that the content becomes not visible due to opening a new application window on the side.

I have never seen anything like this in any other application on windows. I also never had this problem on same PC with Maple 2022.2.

Anyone else noticed this problem?  This is reproducible all the time. Sometimes the content will display again on its own after short amount of time, but will be missing many menu items and missing side content and so on so I have to resize the windows to make repaint eveything again. 

May be it is a Java problem. I do not know.

I have the same system as described in this post 

I will make a movie to show this very soon but I am waiting for something to finish running before I do this so I can save all my work.

Windows 10 pro, running Maple 2023 with two monitors.

Here is a small movie. I made very small example which prints number on the screen in a loop. I added a Sleep in between so it does not take over the CPU just for illustration. In my real code there is no such Sleep command.

In this movie, we see that when I open the task manage window how the display in the worksheet is gone. In this example it comes back after few seconds but all the other items in the worksheet (menus etc..) are still missing. Resizing the windows makes them appear again. In my actual code, due to the larger content, the whole worksheet remain not visible for much longer each time (I waited 5 minutes and more for it to repaint), but still had to resize it to make everything visible as in this example.

Can someone else reproduce this?

for n from 1 to 1000000 do
    print("n=",n);
    Threads:-Sleep(2);
od;

 

 

I am porting some code I have in Mathematica to Maple. 

Mathematica has command Exponent which returns largest power on x, even if the power is not integer.

It is defined as

Maple's degree command does not allow this and returns FAIL (since it is meant to work only on polynomial, I understand that).

Is there a different command I could use which does the same as Exponent? Otherwise I have to parse it manually. The expressions will all be univariant polynomial in x, but the power on x can contain a symbol and numbers. The expression can be more complicated, but it will always have just one x in it, and I just want to extract the power in that x inside the expression.

Here are examples

degree(x^2,x);
degree(x^(n-1),x);
degree(3*x^(n+2),x);

In the above all fail except the first one which returns 2. For reference here is the result from Mathematica's Exponent command

Exponent[x^2, x]
Exponent[x^(n - 1), x]
Exponent[3*x^(n + 2), x]

I googled and could not find anything so far. I looked at PolynomialTools but do not see such command in it.

On possibility to do this manually is

get_exponent:=proc(expr,x::symbol)
   local z:=indets(expr,identical(x)^anything);
   if nops(z)<>0 then
      op(2,z[1]);
   else
      1;
   fi;
end proc;

And now

get_exponent(x^2,x);
get_exponent(x^(n-1),x);
get_exponent(3*x^(n+2),x);

2

n-1

n+2

Eitherway, if there is a builtin command in Maple, it will be better to use than my code which might still fail for some cases I did not think of.

Maple 2023

with(Units[Standard]);
A := 2*Unit('Pa');
x := 0;
sqrt(A^2);

In this example defining the 'x' variable returns an error message: "Error, (in simplify/sqrt/fraction) invalid input: denom expects its 1st argument, x, to be of type {algebraic, list, set}, but received pascal".

You can use any Unit in 'A' variable.

> int((1 - x)^r*(-2*x + (-2 + x)*log(1 - x))/(2*x*log(1 - x)^2), x = 0 .. 1) assuming 0 <= r

(int((1 - x)^r*(-2*x + (-2 + x)*log(1 - x))/(2*x*log(1 - x)^2), x = 0 .. 1) assuming (0 <= r))

Expected result is:

1 + r - r * ln(1 + r) - 1/2 * ln(2 * Pi * (1 + r)) + lnGAMMA(1 + r)

 

For two nonempty lists (of the same length), 

F~(list1, ` $`, list2); # space-dollarsign

is (almost) equivalent to 

zip(F, list1, list2);

However, it appears that in practice, using `~` can be faster than its equivalent zip version.
Here is a typical test: 

restart;

x := combinat:-randperm(10^7):
y := combinat:-randperm(10^7):

undefine(f);

t2 := CodeTools[Usage](`~`[f](x, ` $`, y), iterations = 10)

memory used=0.62GiB, alloc change=1.21GiB, cpu time=51.35s, real time=14.77s, gc time=42.55s

 

t4 := CodeTools[Usage](zip(f, x, y), iterations = 10)

memory used=0.52GiB, alloc change=-4.00MiB, cpu time=53.88s, real time=16.25s, gc time=44.51s

 

evalb(t2 = t4)

true

(1)

NULL


 

Download `~`_and_zip.mw

But I cannot find any explanations in the documentation (as well as What is Maple's equivalent to Mathematica's MapThread?). Does anyone know why?

The inverse problem of a mathematical question is often very interesting.

I'm glad to see that Maple 2023 has added several new graph operations. The GraphTheory[ConormalProduct], GraphTheory[LexicographicProduct], GraphTheory[ModularProduct] and GraphTheory[StrongProduct] commands were introduced in Maple 2023.

In fact, we often encounter their inverse problems in graph theory as well. Fortunately, most of them can find corresponding algorithms, but the implementation of these algorithms is almost nonexistent.

 

I once asked a question involving the inverse operation of the lexicographic product.

Today, I will introduce the inverse operation of line graph operations. (In fact, I am trying to approach these problems with a unified perspective.)

 

To obtain the line graph of a graph is easy, but what about the reverse? That is to say, to test whether the graph is a line graph. Moreover, if a graph  g is the line graph of some other graph h, can we find h? (Maybe not unique. **Whitney isomorphism theorem tells us that if the line graphs of two connected graphs are isomorphic, then the underlying graphs are isomorphic, except in the case of the triangle graph K_3 and the claw K_{1,3}, which have isomorphic line graphs but are not themselves isomorphic.)

Wikipedia tells us that there are two approaches, one of which is to check if the graph contains any of the nine forbidden induced subgraphs. 

Beineke's forbidden-subgraph characterization:  A graph is a line graph if and only if it does not contain one of these nine graphs as an induced subgraph.

This approach can always be implemented, but it may not be very fast. Another approach is to use the linear time algorithms mentioned in the following article. 

  • Roussopoulos, N. D. (1973), "A max {m,n} algorithm for determining the graph H from its line graph G", Information Processing Letters, 2 (4): 108–112, doi:10.1016/0020-0190(73)90029-X, MR 0424435

Or: 

  •   Lehot, Philippe G. H. (1974), "An optimal algorithm to detect a line graph and output its root graph", Journal of the ACM, 21 (4): 569–575, doi:10.1145/321850.321853, MR 0347690, S2CID 15036484.


SageMath can do that: 

   root_graph()

Return the root graph corresponding to the given graph.

    is_line_graph()

Check whether a graph is a line graph.

For example, K_{2,2,2,2} is not the line graph of any graph.

K2222 = graphs.CompleteMultipartiteGraph([2, 2, 2, 2])
C=K2222.is_line_graph(certificate=True)[1]
C.show() # Containing the ninth forbidden induced subgraph.

 

enter image description here

 

Another Sage example for showing that the complement of the Petersen graph is the line graph of K_5.

P = graphs.PetersenGraph()
C = P.complement()
sage.graphs.line_graph.root_graph(C, verbose=False)

 

(Graph on 5 vertices, {0: (0, 1), 1: (2, 3), 2: (0, 4), 3: (1, 3), 4: (2, 4), 5: (3, 4), 6: (1, 4), 7: (1, 2), 8: (0, 2), 9: (0, 3)})

 

Following this line of thought, can Maple gradually implement the inverse operations of some standard graph operations? 

Here are some examples:

  •   CartesianProduct
  •   TensorProduct
  •   ConormalProduct
  •   LexicographicProduct
  •   ModularProduct
  •   StrongProduct
  •   LineGraph
  •  GraphPower

For a list containing at least one element, 

F~(list0); # element-wise

is (almost) equivalent to 

map(F, list0);

However, it seems that in practice, using `~` can be faster than its equivalent map version.
Here is a typical test: 

 

 

restart;

w := [`$`](0 .. 1e4):
x := [`$`](0 .. 2e3):
y := [`$`](0 .. 3e2):
z := [`$`](0 .. 4e1):

undefine(f)

NULL

 

 

# Compute a generalized outer product of [w, x] and [y, z] without using the inefficient `ArrayTools:-GeneralOuterProduct`.

""(* Note that we cannot use the ""unapply"" command here. (Use ""->"" instead.) *)""

p2 := CodeTools[Usage](`~`[proc (s4) options operator, arrow; `~`[proc (s3) options operator, arrow; `~`[proc (s2) options operator, arrow; `~`[proc (s1) options operator, arrow; f(s3, s1) end proc](s2) end proc]([y, z]) end proc](s4) end proc]([w, x]), iterations = 10)

memory used=282.53MiB, alloc change=0.59GiB, cpu time=21.67s, real time=7.41s, gc time=17.33s

p4 := CodeTools[Usage](map(proc (s4) options operator, arrow; map(proc (s3) options operator, arrow; map(proc (s2) options operator, arrow; map(proc (s1) options operator, arrow; f(s3, s1) end proc, s2) end proc, [y, z]) end proc, s4) end proc, [w, x]), iterations = 10)

memory used=230.48MiB, alloc change=-4.00MiB, cpu time=23.26s, real time=8.67s, gc time=17.71s

evalb(p2 = p4);

true

NULL


 

Download `~`_and_map.mw

But I cannot find any explanations in Comparison of element-wise operators and map function or Difference between 'map' and '~' (element-wise operation). Does anyone know why?

The standard way of writing quotes and double quotes in LaTeX is with `` and ''

So a string should be translated to Latex using ``the_string' '  and not ``the_string"  which is what Maple does.

see for example this  

 

For example, Maple translates  "regular" to

                "\text{``regular\"}"

It should be

                "\text{``regular' '}"

i.e. instead of closing it on the RIGHT with string quote  \"  it should close it with two upticks, like this ' '

Hard to see the differene here, so here is screen shot

s:="regular";
latex(s,output=string);
lprint(%)

The difference will show up depending on what font one is using. Here is an example below where when using different font, the effect is now visible. 

\documentclass[12pt]{book}
\usepackage{amsmath} 

\usepackage[T1]{fontenc}
\usepackage{mlmodern}

\begin{document}

\text{``regular"}

\text{``regular''}

\end{document}

The first one above is what Maple generates, the second one is what it should have been. Compiling with luatex gives this pdf, You can see clearly the difference now

It is important to note that this behavior shows depending on font used. For example, this code

\documentclass[12pt]{book}
\usepackage{amsmath} 
\begin{document}

\text{``regular"}

\text{``regular''}

\end{document}

When compiled gives

So to be safe, it is better to always use the standard  `` ....' '   and not `` .... \" because it then works the same for different fonts being used.

So, would it be possible to make Maple generate quoted string using the standard latex by closing it with ' ' instead of \"  ?  

 

 

the command singular can return results with _Z or _N as it says in help

The singular function may return expressions prefixed by _Z or _N, representing the integers and positive integers, respectively.
 

But it changes these letters by adding different number at the end for each call., Yet they all mean the same thing, which is an integer:

singular(1/sin(x),x)
                         {x = Pi*_Z1}

singular(x/sin(x),x)
                         {x = Pi*_Z2}

singular(x^2/sin(x),x)
                        {x = Pi*_Z3}

 

This makes it little hard when I try to make union of these results to only keep the unique singular points, since they are different symbols, yet they are really the same: integer times Pi.

Is there an option to tell Maple to use _Z for everything? And not keep adding new numbers each time it is called?

May be clear some internal memory table after each call?  Otherwise, I have to add more code to parse all these results and convert all _Znnn to just _Z  if it is there in each result, after each call is made.

Same issue for _N

Update

Additional example to try/test against

expr:=1/(sin(x)*cos(x)*tan(x));
s := singular(expr, x);

expr:=1/((x-1)*sin(x));
s := singular(expr, x);

expr:=1/(sin(x)*cos(x-Pi/3)*tan(x));
s := singular(expr, x);

In all the outputs above, I'd like to have same _Z show up. This will make it easier for postprocessing later on. Best solution will be to tell Maple itself not to change _Z if possible, otherwise one will need to add code to do this afterwords for all possible cases.

 

ODE for electrical circuit (right click on Documentblock, unselect show command does not work. Command still visble)u(t) = T*(diff(`&varphi;`(t), t))+L*(diff(i(t), t))+i(t)*R

u(t) = T*(diff(varphi(t), t))+L*(diff(i(t), t))+i(t)*R

(1)

 

ODE for motor (toggle Documentblock, unselect show command is only effective on equations  3 and 4)i(t)*T = J*(diff(`&varphi;`(t), t, t))

i(t)*T = J*(diff(diff(varphi(t), t), t))

(2)

Isolate i(t) and taking the derivative

i(t) = J*(diff(diff(varphi(t), t), t))/T

(3)

``

diff(i(t), t) = J*(diff(diff(diff(varphi(t), t), t), t))/T

(4)

``

Download Document_Block_hide_command.mw

in Maple 2023 one can do File->Open and select an .mpl file and that will automatically open in new window using code editor.  see Maple2023-CodingTools.pdf

One problem I saw right away on windows 10, is that the diagonstic window has funny character at the end of the messages. Here is screen shot

 

To see if you reproduce this, here is the code I used. Simply save this in foo.mpl file and then use Maple file->open to open it (must use 2023 only for this to work)

A_class :=module()
    option object;

    #my variable
    export c::integer;

    export a::integer;

end module;

 

That is not all. If I simply shift the code up so the starting line in the file is not empty as above, the funny characters change to something else

 

 

Yet, it is the same exact code.  Can any one confirm this problem, and how to fix it so one can read the variable name?

 

I think I will stick to using notepad++ for my .mpl files for now.

 

Hi MaplePrimes,

I've updated to the 2023 version of Maple. After the update I chose to remove older version folders in Windows.

Since then I cant't use my tasks any longer. I've re created the tasks and the are also shown in the Task Palette, but clicking on a task results in nothing. I can though create a new Task and after the creation all my tasks can then be used again.

Its like Maple doesn't recognize the correct Help Database from the beginning. I've reinstalled Maple 2023 two or three times to try to reset the whole installation to something from scratch. Nothing that I do seems to produce the desired result. Does anybody out there have a solution or suggestion to a probable solution?

I don't know of any file that I could attach to exemplify my problem. It's not a math/maple problem relating directly to the maple code language. My tasks themselves work fine once inserted in a document. It's the insertion itself that's the problem.

Thanks.

1 2 Page 1 of 2