acer

32445 Reputation

29 Badges

19 years, 364 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

I changed your Post into a Question.

Please submit your future queries as Questions.

@Motocycle Mayor Thank you.

Your Document runs ok and as expected in my Maple 2024.2.

Ribbiting_Disparities_29_ac_2024.2.mw

I'll have to get back to you about Maple 2025.1, unless someone else clarifies sooner.

ps. The line,
   with DataFrames
doesn't do anything or load anything. It's just a product of two names. It shouldn't hurt, though.

@Geoff For that alternate input,

restart

n, k := 4, 2

4, 2

sys := {Tree = Union(Z, Prod(`$`(Tree, k)))}

all := combstruct:-allstructs([Tree, sys], size = n)

lists := eval(all, Prod = (proc () options operator, arrow; [args] end proc))

Groupings := proc(LI::{list,posint}, k::posint)
local L, Tree, Leaf, sys, n, lists, LTS;
if k = 1 then error "k must be greater than 1" end if;
if LI::posint then L:=$LI; n:=LI;
else L:=LI; n:=nops(L); end if;
LTS := proc(LL)
   local count := 0, F := proc() count:=count+1; L[count]; end proc;
   eval(subs(Leaf='F'(),LL));
end proc:
sys := {Tree = 'Union'(Leaf, 'Prod'(Tree $ k)), Leaf = 'Atom'};
lists := eval(combstruct['allstructs']([Tree, sys], 'size' = n), 'Prod' = (()->[args]));
map(LTS, lists);
end proc:

 

Groupings([a, b, c, d], 2);

[[a, [b, [c, d]]], [a, [[b, c], d]], [[a, b], [c, d]], [[a, [b, c]], d], [[[a, b], c], d]]

Groupings([1, 2, 3, 4], 2)

[[1, [2, [3, 4]]], [1, [[2, 3], 4]], [[1, 2], [3, 4]], [[1, [2, 3]], 4], [[[1, 2], 3], 4]]

Groupings(4, 2)

[[1, [2, [3, 4]]], [1, [[2, 3], 4]], [[1, 2], [3, 4]], [[1, [2, 3]], 4], [[[1, 2], 3], 4]]

Download Groupings_ac4.mw

@Geoff Change the type specification of the L parameter (in the definition of procedure Groupings) to L::list instead, so it'll look like,

   Groupings := proc(L::list, k::posint)
      ...
   end proc:

@Motocycle Mayor A reasonable first step would be to attach an Excel data file that could be used with your Import command and which creates a representative example that reproduces the problem.

Uploading and attaching an Excel file and .mw Maple worksheet that can be used together to reproduce the problem is often a very good first step here.

In the absence of an actual worksheet it is more difficult for me to determine the cause, eg. whether Data is actually a DataFrame, etc.

Mentioning your Maple version (or marking it in the field at the top of your Question) might also be useful. Are you still using Maple 2019?

Could you please attach an Excel data file and the Import command which creates a representative example that illustrates the problem? You can use the green up-arrow in the Reply editor, to upload and insert links to files.

Are you sure that the entries of the column are all strings already? Have you tried,

   SubsDatatype(Data, "UN Region", string, conversion=String );

@dharr I suppose this is simpler still, having F insert indexed references to L.

restart

n, k := 4, 2

4, 2

Define trees with k branches from each node. Z here is a leaf on the tree.

sys := {Tree = Union(Z, Prod(`$`(Tree, k)))}

Find all possibilities

all := combstruct:-allstructs([Tree, sys], size = n)

Convert the Prod(...) to [...]

lists := eval(all, Prod = (proc () options operator, arrow; [args] end proc))

Groupings:=proc(L::list(symbol),k::posint)
local Tree,Leaf,sys,n:=nops(L),lists,LTS;
if k=1 then error "k must be greater than 1" end if;
LTS:=proc(LL)
   local count:=0,F:=proc() count:=count+1;L[count];end proc;
   eval(subs(Leaf='F'(),LL));
end proc:
sys:={Tree='Union'(Leaf,'Prod'(Tree $ k)),Leaf='Atom'};
lists:=eval(combstruct['allstructs']([Tree,sys],'size'=n),'Prod'=(()->[args]));
map(LTS,lists);
end proc:

Groupings([a, b, c, d], 2)

[[a, [b, [c, d]]], [a, [[b, c], d]], [[a, b], [c, d]], [[a, [b, c]], d], [[[a, b], c], d]]

Download Groupings_accc.mw

@janhardo That's nice. It perhaps shares the theme of my 6) using eliminate, or 1).

You could even do it as the shorter,

   simplify(F2, {eq}, [p1])

@dharr For fun,

