Maple 2023 Questions and Posts

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

I have a result:

u1 = RootOf(4*_Z^2 + (4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) - 4)*_Z + 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1)^2 - 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) + 1)

I tried: convert(u1,'radical');

but it reported error Error, (in sprintf) too many levels of recursion

how can I convert it to this form?

Thanks!!

There appears to be a bug with Maple 2023.2 which will remove units from physical constants.

AddConstant(Solar_equatorial_radius, symbol = r[e,Sol], value = 696342., uncertainty = 65., units = km) :

AddConstant(Solar_flattening, symbol = f[Sol], value = 0.000009) :

AddConstant(Solar_polar_radius, symbol = r[p,Sol], derive = -r[e,Sol]*(f[Sol] - 1)) :

AddConstant(Solar_nonradius, symbol = x[Sol], derive = f[Sol]*r[e,Sol]) :

In the example here, "GetUnit(Constant(r[p,Sol]))" will return "1" and "GetUnit(Constant(x[Sol]))" will return "m".

The only workaround is to not save dimensionless quantities as physical constants or otherwise at least some constants derived from a dimensionless constant will also be dimensionless.

Adding "units = 1" to "AddConstant" does not help.

Hello! We are using Maple to evaluate numerically expressions with very high precision and we are finding very strange results. After some playing with simple models we have come to conclusion that there might be a bug in Maple 2023. Here is a clean example of what we are experiencing. Plotting the function x*exp(-x) in [0,20]. Clearly the function cannot be negative in that interval! However, if Digits is set to 40 the results may be whatever. Any ideas? Thank you very much. 

Is there a way to remove a unit symbol?  "AddUnit" allows to add additional symbols or change the default symbol, but I don't see any way to remove symbols?

A good example is for the hectare.  Maple 2023 uses "a" as the default symbol for the are, except that the unit symbol "a" does not allow using SI prefixes because the peta- unit prefix then conflicts with the pascal ("Pa").  I can use "AddUnit" to change the default symbol for the are from "a" to "are" but I still cannot enable SI prefixes unless the symbol "a" is removed from the symbol set.  This way hectares ("hare") and petares ("Pare") can be used.

I don't see a way to nondestructively/temporarily delete units either ("RemoveUnit").  Deleting the unit "are" and then recreating it as a new unit with the symbol "are" would solve the same problem.

I just saw that there already exists a separate "hectare" unit with the symbol "ha" which presumably also needs to be removed in order to enable SI prefixes for "are".  This is just one example but a general way to remove units and/or unit symbols should be very helpful.

Is there a way to import an MPL file from a URL?

Import("https://www.nicolesharp.net/testbox/test.mpl");

Using the "Import" command on Maple 2023.2 appears to only import the MPL as plaintext and doesn't recognize any of the Maple instructions from the MPL file.

Using the "Get" command with the URL package doesn't do anything useful either.

with(URL) : Get("https://www.nicolesharp.net/testbox/test.mpl");

Any one knows if this is a new bug in int()? It happens only when kernelopts('assertlevel'=2): is on.

Using Maple 2023.2.1 on windows 10.

edit: Found another integral. #3 below. The difference now is that this third integral is solved completely when removing Physics update/lib from libname. While the first two are not solved. But all three now do not give exception with the updated libname. New attachment is below.

ps. just in case I also just send bug report to Maplesoft.  

restart;

201864

interface(version)

