MaplePrimes Questions

Hi,

I am exploring the counting functions available in Maple, and I am searching for how to enumerate arrangements with repetition and combinations with repetition ? ThanksCombinatoireTEST.mw

How to handle these errors in plotting the solutions?compare.mw

Currently, the argument is mapped to the HUE coloring scheme (I guess)

plots:-complexplot3d(z, z = -2 - 2*I .. 2 + 2*I, title = -ln(1/c) - ln(c), orientation = [-90, 0, 0])

This makes it difficult to distinguish the sign of the argument close to the positive real axis (just to give an example). To increase contrast I thought about alternatives: Linear ramping from 0 to 2pi from one color to another (similar to phase wrapped images) or a stepped color scheme (in pi/4 increments for example).

I tried color=argument(z/2/Pi) but this did work.

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

I recently stumbled across this video Why do calculators get this wrong

At some point, the author (Matt Parker) mentions the Farey's algorithm as a way to get a rational approximation of a number between 0 and 1.
Just for fun I applied this algorithm to build increasingly accurate rational approximations of Pi (see here Rational_approximation.mw). 
The rational approximation 

convert(evalf(Pi), rational);
                             104348
                             ------
                             33215 

is one of those the Farley's algorithm returns.

Is this pure chance, or does Maple indeed use the Farley's algorithm?
If not, what algorithm does convert/rational use?

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

The automatic transformation below is a rule in Maple

a := 3:
b := a^2
                               9

that we can prevent using single quotes for instance.

When a is a random variables this becomes

a := Statistics:-RandomVariable(Uniform(0, 1));
                               _R
b := a^2
                                2
                              _R 

# Thus, for instance
Statistics:-Mean(b);
                               1
                               -
                               3



Of course you do know that b is defined as a^2, but if you present this to a student it will be puzzled by the output of b containing _R and not a. Of course you can explain it why this happens, but if b has a more complex expression inoking several random variables, it becomes almost impossible to understand what its display means as it contains only names like _R, _R0, ...

To avoid this difficulty a possibility is to reverse the order of the operations this way

a := 'a':
b := a^2;
                                2
                               a 
a := Statistics:-RandomVariable(Uniform(0, 1));
                              _R
# And then
Statistics:-Mean(b);
                               1
                               -
                               3


But this become quite tricky in some situations, for instance

restart:
b := a^2 - Mean(a)^2
                          2          2
                         a  - Mean(a) 
a := Statistics:-RandomVariable(Uniform(0, 1)):

# The expected result can be got this way
eval(b, Mean = Statistics:-Mean):
Statistics:-Mean(%);
                               1 
                               --
                               12


Or, if you upload the Statistics package

restart
with(Statistics):
b := a^2 - ':-Mean'(a)^2
                          2          2
                         a  - Mean(a) 
a := RandomVariable(Uniform(0, 1)):
eval(b, ':-Mean' = Mean):
Mean(%);
                               1 
                               --
                               12


As we preserved a comprehensible expression for b in the last two examples, this come at the expense of a more complex calculation of the final result.

My goal is the quite simple:  I would like to preserve as long as possible the original names of the random variables (a in the examples above), and get the desired result without never make their "aliases" _R, _R0, _R1, .... appear in intermediate outputs.
The strategy I use is sketched in the file  Manipulation_of_random_variables.mw

Do you have another idea to achieve this goal?

In fact this question could be also stated "Given a random variable _R, could it be possible to recover the name it has been assigned to. I thought to something like this:

restart:
a := Statistics:-RandomVariable(Uniform(0, 1));
b := Statistics:-RandomVariable(Uniform(0, 1));
c := 1:
d := [$1..3]:
                               _R
                              _R0

# This seems correct
FromNames2RV := [anames(RandomVariable)] =~ eval([anames(RandomVariable)]);
                       [b = _R0, a = _R]

# Unfortunately further use of FromNames2RV evaluates its left hand sides
FromNames2RV 
                      [_R0 = _R0, _R = _R]


TIA

restart;
with(geometry);
with(plots);
_EnvHorizontalName = 'x';
_EnvVerticalName = 'y';
point(A, -3, 9);
point(B, -5, 0);
point(C, 6, 0);
xA := -3;
yA := 9;
xB := -5;
yB := 0;
xC := 6;
yC := 0;
triangle(ABC, [A, B, C]);
midpoint(M2, A, C);
midpoint(M1, B, C);
midpoint(M3, A, B);
coordinates(M1);
coordinates(M2);
coordinates(M3);
segment(sA, [A, M1]);
segment(sB, [B, M2]);
segment(sC, [C, M3]);
centroid(G, ABC);
midpoint(J1, A, G);
midpoint(J2, B, G);
midpoint(J3, C, G);
coordinates(J1);
coordinates(J2);
coordinates(J3);
zA := xA + yA*I;
zB := xB + yB*I;
zC := xC + yC*I:
diff((z - zA)*(z - zB)*(z - zC), z)*I;);
allvalues(%, z)
;I am trying to find focus of Steiner ellipse with Marden's theoreme. Thank you.

I'm stuck on trying to convert something like xi^p to H(p)*xi^p. p is an integer.

The variable I am using is xi and I want to just insert an H(p) term based on the order of xi (p). I want to do it for any occurence of xi. I don't want to convert other variables/symbols.

It would seem applyrule should work, except it goes into an endless loop.

I've tried other combinations but just don't seem to be able to figure out the right one.

It seems to me that I could try some sort of subsindet where the transformer checks the variable name, but that seems inefficient.

I'm going to guess there is a simple solution!

Thanks.

What would it take to generate all subgroups (permutation group representation) of Symmetric(6)?

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

Considering galois group of P is Symmetric(6), shoudn't the answer be trivial and instant in this example?

P := s^6 + s^3 - s + 1;
galois(P);
(evala@AFactor)(P);
PolynomialTools[Split](P, s, 'SF');

Is there a command which will analyze a procedure and list all unreferenced global and local sequence entries?

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

First 85 86 87 88 89 90 91 Last Page 87 of 2374