emendes

410 Reputation

6 Badges

7 years, 327 days

MaplePrimes Activity


These are questions asked by emendes

Hello

I am trying to use Grid:-Seq to speed up some calculations.  To this end, I wrote the following procedure:

fun:=proc(model1::list,model2::list,vars::list,conds::set,tlim::numeric)
description "This function returns models with matching structures":
local ans1,ans2,res:=NULL:
if evalb(expand(model1)<>expand(model2)) then
     (ans1,ans2):=UtilsIORelation:-findMatchingStructures(subs(conds,model1),subs(conds,model2),vars,tlim):
     if nops(ans1) > 1 then
        res:=model1:
     end if:
end if:
return(res):
end proc:

I checked if the procedure works by issuing the following command

 

aux:=[seq](fun(modelX[i],model,vars,conds,2),i=1..nops(modelX)):

and it did work. The result is what I needed. 

But when I try it using Grid:-Seq instead of seq, I got the following error message:

infolevel[Grid:-Seq]:=3:
Grid:-Set(fun,findMatchingStructures,'model','vars','conds');
aux:=[Grid:-Seq](fun(modelX[i],model,vars,conds,2),i=1..nops(modelX)):

 

Error, (in fun) findMatchingStructures is not a command in the UtilsIORelation package.

 

What am I missing?   

Many thanks

 

 

 

Hello 

I need a procedure that given two lists of sets A and returns a list of lists such that L[i] is the list of j such that A[i] subset B[j]. Here is an example:

ans6 := [{alpha[1, 8], alpha[2, 2], alpha[2, 5], alpha[2, 8], alpha[3, 6], alpha[3, 9]}, {alpha[1, 8], alpha[2, 2], alpha[2, 5], alpha[2, 8], alpha[3, 3], alpha[3, 6]}, {alpha[1, 8], alpha[2, 2], alpha[2, 5], alpha[2, 7], alpha[3, 6], alpha[3, 8]}, {alpha[1, 8], alpha[2, 2], alpha[2, 5], alpha[2, 7], alpha[3, 3], alpha[3, 8]}, {alpha[1, 8], alpha[2, 2], alpha[2, 5], alpha[2, 7], alpha[3, 3], alpha[3, 6]}, {alpha[1, 8], alpha[2, 2], alpha[2, 4], alpha[2, 5], alpha[3, 3], alpha[3, 6]}, {alpha[1, 8], alpha[2, 1], alpha[2, 2], alpha[2, 5], alpha[3, 3], alpha[3, 6]}, {alpha[1, 8], alpha[2, 0], alpha[2, 2], alpha[2, 5], alpha[3, 3], alpha[3, 6]}, {alpha[1, 5], alpha[2, 8], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 5], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 5], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 6], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 6], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 7], alpha[3, 8]}]:

ans7 := [{alpha[1, 8], alpha[2, 2], alpha[2, 5], alpha[2, 7], alpha[3, 3], alpha[3, 6], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 5], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 5], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 6], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 6], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 7]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 5], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 5], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 4], alpha[3, 7], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 4], alpha[3, 6], alpha[3, 8], alpha[3, 9]}, {alpha[1, 5], alpha[2, 8], alpha[3, 2], alpha[3, 4], alpha[3, 6], alpha[3, 7], alpha[3, 9]}]:

and my procedure

SubsetPairs:= (A::list(set), B::list(set))->
    map(z-> [ListTools:-SearchAll](true, map(w-> z subset w, B)), A)
:
SubsetPairs(ans6, ans7);

The result of applying SubsetPairs is:

[[], [], [1], [1], [1], [], [], [], [2, 3, 8, 23], [2, 4, 9, 24], [2, 5, 10, 25], [2, 6, 11, 26], [2, 7, 12, 27], [3, 4, 13, 28], [3, 5, 14, 29], [3, 6, 15, 30], [3, 7, 16], [4, 5, 17], [4, 6, 18], [4, 7, 19]]

When it is used for long lists, it takes a long time to return the results.  I wonder if a more time- and memory-efficient code can be implemented (perhaps Threads or Grid can be used).

In addition to that, how can a diagram (figure, plot, ...) be drawn to show which subset of the first list is linked to which subsets of the second list (including no link as well).  The length of the first list is always smaller than the length of the second list.  

Many thanks

 

Hello

I am not familiar with the use of notsero in SolveTools:-PolynomialSystem. Is there any special syntax to use it?  In the following example, the trivial solution {x=0,y=0} is to be eliminated.  

SolveTools:-PolynomialSystem({x*(x^2 - 2), y*(y^2 - 2)}, {x, y},explicit=true)

If I issue the command

SolveTools:-PolynomialSystem({x*(x^2 - 2), y*(y^2 - 2)}, {x, y},{x,y},explicit=true)

all roots with either x=0 or y=0 are eliminated.  

Can netzero be used to eliminate only the trivial solution?  

 

Many thanks

 

 

Hello

