(*==================================================== Saturated secondary structures computed by DSV and Flajolet-Odlyzko. Context free grammar given by

s --> * or ** or *R or **R or (S) or S(S)
 R --> (S) or R(S)

 ====================================================*)

P = Simplify[Resultant[-S + z   + z^2 +
 z R + z^2 R + z^2 S + z^2 S^2, -R+z^2 S + z^2 R S,R]]
DP = Simplify[D[P,S]]
Factor[Resultant[-(S^3) (z^4)+z (1+z)-(S^2) (z^2) (-2+(z^2))+S (-1+(z^2)),-1+(1+4 S) (z^2)-S (2+3 S) (z^4),S]]

-(S^3) (z^4)+z (1+z)-(S^2) (z^2) (-2+(z^2))+S (-1+(z^2))

(* Find dominant singularity rho *)

eqn = {4+z-7 (z^2)-28 (z^3)-32 (z^4)+4 (z^6) == 0}
NSolve[eqn,z]

rho = 0.4246873104202721`

F = 4+z-7 (z^2)-28 (z^3)-32 (z^4)+4 (z^6) 
growth = 1/rho
Q=Series[F/(1-z/rho),{z,0,8}]
Expand[Series[Q,{z,0,8}]*(1-z/rho)]

(*====================================================================
Compute value T and verify that dP/dS is increasing when z is rho and S is T. Find possible
values of T by solving equation in S, and then discarding the possible root TT below.
===============================================================*)

NSolve[0.6050466220522767`-0.8196406883679954` S+0.3281891419716385` (S^2)-0.03252948129237052` (S^3)==0,S]
T=1.6568963314781193`
Simplify[Series[P,{z,rho,4},{S,T,4}]]
epsilon = 0.001
TT = 6.7751828754381425`
DP /. {z->rho, S-> TT+epsilon}
Plot3D[DP,{z,rho-epsilon,rho+epsilon},{S,T-epsilon,T+epsilon}];

DPz = D[P,z]

1+2 z+2 S z-2 (S^2) (z^3)-4 (S^3) (z^3)-2 (S^2) z (-2+(z^2))
DPS2 = D[DP,S]

C1=DPz/.{z->rho,S->T}

C2=DPS2/.{z->rho,S->T}

K = Sqrt[2 rho C1/C2]

3.808190403387938`
K/(2 Sqrt[Pi])
Gamma[-1/2]

-2 (Sqrt[π])
SatSecStr[n_]=1.0742706788790013` n^(-3/2) rho^(-n)

((1.0742706788790013` ((0.4246873104202721`)^(-n)))/(n^(3/2)))