`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1641. The version installed in this computer is 1637 created 2023, November 29, 17:28 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2023\Physics Updates\lib\`

kernelopts('assertlevel'=2):

integrand:=(-b*x+a)^(4/3)*(b*x+a)^(8/3);
int(integrand,x,method=_RETURNVERBOSE);

(-b*x+a)^(4/3)*(b*x+a)^(8/3)

Error, (in IntegrationTools:-Indefinite:-ExpandAndMapOverSums) assertion failed, Invalid input for ExpandAndMapOverSums

integrand:=(-b*x+a)^(4/3)*(b*x+a)^(4/3);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x+a)^(4/3)*(b*x+a)^(4/3)

Error, (in IntegrationTools:-Indefinite:-ExpandAndMapOverSums) assertion failed, Invalid input for ExpandAndMapOverSums

integrand:=(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2)

Error, (in IntegrationTools:-Indefinite:-ExpandAndMapOverSums) assertion failed, Invalid input for ExpandAndMapOverSums

libname

"C:\Users\Owner\maple\toolbox\2023\Physics Updates\lib", "C:\Program Files\Maple 2023\lib"

restart;

201864

libname:="C:/Program Files/Maple 2023/lib"

"C:/Program Files/Maple 2023/lib"

kernelopts('assertlevel'=2):
integrand:=(-b*x+a)^(4/3)*(b*x+a)^(8/3);
int(integrand,x,method=_RETURNVERBOSE);

(-b*x+a)^(4/3)*(b*x+a)^(8/3)

["risch" = -(1/1215)*(243*b^4*x^4+324*a*b^3*x^3-450*a^2*b^2*x^2-804*a^3*b*x+47*a^4)*(-b*x+a)^(1/3)*(b*x+a)^(2/3)*((-b*x+a)^2)^(1/3)/(b*((b*x-a)^2)^(1/3))+(int((256/729)*a^5/((b*x-a)^2*(b*x+a))^(1/3), x))*((-b*x+a)^2)^(1/3)*((b*x-a)^2*(b*x+a))^(1/3)/((-b*x+a)^(2/3)*((b*x-a)^2)^(1/3)*(b*x+a)^(1/3)), FAILS = ("gosper", "lookup", "derivativedivides", "default", "norman", "trager", "meijerg", "elliptic", "pseudoelliptic", "parallelrisch", "parts")]

integrand:=(-b*x+a)^(4/3)*(b*x+a)^(4/3);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x+a)^(4/3)*(b*x+a)^(4/3)

["risch" = (3/55)*x*(-5*b^2*x^2+13*a^2)*(-b*x+a)^(1/3)*(b*x+a)^(1/3)*((-b*x+a)^2)^(1/3)/((b*x-a)^2)^(1/3)+(int((16/55)*a^4/((b*x-a)^2*(b*x+a)^2)^(1/3), x))*((-b*x+a)^2)^(1/3)*((b*x-a)^2*(b*x+a)^2)^(1/3)/((-b*x+a)^(2/3)*(b*x+a)^(2/3)*((b*x-a)^2)^(1/3)), FAILS = ("gosper", "lookup", "derivativedivides", "default", "norman", "trager", "meijerg", "elliptic", "pseudoelliptic", "parallelrisch", "parts")]

integrand:=(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2)

["default" = (1/7)*(-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)*((b/a)^(1/2)*b^4*x^9-4*(b/a)^(1/2)*a^2*b^2*x^5+4*a^4*((-b*x^2+a)/a)^(1/2)*((b*x^2+a)/a)^(1/2)*EllipticF(x*(b/a)^(1/2), I)+3*(b/a)^(1/2)*a^4*x)/((-b^2*x^4+a^2)*(b/a)^(1/2)), "risch" = (1/7)*x*(-b^2*x^4+3*a^2)*(-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)+(4/7)*a^4*(1-b*x^2/a)^(1/2)*(1+b*x^2/a)^(1/2)*EllipticF(x*(b/a)^(1/2), I)*((-b*x^2+a)*(b*x^2+a))^(1/2)/((b/a)^(1/2)*(-b^2*x^4+a^2)^(1/2)*(-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)), "elliptic" = (-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)*(-(1/7)*b^2*x^5*(-b^2*x^4+a^2)^(1/2)+(3/7)*a^2*x*(-b^2*x^4+a^2)^(1/2)+(4/7)*a^4*(1-b*x^2/a)^(1/2)*(1+b*x^2/a)^(1/2)*EllipticF(x*(b/a)^(1/2), I)/((b/a)^(1/2)*(-b^2*x^4+a^2)^(1/2)))/(-b^2*x^4+a^2)^(1/2), FAILS = ("gosper", "lookup", "derivativedivides", "norman", "trager", "meijerg", "pseudoelliptic", "parallelrisch", "parts")]

Download jan_13_2024_integrationTools_expand.mw

GraphTheory:-IsReachable can be used to "determine if there is a path between two vertices", and GraphTheory:-ShortestPath can be used to "find a path between two vertices with minimum distance", but which command can be used to "enumerate all (simple) paths from one node to another" like MatLab's allpaths in Maple? 

For instance, I would like to enumerate (not simply count) at most 3483192 paths with total weights at least 45 in the graph constructed from  that begin at node 30 and end at node 29
There exists a practically ready-made procedure  (where only a limited subset of its local variable  is needed) in a previous question. Nevertheless, after waiting for a quarter of an hour, the evaluation still did not terminate and I had to abort it manually. Meanwhile, MatLab completed the same computation within one minutes: 

So, how to list those 1008252 paths (without knowing the actual total number beforehand) faster in Maple?

Note. MatLab also has a built-in function allcycles, whose efficient Maple equivalent has been proposed in How to obtain all cycles in a graph from its cycle basis - MaplePrimes, yet I cannot find an analogue to MatLab's allpaths

For instance, here is a worksheet where I have replaced 1 + 2; with 1 + 1; in advance: 
 

1+1 = 21+1 = 3

1 + 1;

2

(1)

1 + 1;

3

(2)


 

But without re-evaluations, how do I know the second input and the fourth input have been stealthily substituted?

In a Mma notebook, this can be displayed by shadowing the input label: 

But in order to detect changes, which method should be used in Maple?
(Note that I do not mean that no changes are allowed. So I don't think setting the “editable” property is a workaround.)

`lprint` is officially interpreted as “linear printing of expressions”, but in the most recent release, its output looks just like "left printing" (under the default zoom 100%), 

while in some legacy version, `lprint` printed expressions not only on the left but also on the right. 

How to render `lprint` print its arguments not only on the left half?
Although I believe that similar questions must have been asked before, I cannot find such a question. 

Code: 

lprint(_bigPi):
showstat(ellipsoid)

I've reported this to Maplesoft 6 months ago.

I was wondering if someone with beta version of 2024 could check if these are fixed? (if one is allowed to do so). As these errors keep breaking my program. (not possible to trap).

436

interface(version);

`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1637 and is the same as the version installed in this computer, created 2023, November 29, 17:28 hours Pacific Time.`

ode:=diff(y(x),x) = (x*y(x)+x^3+x*y(x)^2+y(x)^3)/x^2;
sol:=exp(3*sum(1/(9*_R^2-1)*ln((-_R*x+y(x)-1/3*x)/x),_R = RootOf(27*_Z^3-9*_Z+29)))-c__1*exp(x) = 0;
odetest(sol,ode);

diff(y(x), x) = (x*y(x)+x^3+x*y(x)^2+y(x)^3)/x^2

exp(3*(sum(ln((-_R*x+y(x)-(1/3)*x)/x)/(9*_R^2-1), _R = RootOf(27*_Z^3-9*_Z+29))))-c__1*exp(x) = 0

Error, (in simplify/RootOf) too many levels of recursion

ode:=diff(u(x),x)-1/2*(2*a*u(x)^3+u(x)+2*b)/x = 0;
sol:=2*sum(1/(6*_R^2*a+1)*ln(u(x)-_R),_R = RootOf(2*_Z^3*a+_Z+2*b))-1/2*ln(x)-_C1 = 0;
odetest(sol,ode);

diff(u(x), x)-(1/2)*(2*a*u(x)^3+u(x)+2*b)/x = 0

2*(sum(ln(u(x)-_R)/(6*_R^2*a+1), _R = RootOf(2*_Z^3*a+_Z+2*b)))-(1/2)*ln(x)-_C1 = 0

Error, (in simplify/RootOf) too many levels of recursion

 

Download in_simplify_rootof_too_many_level_of_recursion_jan_6_2024.mw

Maple dsolve allows one to specify the algorithm to use to solve the ode. But sometimes it is very tricky to figure the syntax,

This ode 

ode:=diff(y(x),x)*y(x)+a*x*y(x)+b*x^3=0;
DEtools:-odeadvisor(ode);

Gives

               [[_homogeneous, `class G`], _rational, [_Abel, `2nd type`, `class A`]]

I wanted now to call dsolve telling dsolve to use the first method above. But how? All the following syntax failed for me

sol:=dsolve(ode,['_homogeneous, `class G`']);
sol:=dsolve(ode,'[_homogeneous, `class G`]');

All return method not found .

I am sure I am using wrong syntax but do not know what the correct one should be.

infolevel[dsolve]:=5;
sol:=dsolve(ode);

gives

Methods for first order ODEs:
--- Trying classification methods ---
trying a quadrature
trying 1st order linear
trying Bernoulli
trying separable
trying inverse linear
trying homogeneous types:
trying homogeneous G
<- homogeneous successful

With long solution printed now OK. 

When using just '[homogeneous]' it works

sol:=dsolve(ode,'[homogeneous]');

It gives same solution as default case.

What is the correct syntax to tell dsolve to use specific method [_homogeneous, `class G`] ? i.e. I need to add class G

The reason I ask is becuase Maple have different kind of homogeneous method as described here

Maple 2023.2.1 on windows 10

It seems that applyrule cannot handle variable numbers of arguments, and I cannot use something like 

applyrule(f(u::anything, v::seq(anything)) = g(v, u), [f(x, y, z), f(x, y, z, t)]);
 = 
                  [f(x, y, z), f(x, y, z, t)]

Strangely, Maple does support the identical patterns in parameter declarations: 

eval([f(x, y, z), f(x, y, z, t)], f = ((u::anything, v::seq(anything)) → g(v, u)));
 = 
                  [g(y, z, x), g(y, z, t, x)]

So the two designs do not appear coherent. Should this be regarded as a "bug" in a sense? 

Of course there is no need to use the  modifier; here it is enough to use 

evalindets([f(x,y,z),f(x,y,z,t)],'specfunc'(anything,f),w->g(op(2..(),w),op(1,w))):
use f = MakeFunction('g(args[2 .. ], args[1])') in [f(x, y, z), f(x, y, z, t)] end:
use f = unapply('g(_rest, _w)', [_w::anything]) in [f(x, y, z), f(x, y, z, t)] end:

But the problem is, why is there such inconsistency described above? 

Given equation 

We see this can be simplified to 

In Mathematica, I just need to tell it the denominator of the left side is not zero for it to do the simplification

The same thing in Maple did not work:

eq:= (y-2*x)^3/( (y-x)^2 * x ) = a/x;
the_denom:= denom(lhs(eq));
simplify(eq) assuming the_denom <>0

No change. 

I am doing this in code not by looking at the screen and simply wanted to eliminate common terms on both sides of equation. I can in code obtain the denominator of the LHS and RHS and add assumption. But since I do not know what if any common terms are on both sides, it is not easy to use elminate.

I see code at https://www.mapleprimes.com/questions/227043-How-To-Automatically-Cancel-Any-Common which actually worked on this and it did automatically elminate x from both sides.

But my question is: why Maple does not do it using simplify with the assumption given?  Tried simplify with size and no change.

I am looking for the simplist method to elminate common terms on both sides of equation. Is the link above the only way to do this in Maple? May be there is something simpler in recent Maple versions?


#code from https://www.mapleprimes.com/questions/227043-How-To-Automatically-Cancel-Any-Common

restart;

eq:= (y-2*x)^3/( (y-x)^2*x) = a/x;
TT := simplify(expand((eq)),size):
if lhs(TT)::`*` and rhs(TT)::`*` then
  TTT := map[2](map,freeze,TT);
  comm := `*`(op({op(lhs(TTT))} intersect {op(rhs(TTT))}));
  new := simplify(thaw(lhs(TTT)/comm=rhs(TTT)/comm));
end if:
new

May be this should be part of Maple build in functions and used by simplify? 

Update 

I just hit on a way to do this automatically with no assumption of anything. The idea is to simply rewrite the equation, like this

restart;

eq:= (y-2*x)^3/( (y-x)^2 * x ) = a/x;
numer(lhs(eq))*denom(rhs(eq)) /  (denom(lhs(eq)) *numer(rhs(eq)))=1;

You see, the common term on both sides is automatically gone!   I need to test this more. 

To moderator: if you think this question is duplicate, feel free to delete it.

Although I still prefer applyrule (as evalindets/subsindets is not as intuitive as applyrule),  I have heard that it is regarded as being more or less antiquated in modern Maple. I notice that a lot of (yet not all) examples given in the help pages of evalindets/subsindets can be reformulated by applyrule, but does any use of applyrule also correspond to using evalindets/subsindets? And if so, how to equivalently rewrite those transformation rules (especially complicated ones like nested function applications) in the syntax of evalindets/subsindets?

Given an expression expr, and symbol, say I wanted to check that only shows as argument to a specific Maple function. In this case, say ln() just an example but this can be any other function.

But if shows up in the expression but not as argument to ln() then I want to detect this also. So the function is passed the expression and the symbol name, and it returns true or false. 

True means the symbol only shows inside ln and false means it found in the expression but not inside ln()

I can find all indets where the symbol shows inside the function. But the problem is how to find if the symbol shows outside of the function?

I think I need to use depends() somehow. But could not figure out how do far. Below is the code I have and few test examples and the result expected.

is_symbol_inside_func_only:=proc(expr::anything,f,y::symbol)::truefalse;
local the_type:=`Or`(     
          'specfunc( `&*`(anything,identical(y)), f )',  
          'specfunc( identical(y), f )'  ,
          'specfunc( `&+`(anything,identical(y)), f )'
          );
local T;
T:=indets(expr, the_type );
print(T);

#need to check that y does not show any where inside expression unless 
#as argument to f

RETURN(true); #or RETURN(false);
end proc:

Here some test cases

expr:=3*ln(1+y)+ln(3*y)*y+ln(y)+cos(7*y);
is_symbol_inside_func_only(expr,ln,y); #should return false

expr:=3*ln(1+y)+ln(3*y);
is_symbol_inside_func_only(expr,ln,y); #should return true

expr:=ln(y)+ln(3*y)+cos(y);
is_symbol_inside_func_only(expr,ln,y); #should return false


expr:=3+cos(y);
is_symbol_inside_func_only(expr,cos,y); #should return true

expr:=y+ln(y);
is_symbol_inside_func_only(expr,ln,y); #should return false

expr:=-1/2*ln(y-1)+1/3*ln(y)+1/6*ln(y-3):
is_symbol_inside_func_only(expr,ln,y); #should return true

some context: I wanted to apply exponential to an expression to convert all ln(y)+ln(1+y)+...  to exp(...) to make it easy to process.

But wanted to do this ONLY if all terms that has are functions on ln otherwise, I will not raise it to exp in this case. The expression will always have the symbol in it. So need to worry about this case. 

Update

After asking the question, I thought about using selectremove and it seems to do what I want. But need to test it more.

is_symbol_inside_func_only:=proc(expr::anything,f,y::symbol)::truefalse;
local the_type:=`Or`(     
          'specfunc( `&*`(anything,identical(y)), f )',  
          'specfunc( identical(y), f )'  ,
          'specfunc( `&+`(anything,identical(y)), f )'
          );
local hasF,nothasF;
hasF,nothasF:=selectremove(hastype,expr,the_type);
if has(nothasF,y) then
   RETURN(false);
else
   RETURN(true);
fi;
end proc:

Here is the result

expr:=3*ln(1+y)+ln(3*y)*y+ln(y)+cos(7*y):
is_symbol_inside_func_only(expr,ln,y); #should return false

expr:=3*ln(1+y)+ln(3*y):
is_symbol_inside_func_only(expr,ln,y); #should return true

expr:=ln(y)+ln(3*y)+cos(y):
is_symbol_inside_func_only(expr,ln,y); #should return false

expr:=3+cos(y):
is_symbol_inside_func_only(expr,cos,y); #should return true

expr:=y+ln(y):
is_symbol_inside_func_only(expr,ln,y); #should return false

expr:=-1/2*ln(y-1)+1/3*ln(y)+1/6*ln(y-3):
is_symbol_inside_func_only(expr,ln,y); #should return true


 

Update

I just found my function has a bug. I added one more test case. so you can ignore my function and use any of the other ones given in the answers below.

 

Maple 2023.2.1

First 6 7 8 9 10 11 12 Last Page 8 of 30