I need to check if the solution of a polynomial system (for instance a set of polynomial equations in y and z) using two different approaches is the same (equal or symmetric).  I thought if I use simplify plus abs I could solve the problem, but that is not the case.   Here is an example;

The first method returns the following solution:

aa := {{y = -2*X1*X2*alpha[1, 8]*alpha[2, 6]/(sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) + alpha[1, 8]^2*alpha[2, 4]*X1^2 + X2*alpha[1, 8]*(alpha[2, 8] + alpha[3, 9])), z = (-sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) - alpha[1, 8]^2*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2*alpha[1, 8])/(2*alpha[1, 8]^2*alpha[2, 6]*X1)}, {y = -2*X2*alpha[1, 8]*alpha[2, 6]*X1/(-sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) + alpha[1, 8]^2*alpha[2, 4]*X1^2 + X2*alpha[1, 8]*(alpha[2, 8] + alpha[3, 9])), z = (sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) - alpha[1, 8]^2*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2*alpha[1, 8])/(2*alpha[1, 8]^2*alpha[2, 6]*X1)}}

and the second Method:

bb := {{y = -2*X2*alpha[2, 6]*X1/(-sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) + (alpha[2, 8] + alpha[3, 9])*X2 + alpha[1, 8]*alpha[2, 4]*X1^2), z = (sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) - alpha[1, 8]*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2)/(2*alpha[1, 8]*alpha[2, 6]*X1)}, {y = -2*X2*alpha[2, 6]*X1/(sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) + alpha[1, 8]*alpha[2, 4]*X1^2 + (alpha[2, 8] + alpha[3, 9])*X2), z = (-sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) - alpha[1, 8]*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2)/(2*alpha[1, 8]*alpha[2, 6]*X1)}}

Notice (if I am not mistaken) that the first pair of the first solution is equal to the second pair of the second solution.   If I compare them using evalb(simplify(aa[1,1])=simplify(bb[2,1])), Maple returns false.  Again, if I am not mistaken I think they are the same.

a) How can the solutions be compared?

b) I also need to determine if there are symmetric roots in a set of solutions (either in aa or in bb) and a procedure that returns just one solution.  Something like:

func:=(auxsolsx,varsx)->`if`(nops(map(v->op(map(w->abs(subs(w[ListTools:-Search(v,varsx)],v)),auxsolsx)),varsx))=2,ifelse(nops(auxsolsx)=1,auxsolsx,{auxsolsx[1]}),NULL):

Many thanks

 

 

 

Hello

I am trying to use Threads in my procedures as much as possible.  However, one of them returned different results when compared to map or Grid:-Map (I have checked if the used functions are threadsafe (perhaps I miss something)).  Here is the procedure (optimization of the code is most welcome).

searchMonomialsEqns:=proc(conds::set,Eqns::list,Vars::list,poolofeqns::list(list))
description "Find if a set of monomials in an equation can be found in a pool of monomials and returns the condition when it is true":
local A:=Array(1..0),
      C,
      i,
      res,
      n:=numelems(Eqns):
#  Find the monomials of Eqns
res:=subs(conds,Eqns):
for i from 1 to n do
    C:= coeffs(expand(lhs(res[i])-rhs(res[i])),Vars, 'M'):
    A,={M}:
end do:
ifelse(member([seq(A)],poolofeqns)=false,NULL,conds):
end proc:

1) Threads:-Map

ans1:=CodeTools:-Usage(Threads:-Map(w->searchMonomialsEqns(w,eqns[1..2],vars[2..3],validYZeqnMon),conds5)):nops(ans1);

returns

memory used=0.58GiB, alloc change=139.56MiB, cpu time=40.23s, real time=11.12s, gc time=1.01s

                              8613

 

2) map

ans2:=CodeTools:-Usage(map(w->searchMonomialsEqns(w,eqns[1..2],vars[2..3],validYZeqnMon),conds5)):nops(ans2);

returns

memory used=0.57GiB, alloc change=-4.00MiB, cpu time=22.48s, real time=21.55s, gc time=1.70s

                              8637

3) Grid:-Map

ans3:=CodeTools:-Usage(Grid:-Map(w->searchMonomialsEqns(w,eqns[1..2],vars[2..3],validYZeqnMon),conds5)):nops(ans3);

return

memory used=23.29MiB, alloc change=21.88MiB, cpu time=3.77s, real time=2.25s, gc time=3.14s

                              8637

Although the number of elements is the same, Grid:-Map returns the result with set function mentioned in my previous post. (I am aware that CodeTools:-Usage is pointless here).

4) Threads:-Seq

ans4:=CodeTools:-Usage([Threads:-Seq](searchMonomialsEqns(conds5[i],eqns[1..2],vars[2..3],validYZeqnMon),i=1..nops(conds5))):nops(ans4);

returns

memory used=0.58GiB, alloc change=0 bytes, cpu time=33.99s, real time=8.68s, gc time=644.74ms

                              8622

What am I missing?   

Many thanks

Ed

 

2 3 4 5 6 7 8 Last Page 4 of 14