acer

33255 Reputation

29 Badges

20 years, 246 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

It occurs to me that your scenario might be one in which you start off with the expressions having the double-underscore name varphi__0, and want to only see the rendered subscript with upright Roman.

So, a similar replacement can work, and you can construct the replacement directly or programmatically. And here indexed names are not involved.

And, again, if you have just the single name to handle then it'd be simpler to just use the directly constructed replacement,

     L := { varphi__0 = `#msub(mi("varphi"),mn("0"));` }

restart

Starting off with `ϕ`[0] as subscripted, ie. varphi__0

K := proc (nm) local v, i, res; i := parse(convert(nm, string)[9 .. ()]); res := Typesetting:-msub(Typesetting:-mi("varphi"), subs(Typesetting:-mi = Typesetting:-mn, Typesetting:-Typeset(Typesetting:-EV(i)))); nprintf(`#%a;`, res) end proc; Rep := proc () options operator, arrow; subsindets([args], suffixed(varphi__, anything), K)[] end proc

K(`ϕ__0`)

`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`

K(`ϕ__a,b,c`)

`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mrow(Typesetting:-mn("a"),Typesetting:-mo(","),Typesetting:-mn("b"),Typesetting:-mo(","),Typesetting:-mn("c")));`

eq := -t(0)+t(`ϕ`(t)) = Int(1/sqrt(2*C*cos(`ϕ`)-2*C*cos(`ϕ__0`)), `ϕ` = 0 .. `ϕ`(t), continuous); Rep(eq)

0, "%1 is not a command in the %2 package", _Hold, Typesetting

H := t(0) = 0, `ϕ`(t) = `ϕ__0`, t(`ϕ__0`) = (1/4)*T; Rep(H)

t(0) = 0, varphi(t) = `#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`, t(`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`) = (1/4)*T

new := Rep(subs(H, eq))

(1/4)*T = Int(1/(2*C*cos(varphi)-2*C*cos(`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`))^(1/2), varphi = 0 .. `#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`, continuous)

cond := C > 0, 0 < `&varphi;__0` and `&varphi;__0` < Pi; Rep(cond)

0 < C, 0 < `#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));` and `#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));` < Pi

ans := isolate(`assuming`([simplify(value(new))], [Rep(cond)]), T)

T = 4*InverseJacobiAM((1/2)*`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`, csc((1/2)*`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`))*csc((1/2)*`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));`)/C^(1/2)


I don't know whether you want the list of replacements.

With that, you can undo the effect.

You can create such a list to involve just the one indexed name, or any found.
Ie, you can make it as targeted as you want, in case there are other indexed
names that you're prfer lest alone.

S := indets([eq, H], suffixed(varphi__, anything))

{varphi__0}

L := map(proc (s) options operator, arrow; K(s) = s end proc, {`&varphi;__0`})

{`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));` = varphi__0}

L := map(proc (s) options operator, arrow; K(s) = s end proc, S)

{`#Typesetting:-msub(Typesetting:-mi("varphi"),Typesetting:-mn("0"));` = varphi__0}

subs(L, ans)

T = 4*InverseJacobiAM((1/2)*varphi__0, csc((1/2)*varphi__0))*csc((1/2)*varphi__0)/C^(1/2)

NULL

Download Evaluation_of_elliptic_integrals_accc.mw

Here is another example of an indexed name, for which double-underscore doesn't look so great.

It's just a simpler kind of temporary replacement...

restart

Evaluation with `&varphi;`[0] indexed

eq := -t(0)+t(`&varphi;`(t)) = Int(1/sqrt(2*C*cos(`&varphi;`)-2*C*cos(`&varphi;`[X+abs(P)])), `&varphi;` = 0 .. `&varphi;`(t), continuous)

-t(0)+t(varphi(t)) = Int(1/(2*C*cos(varphi)-2*C*cos(varphi[X+abs(P)]))^(1/2), varphi = 0 .. varphi(t), continuous)

H := t(0) = 0, `&varphi;`(t) = `&varphi;`[X+abs(P)], t(`&varphi;`[X+abs(P)]) = (1/4)*T

t(0) = 0, varphi(t) = varphi[X+abs(P)], t(varphi[X+abs(P)]) = (1/4)*T

new := subs(H, eq)

(1/4)*T = Int(1/(2*C*cos(varphi)-2*C*cos(varphi[X+abs(P)]))^(1/2), varphi = 0 .. varphi[X+abs(P)], continuous)

cond := C > 0, 0 < `&varphi;`[X+abs(P)] and `&varphi;`[X+abs(P)] < Pi

0 < C, 0 < varphi[X+abs(P)] and varphi[X+abs(P)] < Pi

Rep := proc () options operator, arrow; subsindets([args], specindex(anything, varphi), proc (nm) options operator, arrow; freeze(__K(nm)) end proc)[] end proc

new2 := Rep(new)

subsindets(isolate(`assuming`([simplify(value(new2))], [Rep(cond)]), T), specfunc(__K), op)

T = 4*InverseJacobiAM((1/2)*varphi[X+abs(P)], csc((1/2)*varphi[X+abs(P)]))*csc((1/2)*varphi[X+abs(P)])/C^(1/2)

Without the replacement...

isolate(`assuming`([simplify(value(new))], [cond]), T)

T = 4*2^(1/2)*(-(limit(((-cos(varphi)+cos(varphi[X+abs(P)]))/(-1+cos(varphi[X+abs(P)])))^(1/2)*InverseJacobiAM((1/2)*varphi, csgn(sin((1/2)*varphi[X+abs(P)]))*csc((1/2)*varphi[X+abs(P)]))/(cos(varphi)-cos(varphi[X+abs(P)]))^(1/2), varphi = 0, right))*(cos(varphi[X+abs(P)])-cos(varphi[X+abs(P)][X+abs(P)]))^(1/2)+((-cos(varphi[X+abs(P)])+cos(varphi[X+abs(P)][X+abs(P)]))/(-1+cos(varphi[X+abs(P)][X+abs(P)])))^(1/2)*InverseJacobiAM((1/2)*varphi[X+abs(P)], csgn(sin((1/2)*varphi[X+abs(P)][X+abs(P)]))*csc((1/2)*varphi[X+abs(P)][X+abs(P)])))/(C^(1/2)*(cos(varphi[X+abs(P)])-cos(varphi[X+abs(P)][X+abs(P)]))^(1/2))

NULL

Download Evaluation_of_elliptic_integrals_acc.mw

@lemelinm You could also get that new list of equations, T, with,

    T:=(u->u=GetValue(Constant(u))*GetUnit(Constant(u)))~(L)

@Motocycle Mayor Perhaps when you saw the problematic behavior you had inadvertantly done a restart, or tried after only re-opening the Document.

@TechnicalSupport Fwiw the OP's original attachment shows that it was last saved in Maple 2025.1, so presumably that's the version he was using.

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

First 14 15 16 17 18 19 20 Last Page 16 of 609