restart

n, k := 4, 2

4, 2

Define trees with k branches from each node. Z here is a leaf on the tree.

sys := {Tree = Union(Z, Prod(`$`(Tree, k)))}

Find all possibilities

all := combstruct:-allstructs([Tree, sys], size = n)

Convert the Prod(...) to [...]

lists := eval(all, Prod = (proc () options operator, arrow; [args] end proc))

Groupings := proc(L::list(symbol), k::posint)
local Tree, Leaf, sys, n:=nops(L), lists, LTS, G:=Equate([$n],L);
if k = 1 then error "k must be greater than 1" end if;
LTS := proc(LL)
   local count := 0, F := proc() count:=count+1; end proc;
   eval(eval(subs(Leaf='F'(),LL)),G);
end proc:
sys := {Tree = 'Union'(Leaf, 'Prod'(Tree $ k)), Leaf = 'Atom'};
lists := eval(combstruct['allstructs']([Tree, sys], 'size' = n), 'Prod' = (()->[args]));
map(LTS, lists);
end proc:

Groupings([a, b, c, d], 2)

[[a, [b, [c, d]]], [a, [[b, c], d]], [[a, b], [c, d]], [[a, [b, c]], d], [[[a, b], c], d]]

Download Groupings_ac.mw

If you'd rather not substitute bare [1,2,3,4]=[a,b,c,d] then you could instead do it with [X[1],X[2],X[3],X[4]]=[a,b,c,d] where X is another local. Groupings_acc.mw

@janhardo If you assign to name B12 then it's awkward to get a result that is expressed in just the name B12.

That's why I used InertForm above (as one of several ways to get around the fact that you'd assigned to that name...).

If instead you start with an equation involving B12 then there are a few ways, eg.,

restart;

eq := B12 = -6*(p1 + p2)/(p1 - p2)^2;

B12 = -6*(p1+p2)/(p1-p2)^2

F2 := (theta1*theta2*p1^2 + (-2*p2*theta1*theta2 - 6)*p1
      + theta1*theta2*p2^2 - 6*p2)/(p1 - p2)^2:

 

1)
evala(eval(F2,isolate(eq,p1)));

theta1*theta2+B12

 

alteq1 := isolate(eq,denom(eval(B12,eq)));

(p1-p2)^2 = -(6*p1+6*p2)/B12

2)
simplify(algsubs(alteq1, numer(F2))/subs(alteq1, denom(F2)));

theta1*theta2+B12

alteq2 := map[2](`/`,1,isolate(eq,denom(eval(B12,eq))));

1/(p1-p2)^2 = -B12/(6*p1+6*p2)

3)
simplify(subs(alteq2,algsubs(alteq1, F2)));

theta1*theta2+B12

4)
eval(collect(F2,[theta1],normal), (rhs=lhs)(eq));

theta1*theta2+B12

5)
eval(Ans,solve({Ans=F2,eq},{Ans,p1,p2}));

theta1*theta2+B12

6)
eval(Ans,eliminate({Ans=F2,eq},{Ans,p1})[1]);

theta1*theta2+B12

Download janh_03.mw

@michele Here are two ways to overlay them, with black&white, using either the float or 1..255 values.

Mat_bg_bw2.mw

which gives, for the plotted way,

or,

If I install the Maple 2024 Physics package update then the original attachment seems to work ok.

That is, in a separate Worksheet I issued the command,

   PackageTools:-Install("5137472255164416", version = 1852, overwrite);

and then I reopened the original worksheet, and ran it:

derivativve_ac.mw

@michele Sorry, I don't understand what you mean by "compare".

@janhardo It's now very unclear what your actual question is.

State clearly what input you do already have in your situation, and what you want to achieve with it.

Perhaps you are trying to ask whether you can somehow substitute for B12 in F2?

Or maybe even something(?) like this,

restart;

 

B12 := -6*(p1 + p2)/(p1 - p2)^2:

F2 := (theta1*theta2*p1^2 + (-2*p2*theta1*theta2 - 6)*p1
      + theta1*theta2*p2^2 - 6*p2)/(p1 - p2)^2:

 

simplify( F2 - B12 );

theta1*theta2

You can always both add and subtract something...

simplify( F2 - B12 ) + InertForm:-Display('B12');

theta1*theta2+Typesetting:-mi("B12")

Download janh_02.mw

If (as now it might seem) you'd be content with a plot then another choice for getting it in black and white is:

restart;

with(LinearAlgebra):

M:=1/255*RandomMatrix(8,generator=0..255):

 

plot(background=Array(M,datatype=float[8]),
     size=[400,400],axes=none);

 

Download Mat_bg_bw.mw

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