kill(all);

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

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

load(lrats)$

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

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

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

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

dissociation : aq :
===============

kw:10^(-14);

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

rem:solution of quadratic equation ,only pos solution have a physical meaning.

Weak acid: HA
================

example : HAc , A=Ac,acetic acid (ned : azijnzuur)
pka = -log10(ka)

reaction : HA+H(2)O ⇔ H(3)O(+) + A(-)          ....  '1'
rem:H(3)O(+) =H, A(-) = A

equilibrium:

definition : pKa
============

p2:pKa(x)   :=-log10(x)$

definition : K_a       .... '2'
============

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

question : youtube
----------------------------
https://www.youtube.com/watch?v=05mlkjd4eHk&index=12&list=PL1645A8F52FCEADF9

Find the pH of a 0.043M acetic acid solution calculate the % ionization.
Show how the addition 10^(-3) M HCl would affect the pH of the solution
and the percent ionization .K_a =1.8*10^(-5).

solution :

part a:
=====

def : percent ionization
====================
 =  [A(-)]/[HA] *100 = [conjugate base]/[weak acid]*100

rem : [H(+)] =[A(-)]               '3'

concentration weak acid.
=====================
C_HA = [HA(-)] +[A(-)]      '4'

1e) find HA from '2'
================

p3:C_HA = HA+A;
p3a:solve(p3,HA)[1];

2e) from rem above
================

p3b:[A=H];

p3c:subst(p3b,p3a);

p3d:subst([C_HA = 0.043],p3c);

3e)  subst 2e) into '2'
=================

p4:subst([p3d,p3b[1],K_a=1.8*10^(-5)],p2a);

p4a:rhs(p4)-lhs(p4)=0;

p4b:ratsimp(p4a)*(-1);

p4c:num(lhs(p4b)) =rhs(p4b);

s1:500000000;
s2:9000;
s3:-387;

Solve : quadratic equation 
======================

p5:quadra2(s1,s2,s3,aa);

p5a:float(p5);

p5b:p5a[1];

ph  calculation
=============

p5c:ph1=float(pH(p5b));

only : pos solution, first solution
-------------------------------------------------

percent ionization : perc1 %
=====================

p6:C_HA =part(rhs(p3d),1);
p6a:A  = p5b;

p6b: perc1=100*(subst([p6,p6a],A/C_HA));

part b: addition : 0.001 M HCl
=======================

                  HA          =      A(-)  + H(+)
init            0.043M                      0.001M
react         - x                    x           x
==========================
equil         0.043-x             x          x+0.001

k_a = (x*(x+0.1))/(0.043-x)

p7:K_a = (x*(x+0.001))/(0.043-x);

p7a:subst([K_a=1.8*10^(-5)],p7);

p7b:solve(p7a,x);

p7c:float(p7b);

p7c1:p7c[2];

p7c2:rhs(p7c1);

ph  calculation
=============

[H(+)]tot = [H(+)]'HA' + [H(+)] 'strong acid'
==================================
                =  x  + 0.001M

p8:ph2=float(pH(p7c2+0.001));

percent ionization : perc2 %
=====================

p9:perc2=100*subst([p7c1,p6],x/C_HA);

addition strong acid to a weak acid
==============================

general : perc1 > perc2
general : ph1 > ph2

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

rem : [H(+)]= [H(+)]formed -[H(+)] reacted
example : [H(+)] reacted = 0.