Question:How to obtain degree of x to the power which contains symbol?

Question:How to obtain degree of x to the power which contains symbol?

Maple 2023

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

﻿