kill(all)$

polyhydroxy base : (di)hydroxy weak base,M(OH)n => n=2
------------------------------------------------------
=>  mono = 1,di = 2,tri = 3,tetra = 4
h=[H(+)],c=Cb,k1=kb(1),k2=kb(2),kw = 1E-14

peter.vlasschaert@gmail.com,23/09/2016

p1:kw/h=h+c*(2*h^2*k1*k2 +h*k1*kw)/(h^2*k1*k2+h*k1*kw+kw^2);

p2:lhs(p1)-rhs(p1)=0$

p3:factor(lhs(p2))=0$

p4:num(lhs(p3))=0;

n1:ev(lhs(p4),h=0);
n2:coeff(lhs(p4),h);
n3:coeff(lhs(p4),h^2);
n4:coeff(lhs(p4),h^3);
n5:coeff(lhs(p4),h^4);

p5:(n5*h^4+n4*h^3+n3*h^2+n2*h+n1)=0;

polyhydroxy base : (tri)hydroxy weak base,M(OH)n => n=3
-------------------------------------------------------
h=[H(+)],c=Cb,k1=kb(1),k2=kb(2),k3=kb(3),kw = 1E-14

p6:kw/h=h+c*(h*k1*kw^2+2*k1*k2*h^2*kw+3*k1*k2*k3*h^3)/(kw^3 +k1*h*kw^2+k1*k2*h^2*kw+k1*k2*k3*h^3);

p7:lhs(p6)-rhs(p6)=0$
p8:factor(lhs(p7))=0$

p9:num(lhs(p8))=0;

nn1:ev(lhs(p9),h=0);
nn2:coeff(lhs(p9),h);
nn3:coeff(lhs(p9),h^2);
nn4:coeff(lhs(p9),h^3);
nn5:coeff(lhs(p9),h^4);
nn6:coeff(lhs(p9),h^5);

polyhydroxy base : (di)hydroxy weak base,M(OH)n => n=2
------------------------------------------------------

h=[H(+)],c=Cb,k1=kb(1),k2=kb(2),kw = 1E-14

p10:ev(lhs(p9),k3=0);

mm1:ratsimp(ev(lhs(p10),h=0)/kw);
mm2:ratsimp(coeff(lhs(p10),h)/kw);
mm3:ratsimp(coeff(lhs(p10),h^2)/kw);
mm4:ratsimp(coeff(lhs(p10),h^3)/kw);
mm5:ratsimp(coeff(lhs(p10),h^4)/kw);

polyhydroxy base : (mono)hydroxy weak base,M(OH)n => n=1
--------------------------------------------------------

h=[H(+)],c=Cb,k1=kb(1),kw = 1E-14

p11:ev(lhs(p5),k2=0)=0;

p12:ratsimp(lhs(p11)/kw)=0;

ll1:ratsimp(ev(lhs(p11),h=0)/kw);
ll2:ratsimp(coeff(lhs(p11),h)/kw);
ll3:ratsimp(coeff(lhs(p11),h^2)/kw);
ll4:ratsimp(coeff(lhs(p11),h^3)/kw);

p13:h^3*ll4+h^2*ll3+h*ll2+ll1=0;