# Series expansion really slow

UPDATE

Seems the problem is associated with the division. I've tried taking the Normal[Series[]] of each numerator and denominator separately, and then again taking the Normal[Series[]] of that, and it is fairly fast for order 5 and 5, but still a long time (I didn't wait) for orders 10. Also a lot of extra overhead I would think...

Is there some alternative division algorithm I can implement?

UPDATE 2

By looking here, Multivariate series expansions to different powers, I used a dummy variable and now it all seems to work adequately, though still not as fast.

For just the i=1 and j=1 case, I get,

a1 =
Assuming[Im[z1] >= 0 && Im[z2] >= 0 && Re[z1] > 0 && Re[z2] > 0,
Refine[
((D[tmpTofZ[1, z1, TSvz], z1]*
D[tmpTofZ[1, z2, TSvz], z2])/(tmpTofZ[1, z1, TSvz] -
tmpTofZ[1, z2, TSvz])^2 - If[1 == 1, 1/(z1 - z2)^2, 0]) /.
z1 -> t*z1 /. z2 -> t*z2,
z1 ∈ Reals && z2 ∈ Reals]
]

During evaluation of In[93]:= DynamicSolve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[93]:= DynamicSeries::serlim: Series order specification TSvz is not a machine-sized integer.

During evaluation of In[93]:= DynamicSolve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[93]:= DynamicSeries::serlim: Series order specification TSvz is not a machine-sized integer.

During evaluation of In[93]:= DynamicSolve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[93]:= DynamicGeneral::stop: Further output of Solve::ifun will be suppressed during this calculation.

During evaluation of In[93]:= DynamicSeries::serlim: Series order specification TSvz is not a machine-sized integer.

During evaluation of In[93]:= DynamicGeneral::stop: Further output of Series::serlim will be suppressed during this calculation.

Out[93]= -(
1/(t z1 -
t z2)^2) + ((-E^(-t^2 z1^2) (-I + E^(t^2 z1^2) -
Sqrt[-1 + E^(2 t^2 z1^2)]) t z1 +
1/2 E^(-t^2 z1^2) (2 E^(t^2 z1^2) t z1 - (
2 E^(2 t^2 z1^2) t z1)/
Sqrt[-1 + E^(2 t^2 z1^2)])) (-E^(-t^2 z2^2) (-I + E^(
t^2 z2^2) - Sqrt[-1 + E^(2 t^2 z2^2)]) t z2 +
1/2 E^(-t^2 z2^2) (2 E^(t^2 z2^2) t z2 - (
2 E^(2 t^2 z2^2) t z2)/Sqrt[-1 + E^(2 t^2 z2^2)])))/(1/
2 E^(-t^2 z1^2) (-I + E^(t^2 z1^2) -
Sqrt[-1 + E^(2 t^2 z1^2)]) -
1/2 E^(-t^2 z2^2) (-I + E^(t^2 z2^2) -
Sqrt[-1 + E^(2 t^2 z2^2)]))^2

a2 =
Assuming[Im[z1] >= 0 && Im[z2] >= 0 && Re[z1] > 0 && Re[z2] > 0,
Refine[Normal[Series[a1, {t, 0, 10}]],
z1 ∈ Reals && z2 ∈ Reals]]
a3 = a2 /. t -> 1
a4 = Simplify[a3]

Out[96]= (1/967680)(-869 z1^10 - 320 z1^9 z2 + 639 z1^8 z2^2 +
1280 z1^7 z2^3 + 256 z1^3 z2^3 (-63 + 5 z2^4) -
384 z1^5 z2 (-21 + 5 z2^4) - 210 z1^4 z2^2 (12 + 5 z2^4) -
42 z1^6 (-252 + 25 z2^4) + z2^2 (-120960 + 10584 z2^4 - 869 z2^8) -
64 z1 z2 (2520 - 126 z2^4 + 5 z2^8) +
9 z1^2 (-13440 - 280 z2^4 + 71 z2^8))

a5 = FullSimplify[a4] // Expand

