kill(all)$

Maxima : intro computation ,base and acid, 'appendix 7b,version 1.0'
peter.vlasschaert@gmail.com, 05/01/2019

load packages
============

load(lrats)$

experiment :
==========
titration 10.0 ml of 0.1M  HA (= weak acid) with 0.1M NaOH.

vessel : 10 ml ,0.1M HA
buret   : x ml with 0.1M NaOH (added to the vessel)   'B'

data
====

B:[0.00,1.00,2.50,5.00,7.50,8.75,9.50,9.75,9.90,10.00,10.10,10.25,10.50,12.75,15.00];

p1:length(B);

ph:[3.00,4.05,4.52,5.00,5.48,5.85,6.28,6.59,7.00,8.85,10.70,11.09,11.39,12.08,12.30];

p2:length(ph);

point representation.  (xy ,graph)
-------------------------------------------------

s1(B,ph,dat) :=  block ( [dat:[] ],
l1:length(B),
for i:1 thru l1 step 1 do(
 dat:endcons([B[i],ph[i]],dat)
    )  ,
 return(dat)    
)$

p3:s1(B,ph,dat);

select : first point of the  xy, graph
=============================

p4:p3[1];

How to make this xy,graph (= experiment)
===================================

wxplot2d([[discrete, p3],[discrete,p3]], [x ,0,15], [y,3,13],
 [plot_format, xmaxima],[title,"titration weak acid,HA with NaOH"],
 [xlabel,"x ml  NaOH added with the buret"] , [ylabel,"ph"],[style,[points,0.7,red],[lines,0.6,blue]] , 
 [nticks,15])$

average ( = volume added x ml NaOH)  
================================

fm1(vol,v1) := block ([v1:[]],
ll : length(vol),
for i:1  thru ll -1 step 1
      do(l1:(vol[i+1]+vol[i])/2,
      v1:endcons(l1,v1)),
return(v1))$

v1:fm1(B,v1);

find max from list v1
------------------------------

v1a:lmax(v1);

f ' = Δph/Δv
==========

fderv1(vol,ph,fd1):= block([fd1:[] ],
 ll:length(vol) ,
  for i:1  thru ll -1 step 1
      do(l2:(ph[i+1]-ph[i])/(vol[i+1]-vol[i]),
     fd1:endcons(l2,fd1)),
return(fd1))$     

fd1:fderv1(B,ph,fd1);

find max value fd1
---------------------------

p4:lmax(fd1);

point representation.  (f ' ,graph)
-------------------------------------------------

p5:s1(v1,fd1,dat1);

wxplot2d([[discrete, p5],[discrete,p5]], [x ,0,15], [y,0,p4+0.5],
 [plot_format, xmaxima],[title,"titration weak acid,HA with NaOH"],
 [xlabel," average x ml  NaOH added with the buret"] , [ylabel,"dph/dv"],
 [style,[points,0.7,red],[lines,0.6,black]] ,  [nticks,15] )$

detail : f '
========

wxplot2d([[discrete, p5],[discrete,p5]], [x ,9.5,10.5], [y,0,p4+0.5],
 [plot_format, xmaxima],[title,"titration weak acid,HA with NaOH"],
 [xlabel," average x ml  NaOH added with the buret"] , [ylabel,"Δph/Δv"],
 [style,[points,0.7,red],[lines,0.6,black]] ,  [nticks,15] )$

when : x = 10 ml Equivalence Point (=EP) on the curve.
==============================================

simple rule :  (mono,'NaOH',mono,'HA')

p6:  C_[NaOH]*x = V_[HA]*C_[HA];

x : ml added NaOH by EP 
=====================

p6a:solve(p6,x)[1];

p6b:[V_[HA] =10,C_[HA]=0.1,C_[NaOH]=0.1];

p6c:subst(p6b,p6a); /*ml NaOH added */;

f '' = Δ(Δph/Δv)Δv
===============

average ( =  x ml NaOH added)  
==========================

fm2(vol,v2) := block ([v2:[]],
ll : length(vol),
for i:1  thru ll-1  step 1
      do(l1:(vol[i+1]+vol[i])/2,
      v2:endcons(l1,v2)),
return(v2))$

v2:fm2(v1,v2);

v2a:length(v2);

f '' = Δ(Δph/Δv)/Δv
===============

fderv2(vol,fd1,fd2):= block([fd2:[] ],
 ll:length(vol) ,
  for i:1  thru ll-1 step 1
      do(l2:(fd1[i+1]-fd1[i])/(vol[i+1]-vol[i]),
     fd2:endcons(l2,fd2)),
return(fd2))$     

fd2:fderv2(v2,fd1,fd2);

fd2a:length(fd2);

v2:delete(v2[length(v2)],v2);

v2a:length(v2);

point representation.  (f '' ,graph)
-------------------------------------------------

p7:s1(v2,fd2,dat2); 

wxplot2d([[discrete, p7],[discrete,p7]], [x ,1,14], [y,-120,120],
 [plot_format, xmaxima],[title,"titration weak acid,HA with NaOH"],
 [xlabel," average x ml  NaOH added with the buret"] , [ylabel,"Δ(Δph/Δv)/Δv"],
 [style,[points,0.7,red],[lines,0.6,black]] ,  [nticks,15] )$

detail : f ''
========

wxplot2d([[discrete, p7],[discrete,p7]], [x ,9.5,10.5], [y,-120,120],
 [plot_format, xmaxima],[title,"titration weak acid,HA with NaOH"],
 [xlabel," average x ml  NaOH added with the buret"] , [ylabel,"Δ(Δph/Δv)/Δv"],
 [style,[points,0.7,red],[lines,0.6,black]] ,  [nticks,15] )$

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