Maple 2023 Questions and Posts

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

I am using Maple 2023.

When using PDE Numeric Help Side the text sides is not smooth moving when scrolling downwards or upwards.

Any advice what to do????

Kjell

The so-called look-and-say sequence is something like:

# Starting digit: 0 
0→one 0→
10→one 1, then one 0→
1110→three 1's, then one 0→
3110→one 3, two 1's, then one 0→
132110→…

Rosetta Code gives an example of how to generate such sequences in Maple; however, the code in that example is lengthy. More to the point, compared to the subsequent Mathematica analogue, it is rather inefficient (though more readable, but that's not the point). 
I slightly modify the original code, and now the modified version is significantly faster than the original one: 
 

restart;

interface(version)NULL

`Standard Worksheet Interface, Maple 2023.1, Windows 10, July 7 2023 Build ID 1723669`

(1)
LookAndSay := proc(m::posint, n::nonnegint := 1, ` $`)::'Vector'(nonnegint);

LookAndSay(5, 0)NULL

Vector[column](%id = 36893490791509382076)

(2)

CodeTools['Usage'](LookAndSay(50), iterations = 4)

memory used=3.99GiB, alloc change=1.92MiB, cpu time=48.73s, real time=25.03s, gc time=39.05s

 

gc()time[real](LookAndSay(50))NULL

25.030

(3)


 

Download LookAndSay.mw

For the sake of convenience, I paste the original Maple code from the page above into here:

generate_seq := proc(s)
	local times, output, i;
	times := 1;
	output := "";
	for i from 2 to StringTools:-Length(s) do
		if (s[i] <> s[i-1]) then
			output := cat(output, times, s[i-1]);
			times := 1; # re-assign
		else 
			times ++;
		end if;
	end do;
	cat(output, times, s[i - 1]);
end proc:

Look_and_Say :=proc(n)
	local value, i;
	value := "1";
	print(value);
	for i from 2 to n do
		value := generate_seq(value);
		print(value);
	end do;
end proc:

#Test:
Look_and_Say(10);

Below is a modified version by me: 

LookAndSay := proc(m::posint, n::nonnegint := 1, $)::'Vector'(nonnegint);
    uses StringTools;
    local delete::'equationlist' := Repeat~(Explode(ExpandCharacterClass(":digit:")), 2), aux::procedure[nonnegint](posint) := proc(_::posint)::nonnegint;
        options cache;
        description "https://rosettacode.org/wiki/Look-and-say_sequence#Maple";
        if _ = 1 then
            n
        else
            local char::'nonemptystring' := String(thisproc(_ - 1)), temp::list(string)(*, str*);
            try
                temp := RegSplit(sprintf("(?=[%s])(?<=(?!%s)[%s])", Unique(char), Join(select[2](foldr, eval(apply), delete, rcurry(OrMap, Unique(char)), curry(curry, Has)), "|"), Unique(char)), char)
            catch "cannot compile regular expression: repetition-operator operand invalid":
                local rule::'equationlist' := (str -> str = Insert(str, 1, " "))~(subs(delete =~ NULL, Generate(2, Support(char))));
                temp := StringSplit(Subs(rule, char), " ") # to be replaced
            end;
            parse(String(seq('length(str), str[1]', str in temp)))
        fi;
    end;
    forget(aux);
    Vector[column](m, aux, datatype = nonnegint)
end:

The form LookAndSay(m, n); produces the first m terms in a "look-and-say" sequence starting with n (which is by default 1). Unfortunately, even if "the modified version is significantly faster than the original one", it is still much slower (25s versus 2.5s) than the uncompiled Mathematica implementation (on the same modern computer):

So, is there a workaround to evaluate LookAndSay(50, 1): in about three seconds (instead of half a minute) in the first call (without looking up a pre-calculated table) (on the same computer) as well? 

how I can extract data from plot3d such as x, y, phi2?

thanks

tez-1.mw

Download tez-1.mw
 

restart

``

beta := 2.5; lambda := 0.1e-1; b := Pi; a := Pi; alpha := 1; y[1] := 1.5; y[2] := 1.5; x[1] := -1; x[2] := 1; Q[1] := 40; Q[2] := 35

2.5

 

0.1e-1

 

Pi

 

Pi

 

1

 

1.5

 

1.5

 

-1

 

1

 

40

 

35

(1)

NULL

NULL

v := (2*n-1)*Pi/(2*b)

n-1/2

(2)

Delta := exp(2*v*a)*(alpha*v+beta)*(1+lambda)-(1-lambda)*(alpha*v-beta)

1.01*exp(2*(n-1/2)*Pi)*(n+2.000000000)-.99*n+2.970000000

(3)

g[22] := ((alpha*v+beta)*((1+lambda)*exp(-v*abs(x-xi))+(-1+lambda)*exp(-v*(x+xi)))*exp(2*v*a)+(alpha*v-beta)*((1+lambda)*exp(-v*(x+xi))+(-1+lambda)*exp(-v*abs(x-xi))))/(2*v*Delta)

g[21] := ((alpha*v+beta)*exp(v*(2*a+xi))+(alpha*v-beta)*exp(-v*xi))*exp(-v*x)/(v*Delta)

NULL

u[2] := int(2*g[21]*Q[1]*Dirac(xi-x[1])*sin(n*Pi*y[1]/b)/b, xi = -a .. 0)+int(2*g[22]*Q[2]*Dirac(xi-x[2])*sin(n*Pi*y[2]/b)/b, xi = 0 .. infinity)

NULL

phi[2] := sum(u[2](x)*sin(v*y), n = 1 .. 30)

NULL

``

plot3d(phi[2], x = 0 .. 5, y = 0 .. b)

 

NULL


 

Download tez-1.mw

 

 

While Maple itself is a pleasure to work with, the multitude and persistance of bugs in the Units package doesn't stop to surprise.

Especially as the same bugs come up again and again, after having been fixed i older versions.

In general, working with units and 0 is a pain in the ass. And this one doesn't even need a unit to compare with.

This one works in Maple 2022 - does not work in Maple 2023.

with(Units[Simple]);
min(0, 0);

Hi, 

Im trying to solve a system of 4 non-linear equations using the fsolve function. When i compute the command i seemingly dont get an answer to the system. Maple only prompts the command itself, can any of you locate my mistake or give any input on how to solve the issue. 

My code is as follows: 

restart;
r__C := 400;
r__D := 600;
r__E := 800;
a := 100;
p := 0.7;
q := Pi*a^2*p;
h__eq := 0.9*h__1*(E__1/E__2)^(1/3);
R__Ceq := sqrt(h__eq^2 + r__C^2);
R__C := sqrt(r__C^2 + h__1);
R__Deq := sqrt(h__eq^2 + r__D^2);
R__D := sqrt(r__D^2 + h__1);
R__Eeq := sqrt(h__eq^2 + r__E^2);
R__E := sqrt(r__C^2 + h__1);


eqC := 174.5*10^(-3) = q*(1 + nu)/(2*Pi*E__2*R__Ceq)*(2*(1 - nu) + h__eq^2/R__Ceq^2) + q*(1 + nu)/(2*Pi*E__1*r__C)*(2*(1 - nu) + 0) - q*(1 + nu)/(2*Pi*E__1*R__C)*(2*(1 - nu) + h__1^2/R__C^2);
eqD := 151.7*10^(-3) = q*(1 + nu)/(2*Pi*E__2*R__Deq)*(2*(1 - nu) + h__eq^2/R__Deq^2) + q*(1 + nu)/(2*Pi*E__1*r__D)*(2*(1 - nu) + 0) - q*(1 + nu)/(2*Pi*E__1*R__D)*(2*(1 - nu) + h__1^2/R__D^2);
eqE := 133.2*10^(-3) = q*(1 + nu)/(2*Pi*E__2*R__Eeq)*(2*(1 - nu) + h__eq^2/R__Eeq^2) + q*(1 + nu)/(2*Pi*E__1*r__E)*(2*(1 - nu) + 0) - q*(1 + nu)/(2*Pi*E__1*R__E)*(2*(1 - nu) + h__1^2/R__E^2);
eqA := 401.7*10^(-3) = 2*q*a*(-nu^2 + 1)*(sqrt(1 + (h__eq/a)^2) - h__eq/a)/E__2 + 2*(-nu^2 + 1)*q*a/E__1 - 2*q*a*(-nu^2 + 1)*(sqrt(1 + (h__1/a)^2) - h__1/a)/E__1;


fsolve({eqA, eqC, eqD, eqE}, {E__1, E__2, h__1, nu}, {E__1 = 0 .. 5000, E__2 = 0 .. 5000, h__1 = 0 .. 1000, nu = 0 .. 0.5});
 

 

Picture for refference: 

The attached worksheet shows a simple operator to calculaute the cartesian product of a set. The code is executed in both 1D and 2D notation in the worksheet.  The code is also placed in a code edit region and in the startup code area if the worksheet.  When entered into a worksheet is either notation, it produces an error message,  Without the local designation, it executes with a warning message. When entered into a code edit region it executes without error or warning.

I assume that this behavior reflects a limitation of the 2d notation or is there a workaround to the problem?

error4.mw

For instance, given nine integer x1, x2, …, x9 satisfying x1, x2, …, x9 ≥ -5 and x13x23+…+x93=0, the goal is to maximize x1 + x2 + … + x9. However, according to Optimization/Options,  is not accepted by the Optimization:-Maximize command. A probable method is applying floor into the optimization variables; unfortunately, I can only get: Error, (in Optimization:-NLPSolve) no improved point could be found

(*restart;*)
vars := [x || (1 .. 9)]:
Optimization:-Maximize(`?()`(`+`, floor~(expr)), [add(floor~(expr) ^~ 3) = 0, expr[] >=~ -5], initialpoint = (unapply~(expr) =~ rand(-5 .. 10))()); # Alternatives to exhaustive search?
Error, (in Optimization:-NLPSolve) no improved point could be found

Is there any workaround to solve this problem? 

Hafiz_basin_of_attraction_.mw

[moderator: see also this earlier Question]

The code below runs as expected up through the 4th line. At that point ans_all should contain all the multipule ansers to the equation being looked at. I want to look at just the first solution and I would expect the way to do this would be ans_all[1]. However the command ans_all[999999999] is valid, which indicates to me that that's not how you do that. So.... how do I get just the first answer?

equ := sqrt(1 + (-4 + 4*sqrt(2))*x + (16 - 12*sqrt(2))*x^2 + (-24 + 16*sqrt(2))*x^3 + (15 - 8*sqrt(2))*x^4)/(1 + (-4 + 4*sqrt(2))*x + (22 - 12*sqrt(2))*x^2 + (-36 + 28*sqrt(2))*x^3 + (33 - 20*sqrt(2))*x^4):
anit_dev_equ := int(equ,x):
ans_root := eval(anit_dev_equ, [x = 1]) - eval(anit_dev_equ, [x = 0]):
ans_all := allvalues(ans_root):
ans_all[999999999]

How does a user retain existing inline output (for example, computational output or inline plots) when re-executing an execution group in recent versions of Maple?  The "Replace existing output when re-executing groups" option is not available in Maple 2023 or in Maple 2020.

For example, I want to execute the same execution group 2 times to generate 2 different inline plots as the output. I want to retain the first inline plot when I generate the second inline plot.  However, the default Maple 2023 behavior is to overwrite the first inline plot with the second inline plot.

Several Maple versions ago (for example, Maple 18), there was the Tools > Option > Display > "Replace existing output when re-executing groups" option. When that option is checked, the second plot overwrites the first plot. In contrast, when that option is unchecked, the second plot appears after the retained first plot.

Where is the "Replace existing output when re-executing groups" option in recent Maple versions? Or do recent versions, like Maple 2023, use a different method to retain existing output when re-executing an execution group?

I think that the following worksheet is self-explaining: 
 

restartNULL

interface(version)

`Standard Worksheet Interface, Maple 2023.1, Windows 10, July 7 2023 Build ID 1723669`

(1)

evalf(LinearAlgebra:-MatrixFunction(`<|>`(`<,>`(1, 0, 0), `<,>`(1, 1, I), `<,>`(3, 0, 2)), 'x'/(exp('x')-1), 'x'))

Matrix(%id = 36893489913840207380)

(2)

(* Yet in many cases, the input may be inexact, for we need to speed up computations and decrease memory usage. *)

m := Matrix([[1, 1, 3], [0, 1, 0], [0, I, 2]], datatype = complex(sfloat)):
Digits := 10:
do
    print(CodeTools:-Usage(LinearAlgebra:-MatrixFunction(m, 'x'/(exp('x') - 1), 'x'), quiet), Digits++)
until Digits > 20:

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.3333333333+.1931757357*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 10

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.33333333332+.19317573586*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 11

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.333333333321+.193175735853*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 12

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.3333333333209+.1931757358526*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 13

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.33333333332087+.19317573585263*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 14

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.333333333320870+.193175735852624*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 15

 

Matrix(3, 3, {(1, 1) = .5819767068693265, (1, 2) = .9999999999999999-3.806824264*I, (1, 3) = -.8068242641099854, (2, 1) = 0., (2, 2) = .5819767068693265, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352854993314}), 16

 

Matrix(3, 3, {(1, 1) = .58197670686932644, (1, 2) = .99999999999999997-3.806824264*I, (1, 3) = -.80682426410998598, (2, 1) = 0., (2, 2) = .58197670686932644, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .31303528549933112}), 17

 

Matrix(3, 3, {(1, 1) = .581976706869326423, (1, 2) = -.999999999999999997+2.19317573589001464*I, (1, 3) = -.806824264109985348, (2, 1) = 0., (2, 2) = .581976706869326423, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .313035285499331308}), 18

 

Matrix(3, 3, {(1, 1) = .5819767068693264245, (1, 2) = -.2500000000000000000-0.5682426411e-1*I, (1, 3) = -.8068242641099853627, (2, 1) = 0., (2, 2) = .5819767068693264245, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352854993313037}), 19

 

Matrix(%id = 36893489913905117652), 20

(3)

# Is `linalg:-matfunc` better than `LinearAlgebra:-MatrixFunction`?!
Digits := 10:
linalg:-matfunc(m, 'x'/(exp('x') - 1), 'x');

Matrix(3, 3, {(1, 1) = .5819767070, (1, 2) = -.3386968877+.2092663986*I, (1, 3) = -.8068242645, (2, 1) = 0., (2, 2) = .5819767070, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414215*I, (3, 3) = .3130352855})

(4)

(*
Even for a 3×3 matrix, the number of digits has to be set to 20.
So … how can you certify that the following output is validated?
*)
_seed := 1234:

LinearAlgebra:-MatrixFunction(LinearAlgebra:-RandomMatrix(50, density = .5, generator = -2*Pi .. 2*Pi, datatype = complex[8]), 'x'/(exp('x')-1), 'x')

Warning, the use of _seed is deprecated.  Please consider using one of the alternatives listed on the _seed help page.

 

Matrix(%id = 36893490216779135924)

(5)


 

Download funm.mws

How do you confirm the validity of the last output? 

> op(3, eval(LinearAlgebra:-MatrixFunction));
 = 
  Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.

And does this mean that LinearAlgebra['MatrixFunction'] is so out-dated that the return value is less effective in certain cases?

Wolfram's marketing literature states that a compiled function may generate the dates for the years 1 through 5.7 million in a couple of seconds rather than in minutes (comparing to the "uncompiled implementation").
The given function in this link can be translated into Maple language as follows: 

(*
  Note that this is only a mathematical program that outputs some data,
   hence 'Easter(-2, 1)' will never return real Gregorian Easter dates!
*)
Easter:=proc(BEGIN::integer[4],END::integer[4],$)::Array(BEGIN..END,[integer[1..12],integer[1..31]]);# the parent function
	description "https://www.wolfram.com/language/12/code-compilation/compute-the-date-of-easter.html";
	local computus::procedure[[integer[1 .. 12], integer[1 .. 31]]](integer):=proc(Year::integer,` $`)::[integer[1..12],integer[1..31]];# the child function
		options threadsafe;
		local a::nonnegint,b::integer,c::nonnegint,d::integer,e::nonnegint,f::integer,g::nonnegint,h::nonnegint,i::nonnegint,j::nonnegint,k::nonnegint,Month::integer[1..12],Day::integer[1..31];
		(* For compatibility, when `Year` is nonpositive, the command `iquo` must be replaced with slower `floor`. *)
		if Year<=0 then
			a,b,c:=Year mod 19,floor(Year/100),Year mod 100;
			d,e,f:=floor(b/4),b mod 4,floor((8*b+13)/25);
			g,h,i:=19*a+b-d-f+15 mod 30,floor(c/4),c mod 4;
			j:=floor((a+11*g)/319);k:=2*e+2*h-i-g+j+32 mod 7;
			Month:=floor((g-j+k+90)/25);Day:=g-j+k+Month+19 mod 32
		else
			a,b,c:=irem(Year,19),iquo(Year,100),irem(Year,100):
			d,e,f:=iquo(b,4),irem(b,4),iquo(8*b+13,25);
			g,h,i:=irem(19*a+b-d-f+15,30),iquo(c,4),irem(c,4);
			j:=iquo(a+11*g,319);k:=irem(2*e+2*h-i-g+j+32,7);
			Month:=iquo(g-j+k+90,25);Day:=irem(g-j+k+Month+19,32)
		fi;
		[Month,Day]
	end;
	Array(BEGIN..END,computus)
end:

However, as "no nested procedures can be translated" to optimized native machine code (cf. ), executing Easter(1, 5700000) has to take at least two minutes

Is there some workaround that can provide improved performance for such a numerical procedure that contains a nested procedure? In other words, is it possible to produce the `result` (without modifying the algorithm) in two seconds in modern Maple as that Wolfram marketing literature claims?

What am I doing wrong, why cant I get the result correct?

Hello

I have programs below for the cases n=3 and n=4. If n is increasing by 1, then there is one loop more. As you can see, that additional loop has always the structure:

x[i+1] from ceil(((n-2)*24-d[i])/(n-i)) to x[i]

whereas d[i] is the sum of the values of x before.

Now I want to write "nequaln":=proc(k), which goes through all the values for n from 3 to k and produces a list [a_3,a_4,a_5,...,a_n].

I guess that I need to program a kind of dynamical loop, but I failed completely. May someone help me? That would be very kind.

 

nequal3:=proc()
    local u,v,a_3;
    a_3:=0;
    for u from ceil((3-2)*24/(3-0)) to (3-2)*24-3+1 do
        for v from ceil(((3-2)*24-u)/(3-1)) to u do
            if (3-2)*24-u-v>=1 then
                a_3:=a_3+1;
            end if;
        end do;
    end do;
    print(a_3);
end proc:

 

nequal4:=proc()
    local u,v,w,a_4;
    a_4:=0;
    for u from ceil((4-2)*24/(4-0)) to (4-2)*24-4+1 do
        for v from ceil(((4-2)*24-u)/(4-1)) to u do
            for w from ceil(((4-2)*24-u-v)/(4-2)) to v do
                if (4-2)*24-u-v-w>=1 then
                    a_4:=a_4+1;
                end if;
            end do;
        end do;
    end do;
    print(a_4);
end proc:

The old question "Longest distance in a graph via Maple code" offers some general methods to find longest paths in a given graph, while for directed acyclic graphs, the longest paths can be found much more directly via built-in functions. However, it apprears that even for small dags, Maple cannot solve this in an acceptable time. In the following example, I'd like to count the number of nodes that on longest paths for certain source and target vertexes.
 

restart;

_seed := 1234

Warning, the use of _seed is deprecated.  Please consider using one of the alternatives listed on the _seed help page.

 

G := GraphTheory:-RandomGraphs:-RandomNetwork(200, .2, 'acyclic', 'weights' = 0. .. 2)

G__0 := applyop(`-`, -1, G)``

GRAPHLN(directed, weighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200], Array(1..200, {(1) = {2, 3, 4}, (2) = {5}, (3) = {4, 5}, (4) = {5}, (5) = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}, (6) = {11, 12, 13, 14, 15, 17, 18, 19, 21}, (7) = {9, 10, 11, 16, 17, 20, 22}, (8) = {12, 14, 16, 17, 19, 20, 21, 22, 23}, (9) = {11, 14, 21, 23}, (10) = {11, 13, 18, 19, 20, 21, 23}, (11) = {14, 15, 16, 17, 18, 21, 23}, (12) = {13, 15, 18, 19, 20, 22}, (13) = {14, 15, 16, 17, 21}, (14) = {19, 20, 22}, (15) = {19, 20, 22, 23}, (16) = {17, 18, 21}, (17) = {19, 20, 23}, (18) = {19, 20, 21}, (19) = {20, 24, 25}, (20) = {22, 23, 25}, (21) = {23, 24, 25}, (22) = {23, 24, 25}, (23) = {24, 25}, (24) = {26, 27, 29}, (25) = {27, 28, 29}, (26) = {28, 29, 30}, (27) = {28, 29, 31, 32, 33}, (28) = {32, 33}, (29) = {32, 33}, (30) = {34, 35, 38, 39}, (31) = {32, 37, 38, 39}, (32) = {33, 36, 37, 38}, (33) = {35, 36, 39}, (34) = {36, 38, 39}, (35) = {37, 39}, (36) = {37, 39}, (37) = {39, 40}, (38) = {39, 40}, (39) = {40}, (40) = {41, 42}, (41) = {43, 44, 47, 48, 49}, (42) = {44, 45, 46, 47, 48, 49}, (43) = {47, 49, 50, 55, 56, 57}, (44) = {45, 48, 50, 51, 52, 53, 54, 56}, (45) = {46, 47, 49, 50, 52, 56}, (46) = {47, 48, 49, 50, 51, 52, 53, 56, 57}, (47) = {49, 50, 51, 52, 54, 56, 57}, (48) = {49, 51, 52, 53, 54, 55, 56, 57}, (49) = {50, 52, 53, 54, 57}, (50) = {51, 57}, (51) = {53, 54, 57}, (52) = {53, 55, 57}, (53) = {54, 56}, (54) = {56, 58}, (55) = {58}, (56) = {58}, (57) = {58}, (58) = {59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75}, (59) = {60, 61, 66, 68, 70, 71, 74, 75, 76, 77}, (60) = {61, 63, 67, 68, 70, 72, 73, 77}, (61) = {62, 66, 69, 70, 71, 72, 73, 75, 76, 77}, (62) = {65, 68, 75, 76, 77}, (63) = {65, 66, 69, 70, 72, 73, 76, 77}, (64) = {65, 67, 68, 69, 70, 71, 73, 77}, (65) = {66, 70, 72, 73, 74, 76}, (66) = {68, 70, 71, 72, 73, 74, 75, 76, 77}, (67) = {69, 70, 71, 74, 76}, (68) = {73, 74}, (69) = {71, 76, 77}, (70) = {71, 73, 77}, (71) = {72, 76, 77}, (72) = {75}, (73) = {75, 76}, (74) = {76}, (75) = {76}, (76) = {77, 78, 79, 80, 81, 82, 83, 85, 86}, (77) = {79, 80, 82, 84, 85}, (78) = {79, 83, 85, 87}, (79) = {81, 82, 83, 85, 86, 87}, (80) = {83, 86}, (81) = {83, 84, 87}, (82) = {87}, (83) = {85, 86, 87}, (84) = {85, 87}, (85) = {87}, (86) = {87}, (87) = {88, 89}, (88) = {90, 91, 92, 93, 94}, (89) = {90, 91, 93, 94, 95}, (90) = {96, 97, 99, 101, 103, 104, 107, 108, 109, 110, 112, 115, 117, 118, 120}, (91) = {92, 94, 96, 97, 98, 100, 101, 102, 105, 106, 107, 110, 113, 116, 117, 118, 120}, (92) = {95, 97, 98, 99, 101, 103, 106, 107, 108, 111, 112, 113, 115, 117, 119, 120}, (93) = {95, 96, 98, 100, 104, 106, 109, 111, 112, 113, 116, 118, 119, 120}, (94) = {95, 99, 100, 102, 103, 104, 106, 108, 109, 110, 111, 112, 113, 114, 115, 117, 118, 119, 120}, (95) = {97, 98, 99, 100, 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 118, 120}, (96) = {98, 100, 102, 103, 104, 106, 107, 110, 111, 114, 119, 120, 121}, (97) = {99, 100, 102, 104, 106, 107, 108, 109, 111, 114, 118, 119}, (98) = {102, 103, 107, 110, 111, 112, 113, 114, 116, 117, 119, 120, 121}, (99) = {101, 102, 104, 106, 107, 112, 117, 120}, (100) = {101, 104, 105, 106, 109, 110, 116, 117, 119, 120, 121}, (101) = {102, 105, 109, 110, 111, 112, 113, 114, 115, 117, 118, 119, 120}, (102) = {103, 106, 107, 108, 110, 112, 113, 114, 117, 118, 119}, (103) = {104, 105, 107, 108, 109, 110, 111, 113, 115, 116, 119, 120, 121}, (104) = {105, 106, 109, 110, 114, 115, 116, 118, 119}, (105) = {106, 108, 109, 110, 113, 114, 116, 117}, (106) = {107, 108, 109, 112, 114, 117, 118, 119, 121}, (107) = {110, 114, 116, 119, 120}, (108) = {111, 112, 113, 114, 118, 119, 120, 121}, (109) = {113, 116, 117, 118, 121}, (110) = {111, 113, 117, 119, 120, 121}, (111) = {112, 113, 115, 118, 120}, (112) = {113, 114, 116, 117, 118, 119, 120}, (113) = {116, 117, 119, 121}, (114) = {115, 116, 117, 121}, (115) = {116, 120}, (116) = {119, 121}, (117) = {118, 119, 121}, (118) = {121}, (119) = {121}, (120) = {121}, (121) = {122, 123, 124, 125, 126}, (122) = {123, 124, 125, 126, 127}, (123) = {126}, (124) = {126, 127}, (125) = {127}, (126) = {127}, (127) = {128, 129}, (128) = {130}, (129) = {130}, (130) = {131, 132}, (131) = {132, 133, 135}, (132) = {134, 135}, (133) = {134, 136, 137, 138, 140, 141, 142}, (134) = {135, 136, 139, 140, 141}, (135) = {136, 137, 139, 140, 141, 142}, (136) = {145, 146, 147}, (137) = {139, 141, 143, 145, 147, 148}, (138) = {139, 140, 143, 144, 145, 148}, (139) = {141, 143, 145}, (140) = {143, 145, 146, 147, 148}, (141) = {142, 144, 145, 146, 147}, (142) = {143, 144, 146, 148}, (143) = {145, 146, 147, 148}, (144) = {146, 149}, (145) = {147}, (146) = {149}, (147) = {149}, (148) = {149}, (149) = {150, 151, 152, 153, 154, 155, 156, 157, 158}, (150) = {152, 153, 155, 157, 158}, (151) = {152, 153, 159}, (152) = {154, 158}, (153) = {154, 155, 156}, (154) = {156, 158, 159}, (155) = {158}, (156) = {157, 158, 159}, (157) = {158}, (158) = {159}, (159) = {160, 161, 162, 163}, (160) = {161, 163, 166, 167}, (161) = {165, 166, 167}, (162) = {163, 165}, (163) = {164, 166, 167}, (164) = {166}, (165) = {166, 168, 169}, (166) = {169}, (167) = {168}, (168) = {169, 170, 171, 172, 173, 174, 177, 178, 179, 180, 182}, (169) = {170, 171, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182}, (170) = {172, 173, 174, 175, 176, 180, 182, 183, 185}, (171) = {172, 174, 176, 177, 181, 182, 185}, (172) = {175, 176, 177, 183, 185}, (173) = {175, 176, 178, 183, 185}, (174) = {175, 180, 181, 183, 184, 185}, (175) = {181, 182, 183, 185}, (176) = {177, 178, 179, 182}, (177) = {178, 179, 184, 185}, (178) = {179, 180, 182, 183, 184}, (179) = {180, 182, 185}, (180) = {181, 182}, (181) = {184}, (182) = {185}, (183) = {187, 188, 190}, (184) = {187, 188, 189}, (185) = {186, 188, 190}, (186) = {187, 188, 190, 191, 193, 194, 196}, (187) = {188, 190, 192, 193, 194, 195}, (188) = {189, 190, 191, 192, 194}, (189) = {190, 191, 196}, (190) = {191, 192, 195, 196}, (191) = {193, 196, 199}, (192) = {194, 196, 198, 199}, (193) = {197, 199}, (194) = {195, 196, 197}, (195) = {196, 198, 199}, (196) = {198, 199}, (197) = {198}, (198) = {199, 200}, (199) = {200}, (200) = {}}), `GRAPHLN/table/1`, )

