kill(all)$

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

distribution function and relation with log10  plot.
=========================================

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)$

rem : loga(x) = y ⇔ x = 10^a

p1c:float(log10(100));

p1c: H = 10^(-ph)$

distribution function  : function H, Ka(i),Kw  i=1,2,..,n
=============================================
Ka(i) , dissociation constant  of  (a)cid.
---------------------------------------------------------------------------------
[H3O+] = [H+] = H
[OH(-)]  = [OH-] = OH
Kw = 10^(-14)        ,  dissociation constant  water ( = aq)
---------------------------------------------------------------------------------

find definition for : α(i)  , i = 0,1,2,..,n
------------------------------------------------------

HA  , mono , acid   => monoprotic acid    (n=1)
===

p2a:α(0) = H/(H+Ka(1));
p2b:α(1) =Ka(1)/(H+Ka(1));

p3c:C_HA =HA+A;

rem : [HA] = HA , [A] = A(-)

H2A  , di   , acid   => diprotic acid     (n=2)
====

p3:H^2+Ka(1)*H + Ka(1)*Ka(2);

p3a:α(0) =H^2/p3;
p3b:α(1)=Ka(1)*H/p3;
p3c:α(2)=(Ka(1)*Ka(2))/p3;

p3d:C_H2A =H2A + HA+A;

rem : [H2A] = H2A,[HA(-)] = HA,[A(2-)] = A

p4:s(n) :=sum(H^(n-k)*product(Ka(j),j,1,k),k,1,n);

rem : relation between sum and product connect with 'k'.
-------------------------------------------------------------------------------------
k : control of H  control of Ka.

p4a:s(1);

p4b:s(2);

result : highst power is missing.
===========================

denominator :HA,H2A
---------------------------------

HA :  n=1
===

p5a:H+s(1);

H2A: n=2
====

p5b:H^2+s(2);

 How construct : general equation for  : αn(i,n,H)
========================================

numerator : HA,H2A, ......,HnA
---------------------------------------------

connect factor and product with variable. 'i'
-----------------------------------------------------------------
rem : factor : powers of H

ss(n,i):= H^(n-i)*product(Ka(j),j,1,i);

ratio : numerator/denominator => αn(i,n,H)
----------------------------------------------------------------

αn(i,n,H) :=ss(n,i)/(H^n+s(n));

example : H2A
============

n = 2 ,α(i)  i=0,1,..,n
===============

α(0 ) : 
-------

αn(0,2,H);

α(1) :
------

αn(1,2,H);

α(2) :
-------

αn(2,2,H);

check for : sum(αn(i,n,H)) =1
=========

example : n=2 , H2A
============

p6:'sum(αn(i,2,H),i,0,2) =ratsimp(sum(αn(i,2,H),i,0,2));

log10 plot  weak acid  HA ( n=1)
-----------------------------------------------

dissociation constant: weak acid.
============================

p7:Ka(1) = ((H)*(A))/(HA);

species :{A,H,HA}
======

p7a:HA= C_HA*αn(0,1,H);
p7b:A  = C_HA*αn(1,1,H);

see: Maxima : intro computation ,base and acid, 'part 15,version 1.0'

ref : ph = pKa(1)

below  : ph < pka
==============

correction
=========

denominator ,p7a,p7b : condition 
============================
H > Ka(1)    = >  approximation  Ka(1) = 0

p8a:denom(rhs(p7a));

result
=====

p8b:subst([Ka(1)=0],p8a);

p9a:lhs(p7a) = num(rhs(p7a))/p8b;
p9b:lhs(p7b) = num(rhs(p7b))/p8b;

p9a1:'log10(lhs(p9a)) =log10(rhs(p9a));

p9b1:'log10(lhs(p9b)) =log10(rhs(p9b));

p9b1a:lhs(p9b1) =rhs(p9b1),logexpand=super;

p9b1b:lhs(p9b1) = expand(rhs(p9b1a));

p9b1c:lhs(p9b1)  = lratsubst([-log(H)/log(10)=ph],rhs(p9b1b));

p9b1d:lhs(p9b1) = expand(rhs(p9b1c));

p9b1e:lhs(p9b1)=logcontract(rhs(p9b1d));

p9b1f:lhs(p9b1) =expand(rhs(p9b1e));

above  : ph > pka
===============

correction
=========

denominator ,p7a,p7b : condition 
============================
H < Ka(1)    = >  approximation  H = 0

p10a:p8a;

result
=====

p10b:subst([H=0],p10a);

p11a:lhs(p7a) = num(rhs(p7a))/p10b;
p11b:lhs(p7b) = num(rhs(p7b))/p10b;
p9b1d:lhs(p9b1) = expand(rhs(p9b1c));

p12a:'log10(lhs(p11b)) = log10(rhs(p11b));

p12b:'log10(lhs(p11a)) = log10(rhs(p11a));

p12b1a:lhs(p12b) =rhs(p12b),logexpand=super;

p12b1b:lhs(p9b1) = expand(rhs(p12b1a));
p12b1c:lhs(p9b1)  = lratsubst([-log(H)/log(10)=ph],rhs(p12b1b));
p12b1d:lhs(p9b1) = expand(rhs(p12b1c));
p12b1e:lhs(p9b1)=logcontract(rhs(p12b1d));
p12b1f:lhs(p9b1) =expand(rhs(p12b1e));

see: Maxima : intro computation ,base and acid, 'part 15,version 1.0'
graphics : see part 15.(others)
relation : K_a = Ka(1)