(**************************************************************
Saturated structures: Expected number of base pairs.


From DSV
**************************************************************)

Clear["P","S","R"]
g1 = -S + z +z^2 + z R +  z^2 R + u z^2 S + u z^2 S^2;
g2 = -R + u z^2 S + u z^2 R S;
P  =Resultant[-S + z +z^2 +  z R +  z^2 R + u z^2 S + u z^2 S^21,-R + u z^2 S + u z^2 R S,R]
P = S u (z^2) (z+(z^2))-(-1+S u (z^2)) (-S+z+(z^2)+S u (z^2)+(S^2) u (z^2))
dPdS = Simplify[D[P,S]]
dPdS = -1+(1+4 S) u (z^2)-S (2+3 S) (u^2) (z^4)
dPdu = Simplify[D[P,u]]
dPdu = S (z^2) (1-2 (S^2) u (z^2)+S (2-2 u (z^2)))
S= T+K Sqrt[X];
denom = Series[(-1+(1+4S) (rho - rho X)^2 - S(2+3 S )(rho - rho X)^4),{X,0,1}]/.X -> (1-z/rho)

(**************************************************************
This produces an expansion of \!\(\*"\""\)\!\(\*"denom"\)\!\(\*"\""\) as follows
**************************************************************)


denomApprox = (4 K  (rho^2)-2 K  (rho^4)-6 K  (rho^4) T)  (Sqrt[1 -  (z/rho)])

(**************************************************************
Compute numerator in limit as "S,z" approach "T,rho\!\(\*
StyleBox["\"", "Section"]\)\!\(\*
StyleBox["
", "Subsubtitle"]\)*************************************************************)

K = -3.808190403387938`
T = 1.6568963314781193`
rho =  0.4246873104202721`
numer = Expand[S z^2(1 - 2 S^2 z^2 + S(2-2 z^2))]
numer /. {S->  1.6568963314781193, z->rho}=0.8145799335195365`;

(**************************************************************
Compute denominator in limit as \!\(\*"\""\)\!\(\*"S"\)\!\(\*","\)\!\(\*"z"\)\!\(\*"\""\) approach \!\(\*"\""\)\!\(\*"T"\),rho"
*************************************************************)


K = -3.808190403387938`
T = 1.6568963314781193`
rho =  0.4246873104202721`
A=factorOfDenom = (4 K (rho^2)-2 K (rho^4)-6 K (rho^4) T) = 1.268090901429324` 
B = 1/A = -0.78858700024805473