kill(all)$

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

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

load(lrats)$

definition : pH
===========

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

p1;pH(x):=-log10(x)$

example : pH =7 , neutral => x=10^(-7)

p1:pH(10^(-7));float(%);

pH+pOH =pkw=14

Acid : H(n)A
===========

Strong Acid 
-----------------

mono acid   (n=1)
========

example : strong acid ,HCl, [H3O(+)]=[H(+)]=H =0.050 M = CA
=====================================================
rem : HCl  → H(+) + Cl(-), dissociation aq is small with respect H
-----------------------------------------------------------------------------------------------
use : p1, `completely dissociated`, see : part 1
rem : H = H,A  = Cl 

rem : 0.05 M : '0.05 molair' solution 'aq'

solve :
=====

p2: pH(0.05);float(%);

poly acid   (n=n)
========

example : strong acid ,H(2)SO4, [H3O(+)]=[H(+)]=n*CA
                  CA  = 0.05 M
                   n     = 2
==============================================================
rem : H(2)SO4  → n*H(+) + SO4l(2-), dissociation aq is small with respect H
---------------------------------------------------------------------------------------------------------------
use : p1, `completely dissociated`, see : part 1
rem : H = H,A  = SO4 

solve :
====

1e) conc H:

CA:0.05;
n:2;
H :2*0.05;

2e) pH :

p2: pH(H);float(%);

H;

Menu : Maxima : Delete Variable.

remvalue(H,CA);

H;

dissociation aq :dilution acid with aq 
--------------------------------------------------------
=>  use below 

[H3O(+)]tot = [H3O(+)]acid+[H3O(+)]aq
H                   = CA                 +[H3O(+)]aq = CA   +  OH = CA + kw/H

pkw = 14 : ?     kw = 10^(-14):
========================

kw:10^(-14);

p3:kw =(H)*(OH);

p4: H=CA+kw/H;

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

p6:ratsimp(p5);

math : a/b =0    =>  a=0
===================

a:part(p6,1,1);

b:part(p6,1,2);

p7:a=rhs(p6);

coef : H^2,H,constant  ?
====================

coef :  H^2
=========

p8a:coeff(lhs(p7),H^2);

coef: H
======

p8b:coeff(lhs(p7),H);

coef: constant
============

p8c:ev(lhs(p7),H=0);

p9:[p8a,p8b,p8c]/p8a;

p9a:float(p9);

 see : 'above'
===========

p9b:[p9a[1],p9a[2],-kw];

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

p10:float((100000000000000*H^2-100000000000000*CA*H-1)/100000000000000=0);

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

rem : p7a , quadratic equation. (ned : vierkantsvergelijking)

 quadratic equation :  a1*x^2+a2*x+a3 = 0
===================================

p11:CA=10^(-6);
a1:p9b[1];
a2:subst(p11,p9b[2]);
a3:p9b[3];

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

simple example : x^2-1 = 0
======================
s1:1,s2:0,s3:-1

p11:quadra2(1,0,-1,aa);

 example           : CA =10^(-6)
=======================
s1:a1,s2:a2,s3:a3

p12:quadra2(a1,a2,a3,aa);

rem : doesn't exit neg. concentration, hold : positive solution
====================================================

p12a:p12[1];
p12b:p12[2];

pH : solution  CA = 10^(-6)
---------------------------------------

p13:pH(p12a);float(%);

example:  calculation 1.5*10^(-7) M,HClO(4) :
=====================================

solve :
=====

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

p14:CA = 1.5*10^(-7) ;

p14a:a1;
p14b:subst([p14],p9b[2]);
p14c:a3;

rem : a1,a3  fixed here. ( acid)
---------------------------------------------
rem: p9b[2] not be changed for other calculations.
----------------------------------------------------------------------------

p15:quadra2(p14a,p14b,p14c,aa);

rem : neg value no physical meaning

pH solution :
===========

pH(p15[1]);float(%);

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