Out[97]= -(z1^2/8) + (7 z1^6)/640 - (869 z1^10)/967680 - (z1 z2)/6 + (
z1^5 z2)/120 - (z1^9 z2)/3024 - z2^2/8 - (z1^4 z2^2)/384 + (
71 z1^8 z2^2)/107520 - (z1^3 z2^3)/60 + (z1^7 z2^3)/756 - (
z1^2 z2^4)/384 - (5 z1^6 z2^4)/4608 + (z1 z2^5)/120 - (
z1^5 z2^5)/504 + (7 z2^6)/640 - (5 z1^4 z2^6)/4608 + (
z1^3 z2^7)/756 + (71 z1^2 z2^8)/107520 - (z1 z2^9)/3024 - (
869 z2^10)/967680


I realize of course that square root is multi-valued, so making some concessions, I utilized some Refine[] and Assuming[] to finally get some answers. Of course the assumptions are not physically required - they are locations on a Riemann surface and so z1 and z2 can have negative values. I think this could be done...just wanted to correct the Thread problem I had that, now corrected, doesn't have the exponentials hanging around. I suppose I could get results (different probably?) using assumptions on both z1 and z2 from all four quadrants of the complex plane... Still curious about that...

I guess another big lingering question is why, up to order 4 and 4, I did not need Assuming[], and yet afterwards did... or maybe just days worth of computational time?

I have some Maxima code I am converting to Mathematica and I notice that around the cutoff of "4" to "5" for a Series, the time it takes increases a huge amount. Here is the problem,

curve = 1 - Q*b - a*(b^f)*(1 - b) /. Q -> 2 /. f -> 1
sol2 = Solve[{curve == 0, b == t}, {a, b}]
sol = {u -> Log[a], v -> Log[b]} /. sol2
curveUV = curve /. a -> Exp[u] /. b -> Exp[v]
aiT1 = u /. sol[[1]][[1]]
aiT2 = D[aiT1, t] // FullSimplify
ai = Solve[aiT2 == 0, t]
N = Length[ai]
uai[i_] := (u /. sol[[1]][[1]]) /. ai[[i]][[1]]
uofz[i_, z_] := z^2 + uai[i]
duofz[i_, z_] := D[uofz[i, z], z]
tmpEq[i_, Z_] := curveUV /. u -> uofz[i, Z]
tmpSol[i_, z_] := Solve[tmpEq[i, z] == 0, v]
vofz[i_, z_, TSvz_] := FullSimplify[Normal[Series[v /. tmpSol[i, z][[1]], {z, 0, TSvz}]]]
tmpTofZ[i_, z_, TSvz_] := Exp[vofz[i, z, TSvz]] // FullSimplify


What I next want to do is build expressions (4, as i and j each range from 1 to 2) where I can extract the regular terms of this series.

 RegTerms[i_, j_, z1_, z2_, TSvz_, TS1_, TS2_] :=
