Maple 2023 Questions and Posts

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


I recently got access to a 12-core Intel MacPro with 64 GB main memory. This motivated me to try parallel programming again, even though in prior years I have never been successfull. The project I am trying to do is particle tracking through a circular accelerator, an embarassingly parallel problem in the sense that you can track n particles in parallel through your machine for many turns and then gather up the results for analysis. The function describing the tracking is a 6-component polynomial function acting on 6-vectors and yielding a 6-Vector as a result. Each accelerator component (magnet, drift section, rf, ...) is described by such a function. I am simplifying this a bit here, but in the problem at hand this is what I am doing. The point is that each particle gets treated independently from the others, hence parallelization should be trivial.

Using an existing package (Lattice, which I published with Maple) as framework I set this up such that the tracking proc for n turns of one particle in the accelerator is a member of a module. This module is in the body of a proc and gets returned when the proc is called, essentially instantiating the tracking object and assigning it to a Vector with as many elements as I have particles to track. The tracking function returns a 6-Vector with the coordinates after all turns are complete. 
A separate proc does the instantiation of all tracking objects, gives each one its particle number (from a Beam object it is being given) and sends it off using Threads:-Create. It then waits until every task is done (using Threads:-Wait) and assembles the result in another Beam object which it returns. Please refer to the enclosed Maple worksheet for how it is done.

This actually all appears to work. MacOS is 15.7.2 (Sequoia); Maple is 2023.2. The results are identical both parallel and serial.

The "interesting" result however, is that usage of the available CPU cores saturates at about 4. In the graph shown below, the green line shows the CPU usage of the mserver process, and it saturates between 400 & 500%, actually going down to 360% as more particles get added. 100% is one core, so I am never getting more than about 4 cores to work for me. Correspondingly, the no. of seconds per particle goes up from about 3 s (particle 1 to 4) up to about 15 s/particle, settling at about 10 s/particle as 12 particles are approached. Below is a graph against no. of particles (n) of running time (red), CPU time (dark blue), CPU usage (yellow) and # or mkernel threads (green). 

Bottom line: I am only getting 4 cores out of the 12. Process limits of MacOS (ulimit -a) do not indicate any limit that would cause this (and I have had build jobs that would merrily use all 12 cores).

Is there a limit in Maple that prevents using all available cores? Am I doing something inefficient that could cause this?? This is the first time I actually got parallel operations in Maple to work, so I am happy about that, but my happiness is tempered by not getting it to work at the level I was aiming for. I did google around a bit and found some prior conversations on MP (mostly involving @acer and @Carl Love) about parallel threads which indicated that (a) environment variable OMP_NUM_THREADS should be set and (b) that numcpus can only be set at the very beginning of a Maple session (which I interpret as "right after firing up Maple"). Did both (and verified the settings were in) but no change in behaviour of this code; I only get four cpu cores to work.

Thanks,

Mac Dude

Parallel_tracking_attempt.mw

Edit: Added graph, fixed up graph.

I just installed Maple 2023 on a MacPro running macOS Sequoia 15.7.2. Update to latest .version and activation worked without a hitch.

When I try to run it from the Finder it immediately puts up a dialog saying something like "Java not found". There is a webpage by Maplesoft addressing this, but it is completely uninformative and unhelpful.

I can get Maple to run using the cli (in Terminal) opening the Maple 2023 .app file, at which point Maple (running the standard GUI) works just as one would expect. So it is not a crisis but I'd like to be able to open it through the Finder as well. The Maple .app folder appears to have all the Java stuff in it, and clearly it is somewhere.

Anyone seen and solved this before?

Thanks,

Mac Dude

In space, how can we find the coordinates of the three vertices of a triangle that is neither right-angled nor isosceles, such that the coordinates of its vertices, the coordinates of the foot of an angle bisector, the length of that angle bisector are all integers, and the lengths of the sides of the triangle are integers? 

I tried 

https://drive.google.com/file/d/1xOMxTCv3lC9RiKpwazerQ3D6WxeXLwJ-/view?usp=sharing

I this code, I do by my hand (x - ptA[1])^2 + (y - ptA[2])^2 + (z - ptA[3])^2 = r^2;

restart;
with(geom3d);
ptA := coordinates(point(A, 1, -4, 3));
point(B, -3, 2, 5);
r := distance(A, B);
Equation(sphere(S, [A, r], [x, y, z]));
(x - ptA[1])^2 + (y - ptA[2])^2 + (z - ptA[3])^2 = r^2;

When I used Equation(sphere(S, [A, r], [x, y, z])); I got


Is there a function to convert Equation(sphere(S, [A, r], [x, y, z])); to get the result

I have this code

