textbook page 157 solubility of Mg(OH)2

Equations    7-37, 7-38, 7-3      and        7-41   charge balance

a=[Mg2+]         b=[OH- ]          c=[MgOH-]        d=[H+]

Solve[{7.1* 10^(-12) ==a  b^2, 3.8 10^2==c/(a  b),10^(-14)==b  d, 2  a + c +d ==b},{a,b,c,d}]

{{c->-5.742948671027527`*^-6-9.646577413543173`*^-6 I,d->-2.1285947631680977`*^-11-3.575454934597173`*^-11 I,a->-0.000058596032497195235`+0.00010807186402612444` I,b->-0.00012293503495136563`+0.00020649711488415637` I},{c->-5.742948671027527`*^-6+9.646577413543173`*^-6 I,d->-2.1285947631680977`*^-11+3.575454934597173`*^-11 I,a->-0.000058596032497195235`-0.00010807186402612444` I,b->-0.00012293503495136563`-0.00020649711488415637` I},{c->0.000010973275442055049`,d->4.067188822110841`*^-11,a->0.000117448376894394`,b->0.00024587006990273126`}}

The real values are in larger format

There is an approximation for the use of EXCEL program in the  textbook

textbook page 155 CaSO4

Clear[a,b,c,d,e,f,g]

Comparison between calculation with activity and without  activity coefficients

Equations: 7-28, 7-29, 7-23, 7-24, 7-25, 7-26, 7-27

a= [CaSO4], b= [Ca2+],  c=[So42-], d=[CaOH+] ,  e=[H+], f=[HSO4-] ,  g=[OH-]

Without  Activity coefficients

Solve[{2 b + d +e==2 c +f+g, b+a+d==c+f+a, 2.4  10^(-5)==b c,5 10^(-3)==a,2 10^(-13)==d e/b,9.8 10^(-13)==f g/c,10^(-14)==e g},{a,b,c,d,e,f,g}]

{{a->0.005`,d->-1.1375827245957534`*^-8,f->-4.135084487121414`*^-8,g->-1.1610440582160768`*^-7,e->-8.61293881765425`*^-8,b->0.004898964498080447`,c->0.0048989944730980966`},{a->0.005`,d->-7.4384627461785286`*^-9,f->-6.323657004827323`*^-8,g->7.591805927989372`*^-8,e->1.3171616655320403`*^-7,b->-0.004899007384699381`,c->-0.004898951586592107`},{a->0.005`,d->5.995419400389179`*^-14,f->0.007852081630772265`,g->-1.2735098940186247`*^-12,e->-0.007852081631985953`,b->-0.0023520000003635416`,c->-0.01020408163107589`},{a->0.005`,d->7.438466300448302`*^-9,f->6.323878500366368`*^-8,g->-7.591896106600947`*^-8,e->-1.3171927978432532`*^-7,b->-0.004898951585486437`,c->-0.004899007385805158`},{a->0.005`,d->1.1375882447348934`*^-8,f->4.1350644134137676`*^-8,g->1.1610425874556518`*^-7,e->8.612949705322412`*^-8,b->0.004898994472970106`,c->0.004898964498208433`},{a->0.005`,d->0.049519999999813324`,f->9.499325394000216`*^-15,g->-0.049520000000005775`,e->-2.0193874560164855`*^-13,b->-0.049999999999805686`,c->-0.0004800000000018653`}}

With Activity coefficients

Solve[{2 b + d +e==2 c +f+g, b+a+d==c+f+a, 2.4  10^(-5)==0.628 0.606  b c,5 10^(-3)==a,2 10^(-13)==d e/(0.628 b),9.8 10^(-13)==f g/(0.606 c),10^(-14)==e g},{a,b,c,d,e,f,g}]

{{a->0.005`,d->-1.15380033144537`*^-8,f->-4.07696992796613`*^-8,g->-1.1567841636641924`*^-7,e->-8.644672044662472`*^-8,b->0.007941246694806541`,c->0.007941275926502473`},{a->0.005`,d->-7.641431450110256`*^-9,f->-6.155966734030194`*^-8,g->7.661152785705363`*^-8,e->1.305297637248821`*^-7,b->-0.007941288269804746`,c->-0.007941234351568908`},{a->0.005`,d->3.590673469703029`*^-14,f->0.013093195604686525`,g->-7.634889173997045`*^-13,e->-0.013093195605414353`,b->-0.0037452229301444973`,c->-0.016838418534795105`},{a->0.005`,d->7.641353578948732`*^-9,f->6.156029486855674`*^-8,g->-7.661126680544087`*^-8,e->-1.3053020806444656`*^-7,b->-0.007941234351216209`,c->-0.007941288270157477`},{a->0.005`,d->1.153803055052803`*^-8,f->4.07695569191882`*^-8,g->1.1567826314633636`*^-7,e->8.644673679768542`*^-8,b->0.007941275926417708`,c->0.007941246694891341`},{a->0.005`,d->0.07882575518686631`,f->5.967212342154829`*^-15,g->-0.0788257551869872`,e->-1.2686175964969374`*^-13,b->-0.07961783439478233`,c->-0.0007920792079220071`}}

see e=h+       complete solution

-Log[10,8.6 10^(-8)]

basic

----------------------------------------------------------------