(*Simplify[*)
Normal[
Series[
(*Simplify[*)
(*Expand[*)
(D[tmpTofZ[i, z1, TSvz], z1]*
D[tmpTofZ[j, z2, TSvz], z2])/(tmpTofZ[i, z1, TSvz] -
tmpTofZ[j, z2, TSvz])^2 - If[i == j, 1/(z1 - z2)^2, 0]
(*]*)
(*]*)
, {z1, 0, TS1}, {z2, 0, TS2}
]
]


So I want to extract the coefficients for later use (lots of use), so I think of a table,

** edit: The time issue is the same, but the 'RT' wasn't there - copy/paste error, can just ignore the 'RT'. **

Timing[
Table[
RT[i, j] =
FullSimplify[
RegTerms[i, j, z1, z2, 15, 4, 4]
]
, {i, 1, 2}
, {j, 1, 2}
]
]


and these are the timing results;

For series expansion orders of 2 and 2 -- about 2 seconds:

In[130]:= Timing[
Table[
RT[i, j] =
FullSimplify[
RegTerms[i, j, z1, z2, 15, 2, 2]
]
, {i, 1, 2}
, {j, 1, 2}
]
]

During evaluation of In[130]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[130]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[130]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[130]:= General::stop: Further output of Solve::ifun will be suppressed during this calculation.

Out[130]= {1.8701, {{1/24 (-3 z1^2 - 4 z1 z2 - 3 z2^2),
1/8 (-4 - z1 z2 (4 + 3 z1 z2))}, {1/8 (-4 - z1 z2 (4 + 3 z1 z2)),
1/24 (-3 z1^2 - 4 z1 z2 - 3 z2^2)}}}


For series expansion orders of 3 and 3 -- about 3 seconds:

In[131]:= Timing[
Table[
RT[i, j] =
FullSimplify[
RegTerms[i, j, z1, z2, 15, 3, 3]
]
, {i, 1, 2}
, {j, 1, 2}
]
]

During evaluation of In[131]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[131]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[131]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[131]:= General::stop: Further output of Solve::ifun will be suppressed during this calculation.

Out[131]= {2.92662, {{1/
120 (-15 z1^2 - 20 z1 z2 - 15 z2^2 - 2 z1^3 z2^3),
1/8 (-4 - z1 z2 (4 + z1 z2 (3 + 2 z1 z2)))}, {1/
8 (-4 - z1 z2 (4 + z1 z2 (3 + 2 z1 z2))),
1/120 (-15 z1^2 - 20 z1 z2 - 15 z2^2 - 2 z1^3 z2^3)}}}


For series expansion orders of 4 and 4 -- about 38 seconds:

In[132]:= Timing[
Table[
RT[i, j] =
FullSimplify[
RegTerms[i, j, z1, z2, 15, 4, 4]
]
, {i, 1, 2}
, {j, 1, 2}
]
]

During evaluation of In[132]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[132]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[132]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

During evaluation of In[132]:= General::stop: Further output of Solve::ifun will be suppressed during this calculation.

Out[132]= {38.4277, {{(-320 z1 z2 - 240 z2^2 - 5 z1^4 z2^2 -
32 z1^3 z2^3 - 5 z1^2 (48 + z2^4))/
1920, -(1/2) - (z1 z2)/2 - (3 z1^2 z2^2)/8 - (z1^3 z2^3)/4 + (
5 z2^4)/48 + (5 z1^4 (24 - 41 z2^4))/1152}, {-(1/2) - (z1 z2)/
2 - (3 z1^2 z2^2)/8 - (z1^3 z2^3)/4 + (5 z2^4)/48 + (
5 z1^4 (24 - 41 z2^4))/1152, (-320 z1 z2 - 240 z2^2 -
5 z1^4 z2^2 - 32 z1^3 z2^3 - 5 z1^2 (48 + z2^4))/1920}}}


To order 5 and 5, it takes so long I just kill it as I know for what I want, orders 10 and 10 or more, it would be a lifetime.

I don't claim to know much about Mathematica, actually fairly new to it, and I know each CAS has its advantages and disadvantages, but to order 10 (10,10), Maxima does this exactly in about 5 seconds or less.

Is there something obvious that I am doing wrong?

PS Any suggestions on better methods (e.g. pure functions, this or that, etc.) is greatly appreciated too!

I think it's best to not use Normal and then Series again as you do. There are two basic approaches that I typically use for finding series expansions.

1. Apply Series to the expression
2. Replace an argument of the expression with a Series version.

So, the first step is to find the expression. Consider your expressions:

v /. tmpSol[1, z][[1]]
v /. tmpSol[2, z][[1]]


Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

Log[1/2 (1 - I E^-z^2 - E^-z^2 Sqrt[-1 + E^(2 z^2)])]

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

Log[1/2 (1 + I E^-z^2 - E^-z^2 Sqrt[-1 + E^(2 z^2)])]

These are the basic expressions you are dealing with. Define:

tofz[1, z_] = v /. tmpSol[1,z][[1]];
tofz[2, z_] = v /. tmpSol[2,z][[1]];


Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

Then, the expressions for which you want to find the series are:

expr[i_, j_] := (D[tofz[i, z1],z1] D[tofz[j,z2],z2])/(tofz[i,z1]-tofz[j,z2])^2-Boole[i==j]/(z1-z2)^2


To make the series expansions faster, use FullSimplify (and Together for the diagonal elements):

Do[
s[i, j] = FullSimplify[Together[expr[i, j]], z1>0 && z2>0],
{i, 2}, {j, 2}
] //AbsoluteTiming


{16.1647, Null}

Rather than doing a double series in z1 and z2, I will also scale each variable by a factor t (as you do in your update) and then do a single series in t. Let's compare doing an external series vs an internal series approach.

External:

Assuming[
t>0 && z1>0 && z2>0,
r1 = Simplify @ Series[s[1, 1] /. {z1 -> t z1, z2 -> t z2}, {t, 0, 10}]
]; //AbsoluteTiming
Expand /@ r1 //TeXForm


{22.4073, Null}

$$t^2 \left(-\frac{\text{z1}^2}{8}-\frac{\text{z1} \text{z2}}{6}-\frac{\text{z2}^2}{8}\right)+t^6 \left(\frac{7 \text{z1}^6}{640}+\frac{\text{z1}^5 \text{z2}}{120}-\frac{\text{z1}^4 \text{z2}^2}{384}-\frac{\text{z1}^3 \text{z2}^3}{60}-\frac{\text{z1}^2 \text{z2}^4}{384}+\frac{\text{z1} \text{z2}^5}{120}+\frac{7 \text{z2}^6}{640}\right)+t^{10} \left(-\frac{869 \text{z1}^{10}}{967680}-\frac{\text{z1}^9 \text{z2}}{3024}+\frac{71 \text{z1}^8 \text{z2}^2}{107520}+\frac{\text{z1}^7 \text{z2}^3}{756}-\frac{5 \text{z1}^6 \text{z2}^4}{4608}-\frac{\text{z1}^5 \text{z2}^5}{504}-\frac{5 \text{z1}^4 \text{z2}^6}{4608}+\frac{\text{z1}^3 \text{z2}^7}{756}+\frac{71 \text{z1}^2 \text{z2}^8}{107520}-\frac{\text{z1} \text{z2}^9}{3024}-\frac{869 \text{z2}^{10}}{967680}\right)+O\left(t^{11}\right)$$

For readability, I left the t series. Using Normal and replacing t->1will eliminate t. Now for the internal version:

Assuming[
t>0 && z1>0 && z2>0,
r2 = Simplify[s[1, 1] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^10]
]; //AbsoluteTiming
Expand /@ r2 //TeXForm


{0.014836, Null}

$$t^2 \left(-\frac{\text{z1}^2}{8}-\frac{\text{z1} \text{z2}}{6}-\frac{\text{z2}^2}{8}\right)+O\left(t^4\right)$$

The problem with using the internal method is that the series order of the output can be less than the input order. In this case we have to raise the order significantly to obtain the same result:

Assuming[
t>0 && z1>0 && z2>0,
r2 = Simplify[s[1, 1] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^17]
]; //AbsoluteTiming
Expand /@ r2 //TeXForm


{1.15994, Null}

$$t^2 \left(-\frac{\text{z1}^2}{8}-\frac{\text{z1} \text{z2}}{6}-\frac{\text{z2}^2}{8}\right)+t^6 \left(\frac{7 \text{z1}^6}{640}+\frac{\text{z1}^5 \text{z2}}{120}-\frac{\text{z1}^4 \text{z2}^2}{384}-\frac{\text{z1}^3 \text{z2}^3}{60}-\frac{\text{z1}^2 \text{z2}^4}{384}+\frac{\text{z1} \text{z2}^5}{120}+\frac{7 \text{z2}^6}{640}\right)+t^{10} \left(-\frac{869 \text{z1}^{10}}{967680}-\frac{\text{z1}^9 \text{z2}}{3024}+\frac{71 \text{z1}^8 \text{z2}^2}{107520}+\frac{\text{z1}^7 \text{z2}^3}{756}-\frac{5 \text{z1}^6 \text{z2}^4}{4608}-\frac{\text{z1}^5 \text{z2}^5}{504}-\frac{5 \text{z1}^4 \text{z2}^6}{4608}+\frac{\text{z1}^3 \text{z2}^7}{756}+\frac{71 \text{z1}^2 \text{z2}^8}{107520}-\frac{\text{z1} \text{z2}^9}{3024}-\frac{869 \text{z2}^{10}}{967680}\right)+O\left(t^{11}\right)$$

As you can see, the internal method is significantly faster. For the off-diagonal elements, the replacement doesn't need to be quite as high an order to get the same order in the output:

Assuming[
t>0 && z1>0 && z2>0,
r3 = Simplify[s[1, 2] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^12]
]; //AbsoluteTiming
Expand/@r3 //TeXForm


{0.618868, Null}

$$-\frac{1}{2}-\frac{1}{2} t^2 (\text{z1} \text{z2})+t^4 \left(\frac{5 \text{z1}^4}{48}-\frac{3 \text{z1}^2 \text{z2}^2}{8}+\frac{5 \text{z2}^4}{48}\right)+t^6 \left(\frac{\text{z1}^5 \text{z2}}{8}-\frac{\text{z1}^3 \text{z2}^3}{4}+\frac{\text{z1} \text{z2}^5}{8}\right)+t^8 \left(-\frac{19 \text{z1}^8}{1280}+\frac{7 \text{z1}^6 \text{z2}^2}{64}-\frac{205 \text{z1}^4 \text{z2}^4}{1152}+\frac{7 \text{z1}^2 \text{z2}^6}{64}-\frac{19 \text{z2}^8}{1280}\right)+t^{10} \left(-\frac{\text{z1}^9 \text{z2}}{48}+\frac{\text{z1}^7 \text{z2}^3}{12}-\frac{\text{z1}^5 \text{z2}^5}{8}+\frac{\text{z1}^3 \text{z2}^7}{12}-\frac{\text{z1} \text{z2}^9}{48}\right)+O\left(t^{11}\right)$$

Here are the 4 terms to order 14.

s[1,1]:

Assuming[
t>0 && z1>0 && z2>0,
s11 = Expand /@ Simplify[s[1, 1] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^21]
]; //AbsoluteTiming
s11 //TeXForm


{10.3034, Null}

$$t^2 \left(-\frac{\text{z1}^2}{8}-\frac{\text{z1} \text{z2}}{6}-\frac{\text{z2}^2}{8}\right)+t^6 \left(\frac{7 \text{z1}^6}{640}+\frac{\text{z1}^5 \text{z2}}{120}-\frac{\text{z1}^4 \text{z2}^2}{384}-\frac{\text{z1}^3 \text{z2}^3}{60}-\frac{\text{z1}^2 \text{z2}^4}{384}+\frac{\text{z1} \text{z2}^5}{120}+\frac{7 \text{z2}^6}{640}\right)+t^{10} \left(-\frac{869 \text{z1}^{10}}{967680}-\frac{\text{z1}^9 \text{z2}}{3024}+\frac{71 \text{z1}^8 \text{z2}^2}{107520}+\frac{\text{z1}^7 \text{z2}^3}{756}-\frac{5 \text{z1}^6 \text{z2}^4}{4608}-\frac{\text{z1}^5 \text{z2}^5}{504}-\frac{5 \text{z1}^4 \text{z2}^6}{4608}+\frac{\text{z1}^3 \text{z2}^7}{756}+\frac{71 \text{z1}^2 \text{z2}^8}{107520}-\frac{\text{z1} \text{z2}^9}{3024}-\frac{869 \text{z2}^{10}}{967680}\right)+t^{14} \left(\frac{2339 \text{z1}^{14}}{30965760}+\frac{\text{z1}^{13} \text{z2}}{86400}-\frac{1807 \text{z1}^{12} \text{z2}^2}{30965760}-\frac{\text{z1}^{11} \text{z2}^3}{14400}+\frac{781 \text{z1}^{10} \text{z2}^4}{4423680}+\frac{\text{z1}^9 \text{z2}^5}{5760}-\frac{7 \text{z1}^8 \text{z2}^6}{819200}-\frac{\text{z1}^7 \text{z2}^7}{4320}-\frac{7 \text{z1}^6 \text{z2}^8}{819200}+\frac{\text{z1}^5 \text{z2}^9}{5760}+\frac{781 \text{z1}^4 \text{z2}^{10}}{4423680}-\frac{\text{z1}^3 \text{z2}^{11}}{14400}-\frac{1807 \text{z1}^2 \text{z2}^{12}}{30965760}+\frac{\text{z1} \text{z2}^{13}}{86400}+\frac{2339 \text{z2}^{14}}{30965760}\right)+O\left(t^{15}\right)$$

s[1,2];

Assuming[
t>0 && z1>0 && z2>0,
s12 = Expand /@ Simplify[s[1, 2] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^16]
]; //AbsoluteTiming
s12 //TeXForm


{12.7406, Null}

$$-\frac{1}{2}-\frac{1}{2} t^2 (\text{z1} \text{z2})+t^4 \left(\frac{5 \text{z1}^4}{48}-\frac{3 \text{z1}^2 \text{z2}^2}{8}+\frac{5 \text{z2}^4}{48}\right)+t^6 \left(\frac{\text{z1}^5 \text{z2}}{8}-\frac{\text{z1}^3 \text{z2}^3}{4}+\frac{\text{z1} \text{z2}^5}{8}\right)+t^8 \left(-\frac{19 \text{z1}^8}{1280}+\frac{7 \text{z1}^6 \text{z2}^2}{64}-\frac{205 \text{z1}^4 \text{z2}^4}{1152}+\frac{7 \text{z1}^2 \text{z2}^6}{64}-\frac{19 \text{z2}^8}{1280}\right)+t^{10} \left(-\frac{\text{z1}^9 \text{z2}}{48}+\frac{\text{z1}^7 \text{z2}^3}{12}-\frac{\text{z1}^5 \text{z2}^5}{8}+\frac{\text{z1}^3 \text{z2}^7}{12}-\frac{\text{z1} \text{z2}^9}{48}\right)+t^{12} \left(\frac{715 \text{z1}^{12}}{387072}-\frac{319 \text{z1}^{10} \text{z2}^2}{15360}+\frac{379 \text{z1}^8 \text{z2}^4}{6144}-\frac{133 \text{z1}^6 \text{z2}^6}{1536}+\frac{379 \text{z1}^4 \text{z2}^8}{6144}-\frac{319 \text{z1}^2 \text{z2}^{10}}{15360}+\frac{715 \text{z2}^{12}}{387072}\right)+t^{14} \left(\frac{17 \text{z1}^{13} \text{z2}}{5760}-\frac{17 \text{z1}^{11} \text{z2}^3}{960}+\frac{17 \text{z1}^9 \text{z2}^5}{384}-\frac{17 \text{z1}^7 \text{z2}^7}{288}+\frac{17 \text{z1}^5 \text{z2}^9}{384}-\frac{17 \text{z1}^3 \text{z2}^{11}}{960}+\frac{17 \text{z1} \text{z2}^{13}}{5760}\right)+O\left(t^{15}\right)$$

s[2,1];

Assuming[
t>0 && z1>0 && z2>0,
s21 = Expand /@ Simplify[s[2, 1] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^16]
]; //AbsoluteTiming
s21 //TeXForm


{12.6654, Null}

$$-\frac{1}{2}-\frac{1}{2} t^2 (\text{z1} \text{z2})+t^4 \left(\frac{5 \text{z1}^4}{48}-\frac{3 \text{z1}^2 \text{z2}^2}{8}+\frac{5 \text{z2}^4}{48}\right)+t^6 \left(\frac{\text{z1}^5 \text{z2}}{8}-\frac{\text{z1}^3 \text{z2}^3}{4}+\frac{\text{z1} \text{z2}^5}{8}\right)+t^8 \left(-\frac{19 \text{z1}^8}{1280}+\frac{7 \text{z1}^6 \text{z2}^2}{64}-\frac{205 \text{z1}^4 \text{z2}^4}{1152}+\frac{7 \text{z1}^2 \text{z2}^6}{64}-\frac{19 \text{z2}^8}{1280}\right)+t^{10} \left(-\frac{\text{z1}^9 \text{z2}}{48}+\frac{\text{z1}^7 \text{z2}^3}{12}-\frac{\text{z1}^5 \text{z2}^5}{8}+\frac{\text{z1}^3 \text{z2}^7}{12}-\frac{\text{z1} \text{z2}^9}{48}\right)+t^{12} \left(\frac{715 \text{z1}^{12}}{387072}-\frac{319 \text{z1}^{10} \text{z2}^2}{15360}+\frac{379 \text{z1}^8 \text{z2}^4}{6144}-\frac{133 \text{z1}^6 \text{z2}^6}{1536}+\frac{379 \text{z1}^4 \text{z2}^8}{6144}-\frac{319 \text{z1}^2 \text{z2}^{10}}{15360}+\frac{715 \text{z2}^{12}}{387072}\right)+t^{14} \left(\frac{17 \text{z1}^{13} \text{z2}}{5760}-\frac{17 \text{z1}^{11} \text{z2}^3}{960}+\frac{17 \text{z1}^9 \text{z2}^5}{384}-\frac{17 \text{z1}^7 \text{z2}^7}{288}+\frac{17 \text{z1}^5 \text{z2}^9}{384}-\frac{17 \text{z1}^3 \text{z2}^{11}}{960}+\frac{17 \text{z1} \text{z2}^{13}}{5760}\right)+O\left(t^{15}\right)$$

s[2,2]:

Assuming[
t>0 && z1>0 && z2>0,
s22 = Expand /@ Simplify[s[2, 2] /. {z1 -> t z1, z2 -> t z2} /. t -> t + O[t]^21]
]; //AbsoluteTiming
s22 //TeXForm


{11.6507, Null}

$$t^2 \left(-\frac{\text{z1}^2}{8}-\frac{\text{z1} \text{z2}}{6}-\frac{\text{z2}^2}{8}\right)+t^6 \left(\frac{7 \text{z1}^6}{640}+\frac{\text{z1}^5 \text{z2}}{120}-\frac{\text{z1}^4 \text{z2}^2}{384}-\frac{\text{z1}^3 \text{z2}^3}{60}-\frac{\text{z1}^2 \text{z2}^4}{384}+\frac{\text{z1} \text{z2}^5}{120}+\frac{7 \text{z2}^6}{640}\right)+t^{10} \left(-\frac{869 \text{z1}^{10}}{967680}-\frac{\text{z1}^9 \text{z2}}{3024}+\frac{71 \text{z1}^8 \text{z2}^2}{107520}+\frac{\text{z1}^7 \text{z2}^3}{756}-\frac{5 \text{z1}^6 \text{z2}^4}{4608}-\frac{\text{z1}^5 \text{z2}^5}{504}-\frac{5 \text{z1}^4 \text{z2}^6}{4608}+\frac{\text{z1}^3 \text{z2}^7}{756}+\frac{71 \text{z1}^2 \text{z2}^8}{107520}-\frac{\text{z1} \text{z2}^9}{3024}-\frac{869 \text{z2}^{10}}{967680}\right)+t^{14} \left(\frac{2339 \text{z1}^{14}}{30965760}+\frac{\text{z1}^{13} \text{z2}}{86400}-\frac{1807 \text{z1}^{12} \text{z2}^2}{30965760}-\frac{\text{z1}^{11} \text{z2}^3}{14400}+\frac{781 \text{z1}^{10} \text{z2}^4}{4423680}+\frac{\text{z1}^9 \text{z2}^5}{5760}-\frac{7 \text{z1}^8 \text{z2}^6}{819200}-\frac{\text{z1}^7 \text{z2}^7}{4320}-\frac{7 \text{z1}^6 \text{z2}^8}{819200}+\frac{\text{z1}^5 \text{z2}^9}{5760}+\frac{781 \text{z1}^4 \text{z2}^{10}}{4423680}-\frac{\text{z1}^3 \text{z2}^{11}}{14400}-\frac{1807 \text{z1}^2 \text{z2}^{12}}{30965760}+\frac{\text{z1} \text{z2}^{13}}{86400}+\frac{2339 \text{z2}^{14}}{30965760}\right)+O\left(t^{15}\right)$$

• thank you for all the work you put in, and the valuable insight and comparisons. I will have to incorporate this into my work, and mind first ;)
– nate
Nov 5, 2018 at 20:54