emendes

455 Reputation

6 Badges

8 years, 167 days

MaplePrimes Activity


These are questions asked by emendes

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

 

Hello

I have no choice but use Grid:-Map and Grid:-Seq in my calculations due to the size of them.  Here is a very small example that is puzzling me (Perhaps I did something really silly and did not realize). 

ansa:=CodeTools:-Usage(Grid:-Map(w->CondswithOnesolutionTest(w,eqns,vars,newvars,tlim),conds5s)):

with the following result:

ansa:=set([{alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 1] = 0, alpha[3, 2] = 0, alpha[3, 3] = 0, alpha[3, 4] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}, {}, {}, {}, {}, {}], [{}, {}, {}, {}, {}, {alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 1] = 0, alpha[3, 2] = 0, alpha[3, 3] = 0, alpha[3, 5] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}], [{alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 1] = 0, alpha[3, 3] = 0, alpha[3, 4] = 0, alpha[3, 5] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}, {}, {}, {}, {}, {}], [{}, {}, {}, {}, {}, {alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 2] = 0, alpha[3, 3] = 0, alpha[3, 4] = 0, alpha[3, 5] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}])

The same thing but now using only map

ansb:=CodeTools:-Usage(map(w->CondswithOnesolutionTest(w,eqns,vars,newvars,tlim),conds5s)):
ansb:={[{}, {}, {}, {}, {}, {alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 1] = 0, alpha[3, 2] = 0, alpha[3, 3] = 0, alpha[3, 5] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}], [{}, {}, {}, {}, {}, {alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 2] = 0, alpha[3, 3] = 0, alpha[3, 4] = 0, alpha[3, 5] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}], [{alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 1] = 0, alpha[3, 2] = 0, alpha[3, 3] = 0, alpha[3, 4] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}, {}, {}, {}, {}, {}], [{alpha[1, 1] = 0, alpha[1, 2] = 0, alpha[1, 3] = 0, alpha[1, 4] = 0, alpha[1, 5] = 0, alpha[1, 6] = 0, alpha[1, 8] = 0, alpha[1, 9] = 0, alpha[2, 0] = 0, alpha[2, 1] = 0, alpha[2, 2] = 0, alpha[2, 4] = 0, alpha[2, 5] = 0, alpha[2, 7] = 0, alpha[2, 8] = 0, alpha[2, 9] = 0, alpha[3, 0] = 0, alpha[3, 1] = 0, alpha[3, 3] = 0, alpha[3, 4] = 0, alpha[3, 5] = 0, alpha[3, 6] = 0, alpha[3, 7] = 0, alpha[3, 8] = 0, alpha[3, 9] = 0}, {}, {}, {}, {}, {}]}

(This is what I expected as the result).

 

Why did Grid:-Map add set to the answer?  What am I missing?  

 

Many thanks

 

Hello

I need to detect if different expressions contain a radical. For example

aaa := X3*(alpha[2, 8]*(sqrt(X2/alpha[1, 7])*alpha[3, 8] + X1*alpha[3, 6])*X2 + X3*(alpha[2, 8] + alpha[3, 9]/2))/(X2*alpha[2, 8])

As can be noticed there is a square root in the expression.   

I have tried type(expr,sqrt) and has but to no avail. (I am not sure if I use them as they should though).   

Many thanks

 

Ed

 

Hello

Since this is my first attempt to use plots[animate], please forgive if my question is silly.  

I want to use plots[animate] with RootLocusPlot to show the effect of variable.   Here is my attempt.

num:=10*(s+alpha);den:=s*(s^2+4*s+8);
plots[animate](RootLocusPlot,[NewSystem(subs(alpha=a,num/den))],a=1..10);

Of course, when issuing the commands, an error comes out:  

Error, (in plots/animate) symbolic value(s) in model: a
 

  • Although I could define sys using NewSystem with a symbolic value, alpha, I have no idea how to assign a value for alpha.  subs(alpha=2,..) does not seem to work.
  • If I remove the square brackets in the second argument of plots[animate], a different msg comes out.  Why do I need (or not) them? 

Many thanks.

 

4 5 6 7 8 9 10 Last Page 6 of 15