2
$\begingroup$

I have a list of differentiated expression of the form {f[0,0,0],(f^(a,b,c))[0,0,0],...} where I have left the function as a general f[x,y,z], and (f^(a,b,c))[0,0,0] is the derivative w.r.t. x a times evaluated at [x,y,z]=[0,0,0]. The list itself is output from a power series expansion

 Tn[n_] := Normal[Series[f[x,y,z],{x,0,n},{y,0,n},{z,0,n}]]
 TnList[n_]:=List@@Tn[n]

After some additional operations that reduce the number of terms I'm using, I want to substitute and evaluate the list for a specific function. I have tried numerous options, mainly of the form

 fMap[n_] := Map[ReplaceAll[f-> Function[{x,y,z},Exp[-U[x,y,z]]], TnList[n]]

However, if I try going past say a 3rd order expansion (n=3), the time to evaluate the list starts drastically increasing. I have also tried

 Parallelize[fMap[n]]

but have seen very minimal change, such that I can't even tell if it's doing anything different. Sadly, CUDAMap doesn't work on symbols, so that's also ruled out.

Can anyone suggest a method to speed up this process? It's the only bottleneck in my notebook, and I'd like to fix it.

$\endgroup$
  • $\begingroup$ Have you tried ParallelMap instead of Map and then Parallelize ? $\endgroup$ – Lotus Oct 12 '17 at 3:11
  • $\begingroup$ Can you provide a realistic example without an undefined function U? It's not the replacement that takes long, it's the evaluation of the derivatives which is the bottleneck. $\endgroup$ – halirutan Oct 12 '17 at 3:27
  • $\begingroup$ I have tried ParallelMap as well, and saw a similar performance. The function I'm including looks like: U[x,y,z] := A(x^2 y^2 + x^2 z^2 + y^2 z^2) +B(x^2 y^2 z^2) $\endgroup$ – jpdomann Oct 12 '17 at 11:09
  • $\begingroup$ I realize this process needs to constantly evaluate the same derivatives over and over again, so is there an efficient way to store the previous //Simplify'd solutions instead of constantly recalculating them? $\endgroup$ – jpdomann Oct 12 '17 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.