## How to obtain degree of x to the power which conta...

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

## Maple 2023.0 bug?...

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.

## How to compute definite integral...

> 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)

## Why is zip slower than ~?...

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);  >  memory used=0.62GiB, alloc change=1.21GiB, cpu time=51.35s, real time=14.77s, gc time=42.55s  >  memory used=0.52GiB, alloc change=-4.00MiB, cpu time=53.88s, real time=16.25s, gc time=44.51s  >  (1)  > 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? ## A request for the implementation of the inverse... by: Maple 2023 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.  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 ## Why is map slower than ~?... Asked by: 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):
 >

# Compute a generalized outer product of  and  without using the inefficient ArrayTools:-GeneralOuterProduct.

 >

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

 >

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

 > evalb(p2 = p4);

 >

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?

## problem translating string to latex. Using standar...

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 \"  ?

## how to make singular use same letter Z for integer...

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

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.

## Why can't the commands in these document blocks be...

ODE for electrical circuit (right click on Documentblock, unselect show command does not work. Command still visble)

 (1)

ODE for motor (toggle Documentblock, unselect show command is only effective on equations  3 and 4)

 (2)

Isolate  and taking the derivative

 (3)

 (4)

## strange characters in Maple's code editor on .mpl ...

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.

## Task insertion doesn't work anymore....

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.

## is it possible to identify mserver.exe in task man...

I always run with the option "create a new engine for each document". which is a very nice feature in Maple.

The problem is that, when I have say 5 worksheets open and running, and one of them them hangs, I need to kill mserver.,exe from the task manager which is running this worksheet.

most of the times I end up killing the wrong mserver.exe. I can sometimes guess by the CPU it is using. But if I have two running with high CPU it is not possible guess.

There is no ID or anything associated with the name. It will be nice if each process has in its name an ID which is also displayed in the worksheet bottom bar so one knows. This ID could be simply some random number. So the display will show  mserver-13847,exe ,   mserver-82739,exe and so on. And this name will be automtically displayed at the bottom bar of the worksheet where all time used, cpu used and memory used and so on is now displayed.  This will be a nice feature to add to Maple.

If this is not possible, how about just displaying the PID (process ID)  of the mserver.exe connected to the worksheet in the bottom bar? This will also work, as task manager/details lists a processes with the PID there, so it will make it easy to find.

Meanwhile, while waiting for Maple 2033 to hopefully implement this feature, does anyone know of a method to help find which mserver.,exe is connected to which specific worksheet?

Windows 10.

## int displays large output on the screen on same co...

Do others see this problem? I do not understand what is going on. I am seeing this problem on many integrals

restart;
int(integrand)
#Large output displayed
#echo the input
int(...)
#Large output displayed
#echo the input
int(...)
#echo the input only. Large output gone
int(...)
#echo the input only. Large output gone

restart;
int(...)
#Large output displayed
#echo the input
int(...)
#echo the input only. Large output gone
int(...)
#echo the input only. Large output gone



In all the above, it is the same command used.

i.e. first time (sometimes needs two times), Maple displays large out. But looking at the end of this output, the very last line, we see the same integral/command is returned.

But second time and any attempt after that, it no longer gives that large output, but returns back/echos the command on the screen only.

Attached is worksheet showing this. This is new behaviour in Maple 2023 and I am baffled by it. Do others see it? Why does it happen. I will report it if others confirm it. I just wanted to make sure first it is not just me seeing this.

Is it possible the large output is side effect and is being printed by error to the screen by internal Maple code? But why does it stop the second/third time?

 > interface(version);

 > restart;
 > int((b*g*x+a*g)^2/(A+B*ln(e*(b*x+a)/(d*x+c))),x)

 > int((b*g*x+a*g)^2/(A+B*ln(e*(d*x+c)/(b*x+a))),x)

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

 > int((b*g*x+a*g)^2/(A+B*ln(e*(d*x+c)/(b*x+a))),x)

 > int((b*g*x+a*g)^2/(A+B*ln(e*(d*x+c)/(b*x+a))),x)

 > int((b*g*x+a*g)^2/(A+B*ln(e*(d*x+c)/(b*x+a))),x)

 > restart;
 > int((b*g*x+a*g)^2/(A+B*ln(e*(d*x+c)/(b*x+a))),x)

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

Warning, if e is meant to be the exponential e, use command/symbol completion or palettes to enter this special symbol, or use the exp function

 > int((b*g*x+a*g)^2/(A+B*ln(e*(d*x+c)/(b*x+a))),x)

 >
 >

Update

Do you want to see something more bizzar? Try this command on same integral

restart;
res:=int((b*g*x+a*g)^2/(A+B*ln(e*(b*x+a)/(d*x+c))),x,method=_RETURNVERBOSE)


It prints to the screen results with ~ all over. But this seems to be internal leaked output and not part of the actual output returned.

By issuing the command as follows instead

restart;
res:=int((b*g*x+a*g)^2/(A+B*ln(e*(b*x+a)/(d*x+c))),x,method=_RETURNVERBOSE):


notice the at the end!  I still see the same output as above printed displayed.

This tells me this is a leaked printout from an internal integration function.

Could others confirm this?

## why Maple 2023 return "undefined" embbeded inside ...

First issue I see in Maple 2023 integrate

Example 1

restart;
int( (e*x+d)^(3/2)*(c*x^2+a)^(3/2),x)


Example 2

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


Example 3

restart;
int((c*x^4+b*x^2)^(3/2)/x^(3/2),x)


Worksheet below for 2023 and also for 2022.2 showing this did not have this problem in 2022.2. Internally for me, this cause other problem when post-processing this, that is why I found it. Any one knows what caused it?  Maple 2022.2 result is much longer, but it does have this "undefined" issue in the result.

 > interface(version);

 > restart;
 > int( (e*x+d)^(3/2)*(c*x^2+a)^(3/2),x)

 > restart;
 > int((1+x)^(3/2)*(x^2-x+1)^(3/2),x);

 > restart;
 > int((c*x^4+b*x^2)^(3/2)/x^(3/2),x)

 >

 > interface(version);

 > restart;
 > int( (e*x+d)^(3/2)*(c*x^2+a)^(3/2),x)

 > restart;
 > int((1+x)^(3/2)*(x^2-x+1)^(3/2),x);

 >