Question: Can this procedure be parallelized?

Hello

I wonder if there is a way to parallelize the function listed below.   It deals with a set of sets (dynamical systems).  As far as I can see the problem is with subs and simplify.  In some cases a division by zero shows up (the reason I added try..catch and had to use for). 

The procedure should remove the systems with imaginary coefficients and return the valid indices.  

Many thanks

Ed

Obs.:  The number of dynamical systems can easily be greater than 10,000.  Any speed improvement is welcome.

Example of one such a dynamical system is

[(-x*rho*xi[6]*(beta - 1)*sqrt(((rho + beta - 1)*sigma - beta + 1)^2*xi[8]^2/(beta - 1)^2) - xi[8]*(-2*y*sigma*xi[7]*xi[6]^2*(beta - 1)^2 + (sigma*rho + (sigma + 1)*(beta - 1))*x*rho*xi[6] + 2*sigma*z*rho^2*xi[8]))/(2*xi[6]*xi[8]*rho*(beta - 1)), (-(beta - 1)*(-y*sigma*xi[7]*xi[6]^2*(beta - 1)^2 + rho^2*(sigma*z*xi[8] + x^2))*xi[6]*sqrt(((rho + beta - 1)*sigma - beta + 1)^2*xi[8]^2/(beta - 1)^2) - (2*sigma*(beta - 1)^2*(y*xi[7]*(rho + beta - 1)*sigma/2 + x^2*rho + y*(beta - 1)*xi[7]/2)*xi[6]^3 + 2*x*z*rho*sigma*xi[8]*(beta - 1)^2*xi[6]^2 + (-z*xi[8]*(rho + beta - 1)*sigma^2 + ((2*beta^2*z - 3*beta*z + z)*xi[8] + x^2*rho - (beta - 1)*(-2*beta*y*xi[7] + x^2))*sigma + x^2*(beta - 1))*rho^2*xi[6] + 2*x*z*rho^3*sigma*xi[8])*xi[8])/(2*xi[8]*sigma*(beta - 1)*(rho^2 + (beta - 1)^2*xi[6]^2)*xi[6]*xi[7]), (-(-x*sigma*(beta - 1)^2*xi[6]^3 + (beta - 1)^2*(sigma*y*xi[7] + x^2)*xi[6]^2 - rho^2*sigma*x*xi[6] - sigma*z*rho^2*xi[8])*(beta - 1)*rho*sqrt(((rho + beta - 1)*sigma - beta + 1)^2*xi[8]^2/(beta - 1)^2) + xi[8]*(-2*y*sigma^2*xi[7]*(beta - 1)^4*xi[6]^4 + 2*(rho*(rho + beta - 1)*sigma/2 + (beta - 1)*((-beta + 1/2)*rho + y*(beta - 1)*xi[7]))*sigma*(beta - 1)^2*x*xi[6]^3 + (beta - 1)^2*(((-y*xi[7] + 2*z*xi[8])*rho + y*(beta - 1)*xi[7])*sigma^2 + (x^2*rho + (beta - 1)*(-2*beta*y*xi[7] - 2*beta*z*xi[8] + x^2 + y*xi[7]))*sigma - x^2*(beta - 1))*rho*xi[6]^2 + 2*(rho*(rho + beta - 1)*sigma/2 + (beta - 1)*((-beta + 1/2)*rho + y*(beta - 1)*xi[7]))*sigma*x*rho^2*xi[6] + xi[8]*sigma*z*((rho - beta + 1)*sigma - beta + 1)*rho^3))/(2*xi[8]^2*sigma*(beta - 1)*rho*(rho^2 + (beta - 1)^2*xi[6]^2))]

coefmodel

{beta = 8/3, rho = 28, sigma = 10}

and phi and coe equal to 

[[], [], []]

 

cleanSystems := proc(sys::list,phi::list,coe::list,coefmodel::{list,set})
description "This function applies coefficient values to a system and remove it if the coef is somehow imaginary":
local i,aaa:=table(),bbb:=table(),ccc:=table(),ind:=table():
for i from 1 to nops(sys) do
  try
   aaa[i]:=simplify(subs(coefmodel,sys[i])):
   if has(aaa[i],I) then
      aaa[i]:=NULL:
      bbb[i]:=NULL:
      ccc[i]:=NULL:
      ind[i]:=NULL:
   else
      bbb[i]:=simplify(subs(coefmodel,phi[i])):
      ccc[i]:=simplify(subs(coefmodel,coe[i])):
      ind[i]:=i:
   end if:
  catch:
   aaa[i]:=NULL:
   bbb[i]:=NULL:
   ccc[i]:=NULL:
   ind[i]:=NULL:
  end try:
end do:
aaa:=convert(aaa,list):print(nops(aaa)):
bbb:=convert(bbb,list):print(nops(bbb)):
ccc:=convert(ccc,list):print(nops(ccc)):
ind:=convert(ind,list):print(nops(ind)):
return(aaa,bbb,ccc,ind):
end proc:

 

Please Wait...