(1)

t, s := combinat:-randcomb(GraphTheory:-Vertices(G__0), 5^2), combinat:-randcomb(GraphTheory:-Vertices(G__0), integermul2exp(5, 2))

[12, 13, 22, 23, 41, 65, 70, 80, 88, 97, 105, 119, 124, 127, 129, 132, 135, 138, 146, 150, 165, 170, 189, 193, 199], [6, 13, 28, 29, 31, 41, 42, 49, 55, 85, 98, 104, 136, 141, 162, 166, 167, 168, 192, 199]

(2)

"DataFrame((`M__1`:=CodeTools:-Usage(Matrix(numelems(s),numelems(t),(i,j)->numelems((GraphTheory:-BellmanFordAlgorithm(`G__0`,s[i],t[j]))[1]),datatype=integer[2]))),'columns'=t,'rows'=s)"

memory used=7.99GiB, alloc change=0 bytes, cpu time=5.74m, real time=5.63m, gc time=22.55s

 

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module

(3)

"DataFrame((`M__2`:=CodeTools:-Usage(Matrix(numelems(s),numelems(t),proc(i::posint,j::posint,` $`)::nonnegint;  uses ListTools,GraphTheory; local ts::list(posint):=TopologicSort(`G__0`,'output'='permutation'),q::posint:=Search(t[j],ts),p::posint:=Search(s[i],ts); if  p>q then 0 elif q=p then 1 else numelems(BellmanFordAlgorithm(`G__0`,s[i],t[j])[1]) fi end,datatype=integer))),':-columns'=t,':-rows'=s)"

memory used=4.34GiB, alloc change=32.00MiB, cpu time=3.26m, real time=3.19m, gc time=14.34s

 

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module

(4)

EqualEntries(M__ || (1 .. 2))

true

(5)

 


 

Download longest_paths_in_a_DAG.mw

Unfortunately, I have to wait for almost four minutes in the above instance. Can this task be done in 0.4s?

First 12 13 14 15 16 17 18 Last Page 14 of 26