restart;
with(geometry);
with(StringTools);
interface(worksheetdir);
currentdir(%);
toX := e -> latex(e, 'output' = 'string');
s := toX(e);
s := StringTools:-Substitute(s, "[", "(");
s := StringTools:-Substitute(s, "]", ")");
s := StringTools:-SubstituteAll(s, ",", ";");
s := StringTools:-SubstituteAll(s, "\\frac", "\\dfrac");
s := StringTools:-SubstituteAll(s, "-\\infty", "#@#");
s := StringTools:-SubstituteAll(%, "\\infty", "+\\infty");
s := StringTools:-SubstituteAll(%, "#@#", "-\\infty");
printf("\\documentclass[12pt]{article}\n");
printf("\\usepackage{amsmath,amssymb}\n");
printf("\\usepackage{enumitem}\n");
printf("\\begin{document}\n\n");
f := x -> (x^2 + 4*x + 7)/(x + 1);
df := simplify(diff(f(x), x));
cuctri := sort([solve(df = 0, x)], key = evalf);
g := simplify(diff(df, x));
xcd := rhs(solve([df = 0, g(x) < 0], x)[1]);
xct := rhs(solve([df = 0, 0 < g(x)], x)[1]);
ycd := simplify(f(xcd));
yct := simplify(f(xct));
mycd := coordinates(point(A, xcd, ycd));
myct := coordinates(point(B, xct, yct));
L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")];

printf("\\begin{enumerate}[label=\\arabic*)]\n");
for item in L do
    printf("\\item %s\n", item);
end do;
printf("\\end{enumerate}\n\n");

I got

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = \frac{x^{2}+4 x +7}{x +1}$.
\item Its derivative is: $y' = \frac{x^{2}+2 x -3}{\left(x +1\right)^{2}}$.
\item The maximum point of the graph  $ [-3, -2]$.
\end{enumerate}

I want to $ (-3; -2)$, not $ [-3, -2]$. How can I make the function toX apply to the whole document?

I tried

restart;
with(geometry);
with(StringTools);
interface(worksheetdir);
currentdir(%);
toX := proc(e) local s; s := latex(e, 'output' = 'string'); s := Substitute(s, "[", "("); s := Substitute(s, "]", ")"); s := SubstituteAll(s, ",", ";"); s := SubstituteAll(s, "\\frac", "\\dfrac"); s := SubstituteAll(s, "-\\infty", "#@#"); s := SubstituteAll(s, "\\infty", "+\\infty"); s := SubstituteAll(s, "#@#", "-\\infty"); return s; end proc;
printf("\\documentclass[12pt]{article}\n");
printf("\\usepackage{amsmath,amssymb}\n");
printf("\\usepackage{enumitem}\n");
printf("\\begin{document}\n\n");
f := x -> (x^2 + 4*x + 7)/(x + 1);
df := simplify(diff(f(x), x));
cuctri := sort([solve(df = 0, x)], key = evalf);
g := simplify(diff(df, x));
xcd := rhs(solve([df = 0, g(x) < 0], x)[1]);
xct := rhs(solve([df = 0, 0 < g(x)], x)[1]);
ycd := simplify(f(xcd));
yct := simplify(f(xct));
mycd := coordinates(point(A, xcd, ycd));
myct := coordinates(point(B, xct, yct));
L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")];
printf("\\begin{enumerate}[label=\\arabic*)]\n");
for item in L do
    printf("\\item %s\n", item);
end do;
printf("\\end{enumerate}\n\n");

and got the 

 

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = \dfrac{x^{2}+4 x +7}{x +1}$.
\item Its derivative is: $y' = \dfrac{x^{2}+2 x -3}{\left(x +1\right)^{2}}$.
\item The maximum point of the graph  $ (-3; -2)$.
\end{enumerate}

 

I want to change all `\infty` with `+\infty`. I tried

s := StringTools:-SubstituteAll(s, "\\infty", "+\\infty")

Then,  `-\\infty` to `- + \\infty`. How can I replace \infty with +\infty but keep -\infty unchanged?

I want to write the equation of the line in the form a*x + b*y + c=0, with igcd(a,b,c)=1 of this code

restart;
with(geometry);
point(A, 2, -3);
point(B, -1, 6);
sort(Equation(line(d, [A, B], [x, y])));

I tried by hand

-1/3*sort(Equation(line(d, [A, B], [x, y])))

How can I get the result 3x + y - 3=0 automatically?

PS. I tried and get the answer 3x + y - 3 =0.

restart;
with(geometry);
point(A, 2, -3);
point(B, -1, 6);
eq := sort(Equation(line(AB, [A, B], [x, y])));
k := igcd(coeff(lhs(eq), x), coeff(lhs(eq), y));
sort(eq*sign(coeff(lhs(eq), x))/k);

 

I am using S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);

restart;
n := 0:
L := []:

for a from 3 to 100 do
    for b from 3 to a do
        c2 := a^2 - a*b + b^2;
        c := isqrt(c2);
        if c^2 = c2 then
            if c < a + b and a < b + c and b < c + a then
                if igcd(a, b, c) = 1 then
                    x2 := (-a^2 + b^2 + c^2)/2;
                    y2 := (a^2 - b^2 + c^2)/2;
                    z2 := (a^2 + b^2 - c^2)/2;
                    if 0 < x2 and 0 < y2 and 0 < z2 then
                        S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);
                        x := S[1]; 
                        y := S[2]; 
                        z := S[3];
                        n := n + 1;
                        L := [op(L), [x, y, z, sqrt(x^2 + y^2), sqrt(y^2 + z^2), sqrt(x^2 + z^2)]];
                    end if;
                end if;
            end if;
        end if;
    end do;
end do;

n;
L;
 

But I get the result. How can I get the correct result of sort? 

How Maple 2023 displays new results with old results together

I have a random variable called Y1, which looks like the following: Y1 = 2*sqrt(1 - x^2)/Pi, on the (-1 < x < 1) interval. This "semicircle" integrates to 1, like other random variables. Random variable Y2 is the same as Y1 above. I want to find the random variable Z, which is equal to the absolute difference of two random variables Y1 and Y2. In other words, I want to find Z = |Y1 - Y2|. Via simulation, I know that |Y1 - Y2| takes on a logrithmic form, but I need to get a mathematical solution of this.

DrawGraph(Graph({[{1, 2}, 0.7462761011], [{2, 3}, 0.8190708767], [{2, 4}, 0.6810933318], [{4, 5}, 0.7451261104], [{4, 23}, 0.6746390886], [{5, 6}, 0.7231256359], [{6, 7}, 0.6775594149], [{6, 10}, 0.7019893588], [{7, 8}, 0.6618796622], [{7, 9}, 0.6623496808], [{8, 9}, 0.6688297164], [{10, 11}, 0.7092623872], [{10, 22}, 0.7112560850], [{11, 12}, 0.7098970677], [{12, 13}, 0.7108845941], [{12, 19}, 0.7092202631], [{13, 14}, 0.6734297238], [{13, 18}, 0.6767541419], [{14, 15}, 0.6466191140], [{15, 16}, 0.6773709292], [{16, 17}, 0.6780410682], [{17, 18}, 0.6468993314], [{19, 20}, 0.7444847640], [{19, 21}, 0.7192676187], [{21, 22}, 0.7167453581], [{22, 23}, 0.6726943362], [{23, 24}, 0.8156746068]}), layout = spring)

DrawGraph and save that as 300 dpi png increase edge length so that the edge weight show up How do the edge are small sized and weights overlap and and are not neatly seen in the middle of edge without overlap kind help with a code to correct this

I am interested in determining the density function which results from multiplying two random variables.  I have read about the Mellin Transformation, but I just end up confused.  I have two random variables:  f[1], which is nonzero on the 0 < t < 2 interval, and f[2], which is nonzero on the 0 < t < 1 interval.  Of course, both of these random variables sum to one when evaluated.

Any thoughts on how I can obtain the density function for this?  My work is below.

restart

with(Statistics)

f[1] := piecewise(t <= 0, 0, 0 < t and t < 2, 1/(Pi*sqrt(1-(1-t)^2)), t >= 2, 0)

piecewise(t <= 0, 0, 0 < t and t < 2, 1/(Pi*(1-(1-t)^2)^(1/2)), 2 <= t, 0)

f[2] := piecewise(t <= 0, 0, 0 < t and t < 1, 2*t, t >= 1, 0)

piecewise(t <= 0, 0, 0 < t and t < 1, 2*t, 1 <= t, 0)


Download Inquiry.mw

Hello everyone,
Could someone tell me how to insert an entry (empty cell) between two already filled entries or above an already filled entry in Document Mode?

Oliveira

I am learning how to use Maple for solving single and systems of linear PDE's using the Laplace transform (LT)method so the resulting solution in s space can be used to generate the moments of the resulting probability distribution.

When I take the LT of a term such as Uxx(t,x), I expect a second order ordinary derivative. Instead, it shows the Laplace transform operator.

Here is a simple test code  

with(inttrans):

with(DEtools):

rhs_pde := diff(u(x, t), x, x);

laplace_rhs_pde := laplace(rhs_pde, t, s);

I constructed a density function, and I am certain it shows me what I want.  The problem I am having is parsing the Elliptic functions. Is there a way to "get rid" of the ones I don't want or need.

I generated a plot of the function -- the plot tells me what I expected based on simulation. I need to know if there is a way to express the density function (y) as a function of t and without the elliptic functions..  Even a numerical solution would be fine.

I assume the denomenator term is correct. I also assume that I don't need complex values. My input file is below.

Basics.mw

1 2 3 4 5 6 7 Last Page 1 of 32