kill(all)$

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

intro math:
=========
-------------------------------------------------
math : ln  => maxima : log 
e:2.7.....   => maxima : %e ,exp()
-------------------------------------------------

float(%e);

assume(a>0);

maxima : a^x = %e^(log(a^x))
=========================

d(a^x)/dx :
----------------

m1:'diff(a^x,x) = diff(a^x,x);

m2:'diff(%e^(log(a^x)),x) = diff(%e^(log(a^x)),x);

rem : use 'radcan' simplification.

radcan(log(a)*%e^(log(a)*x));

m3:lhs(m2) = radcan(rhs(m2));

d(log(x))/dx:   'see below , definition : log10(x)'
------------------

'diff(log(x),x) = diff(log(x),x);

titration : calculus
===============

load : packages
=============

load(lrats)$
load(facexp)$

rem : lrats => command 'lratsubst'.

rem : [OH(-)] = OH, [H(+)] = H
=======================

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

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

definition : ph = -log10(H)
=====================

p1:ph=-log10(H);

rem : 'diff(log10(x),x) = diff(log10(x),x);

'diff(log10(x),x) = diff(log10(x),x);

rem : a^x = 10^(log10(a^x))

a^x =radcan(10^(log10(a^x))) ;

rem : e^x = 10^(log10(e^x))

 %e^x = radcan(10^(log10(%e^x)));

'diff(ph,H)  : ?
===========

p1a:'diff(lhs(p1),H) = diff(rhs(p1),H);

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

p2a:'diff(lhs(p2),ph) = diff(rhs(p2),ph);

'diff(H,ph)  : ?
===========

p2b:lhs(p2a) = subst([p1],rhs(p2a));

check : 
======

p3:p1a*p2b;

definition : K_w = [OH]*[H]
======================

p4:K_w =(OH)*(H);

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

p4a1:rhs(p4a) = lhs(p4a);

p4b:'diff(lhs(p4a),H) = diff(rhs(p4a),H);

p4c:lhs(p4b) = lratsubst([p4a1],rhs(p4b));

result : d(OH)/OH = - d(H)/H
-----------------------------------------

find : d(OH)/d pH :
===============

p5:'diff(lhs(p4a),ph) = 'diff(rhs(p4a),ph);

chain rule
========

p5a:lhs(p5) = 'diff(rhs(p4a),H)*'diff(H,ph);

p5b:lhs(p5a) =  diff(rhs(p4a),H)*'diff(H,ph);

use : ?  from , 'p2b'

p5c:lhs(p5b) = subst([p2b],rhs(p5b));

use: ? from,'p4a1'

p5d:lhs(p5c) =lratsubst([p4a1],rhs(p5c));

monoprotic acid , HnA   ( n = 1)  = HA
===============================

distribution function : α(0),α(1)
==========================
--------------------------------------------------------------------------------------------------------------------------------------------------------------
see: Maxima : intro computation ,base and acid, 'part :15a,version 1.0',(weak acid,distribution,log10(ph))
see :Maxima : intro computation ,base and acid, 'appendix 2',(Distribution diagram,acid,poly)
--------------------------------------------------------------------------------------------------------------------------------------------------------------

p6a:α(0) = H/(K_a+H);
p6b:α(1) =K_a/(K_a+H);

 check : distribution function : 'sum(α(i),i,0,n) = 1 for HnA'
================================================

p6c:'sum(α(i),i,0,1) = sum(α(i),i,0,1);

p6d:lhs(p6c) = subst([p6a,p6b],rhs(p6c));

p6e:lhs(p6d)=ratsimp(rhs(p6d));

d(α(0))/dH : ?
============

p7:'diff(α(0),H) = diff(rhs(p6a),H);

p7a:lhs(p7)=ratsimp(rhs(p7));

p7b:lhs(p7) = factor(rhs(p7a));

rem : product(α(i),i,0,n) for HnA: n=1 => HA

p8:product(α(i),i,0,1);

p8a:subst([p6a,p6b],p8);

α(0)*α(1)*1/H

p8b:p8a*1/H;

p7c:lhs(p7b) = p8*1/H;

find : d(α(0))/dph: ?
================

chain rule :
=========

p9:'diff(lhs(p6a),ph) = 'diff(lhs(p6a),H)*'diff(H,ph);

use : ? from  'p2b' and 'p7c'

p9a:lhs(p9) = subst([p2b,p7c],rhs(p9));

find : d(α(1))/dph: ?
================

chain rule :
=========

p10:'diff(lhs(p6b),ph) = 'diff(lhs(p6b),H)*'diff(H,ph);

need :'diff(α(1),H)

p10a:part(rhs(p10),1) = diff(rhs(p6b),H);

see : 'p8,p8a'

p10b: p8a=p8;

p10c:p10b/H;

subst : 'p10c' into 'p10a'

p10d:subst([p10c],p10a);

subst : 'p10d' and 'p2b'  into 'p10'

p10e:lhs(p10) =subst([p10d,p2b],rhs(p10));

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

to find :
======

p11:'diff(log10(α(0)),ph);

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

p11a:part(p11,0);

p11b:part(p11,1);

assume(H>0,K_a>0);

chain rule :
=========

p11c: p11 =' diff(p11b,H)*'diff(H,ph);

p11d:part(rhs(p11c),1)=subst([p6a],part(rhs(p11c),1));

p11e:lhs(p11d) = ev(rhs(p11d),diff);

p11f:lhs(p11e) = factor(ratsimp(rhs(p11e)));

subst :'p11f' and 'p2b' into 'p11c'

p11g:lhs(p11c) = subst([p2b,p11f],rhs(p11c));

p11h:p6b;

p11h1:rhs(p11h) = lhs(p11h);

final result :

p12:lhs(p11g) = subst([p11h1],rhs(p11g));

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

to find :
======

p13:'diff(log10(α(1)),ph);

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

p13a:part(p13,0);
p13b:part(p13,1);

chain rule :
=========

p13c: p13 =' diff(p13b,H)*'diff(H,ph);

p13d:part(rhs(p13c),1)=subst([p6b],part(rhs(p13c),1));
p13e:lhs(p13d) = ev(rhs(p13d),diff);

subst: 'p13e' and 'p2b' into 'p13c'

p13f:lhs(p13c) = subst([p13e,p2b],rhs(p13c));

use : 'p6b'

p13g:p6a;

p13g1:rhs(p13g) =lhs(p13g);

final result :

p14:lhs(p13f) = subst([p13g1],rhs(p13f));

rem : diprotic acid  to nprotic acid

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