kill(all)$

Maxima : intro computation ,base and acid, 'part 16,version 1.0'
peter.vlasschaert@gmail.com,23/12/2018

load packages :
------------------------

load(lrats)$
load(facexp)$

convert:
-----------

log10(x):=log(x)/log(10);

definition : pH,pOH
================

p1: pH(x)   :=-log10(x)$
p1a:pOH(x):=-log10(x)$

quadratic equation :  s1*x^2+s2*x+s3= 0
=================

quadra2(s1,s2,s3,aa):= block([x1,x2,disc], disc: sqrt(s2^2-4*s1*s3),
                                                     x1:(-s2+disc)/(2*s1),
                                                     x2:(-s2-disc)/(2*s1),
                                                     aa:[x1,x2])$  

titration : strong acid (mono: HCl)  'vessel' with strong base (NaOH) 'buret'.
===============================================================

reaction :  HCl + NaOH   => NaCl + H2O  ... '1'
1e)  HCl     -> H(+) + Cl(-)
2e) NaOH  -> Na(+) + OH(-)
rem :[H3O(+)]  = [H(+)] = H
          [OH(-)] = OH
          [Na(+)] = Na,[Cl(-)] = Cl

charge balance :
==============
-------------------------------------------------
sum ( +  charge) = sum( - charge)
-------------------------------------------------

p2:Na + H = Cl + OH;

definition : fraction  'f'
========
Nomemclature  ' titration'
    buret   :    Cb*V, ' NaOH' = titrant
f= ====== = ======
    vessel :    Cv*V0,   'HCl'  = titrated
-------------------------------------------------------------------
volume             : 'ml' ,  V,V0
concentration : 'M'  ,  Cb,Cv
b = buret
v = vessel
--------------------------------------------------------------------
example :
========
titration f,ratio of 'mmoles 'of base added as 'titrant
to (mmoles) of acid titrated.

simplified : principle
=================

symbolic : strong acid = C_HA , V0 = volume vessel
                     strong base=C_B    , V   = volume buret

added : 'Na OH'  : result : [H3O+] down , [OH(-)] up

before : Eq  (Equivalance  point)
===========================

p3: H = (C_HA*V0 - C_B*V)/(V+V0);

definition : f    'above reaction system  '1' '
==========

p3q: f=(C_B*V)/(C_HA*V0);

by : Eq
=======   
H = 0   => Why : [H(+)] = [OH(-)]

p3a:subst([H=0],p3);

p3b: expand(p3a);

p3c:lratsubst([rhs(p3q) = lhs(p3q)],p3b);

p3d:solve(p3c,f);

p3e:p3d[1];

after : Eq  (Equivalance  point) 
==========================

added : 'NaOH' , result : [H(+)] = 0 , [OH(-)]  up

p3f:OH = (C_B*V-C_HA*V0)/(V+V0);

p3g:lratsubst([rhs(p3q) = lhs(p3q)],p3f);

p3h :factor(p3g);

rem : K_w = [OH(-)]*[H] = 10^(-14)

p3i:K_w = OH*H;

p3j:solve(p3i,OH);

p3k:subst(p3j,p3h);

find : H

p3l:solve(p3k,H)[1];

p3m:factor(p3l);

result  : after Eq  => f > 1  , why: [H(+)] > 0

=====================================
rem : vessel volume during titration = V+V0
=====================================

 general treatement, '1'
===================

vessel :conc  'strong acid'
======================

p4a:Cl=C_HA*V0/(V+V0);

buret :conc  'strong base'
======================

p4b:Na=C_B*V/(V+V0);

insert : charge balance 'p4a,p4b'.
-------------------------------------------------

p4c:subst([p4a,p4b],p2);

insert :  'f' from above.

p4d:lhs(p4c) - rhs(p4c) = 0;

p4d1:H-OH = u;

p4e:lratsubst([p4d1],p4d);

p4f:solve(p4e,u)[1];

p4g:lratsubst([rhs(p3q) = lhs(p3q)],p4f);

p4g1:expand(p4g);

p4g2:combine(p4g1);

subst back : u = H-OH
===================

p4h:lratsubst([rhs(p4d1) = lhs(p4d1)],p4g2);

p4h1:p4h*(-1);

p4h2:factor(p4h1);

before Eq :   [H(+)] >[OH(-)]
=========
result : OH = 0

p5a:subst([OH = 0],p4h2);

p5a1:expand(solve(p5a,H)[1]);

p5a2:factor(p5a1);

@ Eq  : 'see above'
================

p5a3:OH = H;

after  Eq :   [H(+)] >[OH(-)]
=========
result : H = 0

p5a5:subst([H = 0],p4h2);

insert : H,K_w

p5a6:subst(p3j,p5a5);

p5a7:solve(p5a6,H)[1];

p5a8:factor(p5a7);

before : f > 1 : simplified
                f > 1  : general

relation between  : 'simplified method' and 'general method'
------------------------------------------------------------------------------------------

check ' p5a8' and 'p3m'
====================

is(rhs(p5a8)=rhs(p3m));

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