kill(all)$

Maxima : intro computation ,base and acid, 'part :7,version 1.0'
peter.vlasschaert@gmail.com, 29/11/2018

see also part 4,5,6

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

load(lrats)$

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

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

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

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

Buffer Solution
=============

Mix of two solutions , weak acid and the other one 
the conjugate base

state equilibrium  :   '1' or '2'
----------------------------

reaction : HA+H2O = H3O(+)+A(-) ... '1'
====================================
rem:[A(-)] = A, [H3O(+)] =[H] = H

reaction : HA+OH(-) = H2O+A(-)   ... '2'
====================================
rem:[A(-)] = A, [H3O(+)] =[H] = H,[OH(-)]=OH

p2: K_a = ((H)*(A))/HA;

p2a:solve(p2,H)[1];

p2b: -log(H)/log(10)=ph;

p2c:-log10(p2a);

p2d:subst([p2b],lhs(p2c)) = rhs(p2c);

p2e: p2d,logexpand=super;

p2f:expand(p2e);

pK_a: calculation  : -log(K_a)/log(10)
================

p2g : list statement.
------------------------------

p2g : args(rhs(p2f));

p2h:p2g[1] =pK_a;

p2i:subst([p2h],p2f);

p2j:logcontract(p2i);

p2k:expand(p2j);

from definition : log10 : 'above'
----------------------------------

p2l:part(rhs(p2k),2,1);

ph : calculation for 'buffer solution'
----------------------------------------------------------

p2m:lhs(p2k) = part(rhs(p2k),1) + subst([log=log10],p2l);

region of effective buffer action
==========================
ph = pK_a ±  1
-----------------------------------------------

rem : dilution of buffer solution doesn't usualy the ph value.

example:
========

pK_a 'CH3COOH' = 4.75
-------------------------------------------------------------------------------------------------
acid                       = CH3COOH   =  10 mmoles  , 'HA' =>  acid
conjugate base  = CH3COO(-)  =  100 mmoles,  'A'   =>  salt of acid
--------------------------------------------------------------------------------------------------

acid :[HA], conjugate base:[A(-)]
------------------------------------------------
NH4(+)   ,NH3
HCO3(-) ,CO3(2-)
------------------------------------------------

p2n:subst([pK_a=4.76,A=100,HA=10],p2m),numer;

behaviour 'buffer solution' use :'1' and '2'
===================================

added : OH(-) : buffer solution A/HA  => '2'
--------------------------------------------------------------
result :  A/HA ' increase'  , ph : not much

added : H3O(+) : buffer solution A/HA  => '1'
-----------------------------------------------------------------
rem : reaction '1', from right to left
result :  A/HA ' decrease'  , ph : not much

 charge balance:
 ------------------------
[H3O(+)]+[M(+)]=[A(-)]+[OH(-)]

rem : salt of acid = CH3COOM
                       acid = CH3COOH
--------------------------------------------
M = Na,K ,metal ion
--------------------------------------------
rem : [M(+)] = M

p3a: H+M = A+ OH;

1e)  concentration C_HA+CA:
        -------------------------------------
C_HA +C_A = [HA]+[A(-)]

reason : A from acid, salt of acid

p3b:C_HA+C_A = HA + A;

special concept : analytical chemistry

2e) salt of acid : MA
       ----------------

reaction(aq): MA = M + A  ... '3'
=========================

p3c: M=C_A;

find : [A(-)] = A;
============

1e)  2e into charge balance
----------------------------------------

p4: subst([p3c],p3a);

2e)  solve for A
----------------------------------------

p4a:solve(p4,A)[1];

find : [HA] = HA;
=============

1e)  solve 'p3b' for HA
----------------------------------------

p5:solve(p3b,HA)[1];

2e)  subst 'p4a' into 'p5'
----------------------------------------

p5a:subst([p4a],p5);

==================================

find H : use 'p2a'
==============

1e) start
=======

p6:p2a;

2e) subst, 'p4a' and '5a' in 'p6'
==========================

p6a:subst([p4a,p5a],p6);

3e) K_w =[OH]*[H]
===============

p6b:K_w= OH*H;

p6c: solve(p6b,OH)[1];

4e) subst  'p6c' into 'p6a'
=====================

p6d:subst([p6c],p6a);

first approximation :  C_A    : concentration salt
                                        C_HA : concentration acid
------------------------------------------------------------------------
=   Henderson -Hasselbalch equation
-------------------------------------------------------------------------

relation between :'p2m' ,'p6d'
=========================

p7:p2m;

p7a: subst([A=C_A,HA=C_HA],p7);

assume: C_HA >>  K_w/H-H
assume: C_A    >> -K_w/H+H

'--------------------------------------------------------------------------------------------'

rem:

logcontract(-log(HA)/log(10)+log(A)/log(10));

rem :

expand(-(log(K_a)+log(HA)-log(A))/log(10));

rem : product to sum
--------------------------------

log((HA*K_a)/A), logexpand=super;

reaction :  HA+OH(-)  = A(-)+H2O ... '2'
================================

relation : 
K_a*K_b = K_w
K_w         = H*OH=1.0*10^-14,aq
pK_w       = 14.0

rem:
====
----------------------------------------------------------
Menu : Simplify :  Expand  Logarithms 
                                 Contract Logarithms
----------------------------------------------------------

===============================================

example
=======

make 1l , 0.1 molar acid-acetate,with ph=4.76 : ' see p3b'
===============================================
given : K_a = 1.8 *10^(-5)
-------------------------------------------------------------------------------------

solve:
====

given:
=====

p8: C_HA+C_A = 0.1;

use:Henderson -Hasselbalch equation

p8a:p7a;

p8b:K_a = 1.8 *10^(-5);

p8c:ph=4.76;

solve :start
==========

p8d:subst([p8c,pK_a=-log10(rhs(p8b))],p8a);

p8e:lhs(p8d)-part(rhs(p8d),2)=part(rhs(p8d),1),numer;

p8f:solve(p8e,C_A/C_HA)[1],numer;

find : C_A,C_HA : from  'p8' and 'p8f'
===============================

find C_A :
========

p9:solve(p8f,C_HA)[1];

p9a:subst([p9],p8);

p9b:solve(p9a,C_A)[1],numer;

===========================================

result : concentration salt , 0.05 M, example : NaAc

find C_HA:
=========

p10:solve(p8f,C_A)[1];

p10a:subst([p10],p8);

p10b:solve(p10a,C_HA)[1],numer;

=========================================

result : concentration acid , 0.05 M,example: HAc

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