Retro programming Nostalgia IV: Acid/Base Equilibrium and Titration (Part I)

The motivation for this article stems from my interest in retro-computing connected, on the one hand, to the re-evaluation of my youthful explorations of scientific computing in the BASIC language and, on the other, to the popularity they are having in the amateur sector in recent years and of teaching, single-board microcomputers (single-board computers, such as, for example, the Raspberry Pi). These small computers have considerably more power at a much lower cost than the microcomputers of the 80s. This made it possible to emulate the operating systems of the legendary Commodore home computer models and the MSX extension on these computers.

Therefore, a renewed interest in the BASIC programming language is also occurring. This interest in retro-computing reflects the nostalgia for the great emotions that the development of consumer information technology brought to my generation in the 1970s and 1980s. I remember being so struck by the creativity in using and programming these microcomputers that it redirected my scientific interests and academic career. I have written in other articles about my first programming adventures with Commodore home computers and MSX systems in the late 80s and early 90s and my rediscoveries in computer archaeology. Among the exhibits, I found a small program I used to study acid/base titrations developed in MSX BASIC. Therefore, I took the opportunity to write notes on acid-base balance and titration and thus provide a restored and improved version of my program to students passionate about programming and grappling with this important concept of analytical chemistry.

The Acid/Base Balance

Historically, the first theory of acid-base balance was proposed by Svante Arrhenius ( 1858-1927) in 1887. Arrhenius classified acidic and basic substances based on their ability to spontaneously dissociate into H+ or OH- ions in solution. The introduction of the concept of chemical equilibrium and, therefore, of the dissociation constant allowed the distinction between strong and weak acids and bases.

At the beginning of the last century (1909),  SPL Sørensen ( 1868-1939) defined the pH scale as a measure of the concentration of H+ in solution. This unit of measurement soon spread because using the properties of decimal logarithms simplifies the notation and calculation of low concentrations of H+ ions. In the same  L.J. Henderson (1878-1942), professor of physiology at Harvard University, studying the mechanisms that contribute to maintaining neutrality in the blood, discovered the ‘buffer effect of some substances that neutralise large amounts of acids in the blood and bases without affecting its neutrality. Henderson reworked the law of mass action for the dissociation of weak acids so that it applied to mixtures of the weak acids and their salts with a strong base, obtaining the well-known equation. K. A. Hasselbalch (1874- 1962), in 1917, converted the Henderson equation in logarithmic terms into the equation known since then as the equation by Henderson-Hasselbalch.

Contrary to popular belief, it was Niels Bjerrum (1879-1958), and not Hasselbalch, who introduced this terminological transformation in some countries, the equation is known as Bjerrum ‘s equation or buffer equation. I will describe the buffer equation in another article.

In 1923 by J .N. Bronsted (1879- 1947) and independently by TM Lowry (1874-1936), the definition of acid and base was generalised as a proton donor and acceptor chemical species, extending acid-base chemistry also to non-aqueous solutions. The progress in quantum chemistry in the first decades of the last century also had a great stimulus in the field, so much so that GN Lewis (1875-1946), in the same year (1923) proposed a definition of acids, all chemical species capable of accepting a pair of electrons, and of bases those capable of donating an electron pair.

But now let’s look in more detail at some aspects of chemical equilibrium. From the definition of Bronsted and Lowry, an acid or a base are chemical species capable of donating or accepting protons. An acid/base equilibrium is the thermodynamic condition in which a system consisting of a proton donor and a proton acceptor chemical species reaches the maximum available entropy or, equivalently, the minimum of its Gibbs free energy.

The equilibrium in an aqueous solution of a generic monoprotic acid (A) and basic (B) species is described with the equation:

AH _{aq}+ B^{-}_{aq} <=> A^{-}_{aq} + BH_{aq} 

where AH e B^{-} are generic dissociated acids and basic compounds, respectively; using the concentrations of these species, we can characterise their relationship as

K_{equ} = \frac{[A^{-}_{aq}][BH_{aq}]}{[AH _{aq}][B^{-}_{aq}]}

To go into more detail, here are some examples of acid/base equilibrium reactions. Pure water is an amphiprotic substance, i.e. a chemical species that can donate and accept protons.

H_2O + H_2O <=> H_3O^{+} + OH^{-}_{(aq)}

The ions H_3O^{+} e HO^{-} are known as oxonium and hydroxide cations, respectively.

Water in contact with air absorbs the gases (according to Henry’s law) contained. In particular, dissolving carbon dioxide reacts with water and its ions to form carbonic acid:

CO_2 + 2H_2 O <=> CO_3H^{-} + H_3 O^{+}

which can also yield the other proton

CO_3 H^{-} + H_2 O <=> CO_3 ^{2-} + H_3 O^{+} 

These balances delight our palate when we savour carbonated drinks such as carbonated mineral waters (natural or artificial) or sparkling wine on New Year’s Eve. But they are also the fundamental equations that regulate the delicate chemical balance between ocean water and the atmosphere. The excess of carbonic acid created by the increase C O_2 due to human activity is acidifying the oceans destroying fragile ecosystems such as coral reefs with enormous environmental consequences. The undissociated acid is the carbonic acid H_2 CO_3 , an unstable compound prone to dissociation into carbon dioxide.

Another prevalent acid in our kitchens is acetic acid which releases protons in water according to the equilibrium

{HCl + NaOH <=> Cl^{-}_{(aq)} + Na^{+}_{(aq)} + H_2 O}

{CH_3 COOH + OH^{-}_{(aq)} <=> CH_3 COO^{-}_{(aq)} + H_2 O}

Acetic and carbonic acids are two examples of weak acids, i.e., substances that release protons less quickly than other compounds, which are therefore called strong acids. A homemade example of a strong acid is muriatic acid or diluted hydrochloric acid (HCl), used in diluted form to free clogged pipes from stubborn encrustations. Regarding chemical equilibrium, the dissociation constants between the two types of acids differ in the order of magnitude, with those of the former being very small.

Bases are negatively charged chemical species that tend to bind protons. A basic example is the hydroxyl ion released from the dissociation of water or is present in salts, such as caustic soda—another household product.

Also, we can distinguish between weak and strong bases in this case. It can be seen immediately that every acid is associated with a base opposite to the acid. Thus, carbonic acid, a strong acid, has the carboxylic ion as its weak base and Muriatic acid (strong acid) has the chloride ion (weak base) as its base. On the other hand, water, a weak acid, has a hydroxyl (strong base) as its base.

Acid and base react with neutralisation reactions. The reaction

{HCl + NaOH <=> Cl^{-}_{(aq)} + Na^{+}_{(aq)} + H_2 O}

is a neutralisation of a strong acid with a strong base. While the acetic acid reaction described above is a neutralisation reaction of a weak acid with a strong base.

Neutralisation reactions can be used to determine the concentration of an acid or base in a solution leading to the subject of this article.

Acid/Base titration

Titration is one of the fundamental practical skills that every chemistry student must be able to perform with great accuracy and precision, at least up until the time I attended the Chemistry degree course. However, the importance of learning the technique is not linked to the development of the dexterity necessary for flawless execution but to understanding the theoretical aspects of the procedure as well as the statistical analysis of the results.

Acid/base titration is a procedure of analytical chemistry that measures the title of an acid or base solution using a suitable titrant and a colourimetric indicator or a pH meter. The instrument of this art is the burette, a long-graduated cylinder with an accurate graduated scale indicating the volume of titrant that is added to its meniscus. In addition, the burette is equipped with a stopcock which controls the added volume.

The following regions characterise an acid/base titration curve:

  • Only acid or base
  • equivalence points,
  • intermediate points before and after equivalence.

The titration consists of the addition of a volume (({V}_B)  of the titrant having a known concentration (C_A ) to the solution to be titrated using the burette. The solution to be titrated has a concentration C_A and volume of {V}_A .

The titration curve reports the pH value as a function of the added volume. The pH can be measured with a pH meter. Still, in the laboratory procedure, the equivalence point corresponding to the value pH = 7 was identified using an indicator, i.e. a dye that changes the chromatic properties in a narrow pH range. In this type of titration, the indicator used is phenolphthalein (3,3-Bis(4hydroxyphenyl)-2-benzofuran-1(3 H )-one), the structure of which is shown in Figure 1.

Figure 1: Chemical formula of phenolphthalein.

This molecule, synthesised in 1871 by German chemist Adolf von Baeyer, ranges from colourless to a faint pink at the equivalence point and then continues increasing hue colour as the pH increases.

This indicator is added a small amount to the solution to be titrated. Of course, phenolphthalein can be used when the change is visible, otherwise, another indicator or a spectrophotometer, an electronic measurer of the visible light absorption of a sample, is used.

I remember my first encounter with the titration method with phenolphthalein as an indicator when I was in middle school, and my science teacher organised a school visit to a local milk processing company (SOLAC in Frosinone). During the laboratory visit, a technician showed us the procedure for determining the lactic acid content in milk using phenolphthalein in an alcoholic solution (the substance is poorly soluble in water) as an indicator since its pink colour stands out clearly against the white background of the milk.

Figure 2: Chemical formula of the acid lactic.

Let us now analyse how the chemical equilibrium in a solution of an acid or a base changes with the addition of the titrant. In the first part of this article, we will limit ourselves to considering only strong acids and bases for both the titrating solution and the titrant.

Titration of a strong acid with a strong base

The simplest titration measures the concentration of fully dissociated acids or bases in water. For example, we want to determine the acid content (hydrochloric) in the muriatic acid solution purchased at the supermarket.

In this case, the burette is filled with a dissociated base such as, for example, sodium hydroxide ( (Na O H )).

Let us consider the concentrations of the ions [H_3O^+] in the various steps of the titration. We denote C_A the concentration of the solution having volume {V}_A, C_T the concentration of the titrant, and {V}_T   the volume of titrant added. Before equivalence, the concentration of

[H_3 O^+] = \frac{V_AC_A-V_TC_B}{V_A+V_T} 

From this we get the value of

pH= -\log_{10} [H_3O^+]

With the addition of base, the value of   pH    increases until it reaches pH = 6 where the contribution of ions [ H_3 O^{+} ]  from the self-dissociation of water becomes significant.

In the range of 6 \leq pH < 7  , we can distinguish the following two conditions.

The condition where [H_3 O^{+}]_{acido} \geq[H_3 O^{+}]_{acqua} , for which the total concentration is given by the formula

[H_3O^+]= [H_3O^+]_{acido} + \frac{10^{-14}}{ [H_3O^+]_{acido}}

The second term derives from the dissociation equilibrium of water examined in the introductory paragraph, whose constant is equal to

k_w =10^{-14} = [H_3 O^{+}][OH^{-}]

expressing the relationship in terms of volumes and concentrations we obtain

[H_3O^+]= \frac{V_AC_A-V_TC_T}{V_A+V_T}+10^{-14} \frac{V_A+V_T}{V_AC_A-V_TC_T}

The condition in which    [H_3O^{+}]_{acido} \leq [H_3 O^{+}]_{acqua}, it is approximated as follows

[ H_3 O^{+} ] = [ H_3 O^{+} ]_{acido} + \frac{10^{-14}}{ 10^{-7} + [ H_3 O^{+} ]_{acido}}

Which, expressed in terms of volumes and concentrations, is obtained

[ H_3 O^{+} ] = \frac{V_AC_A-V_TC_T}{V_A+V_T} + \frac{10^{-14}} {10^{-7} + \frac{V_AC_A - V_TC_T}{V_A + V_T}}

The value of pH can then be calculated using the usual expression.

.pH = -\log_{10}  [H_3 O^{+}] .

Equivalently we have that pH > 7. For values of pH > 7, the value of pH is determined by the base excess

and the contribution of water. Again we can distinguish two conditions which determine the total hydroxide ion content.

The condition where [O H^{+}] _{base} >= [O H^{+} ] _{acqua} ,

for which the total concentration is given by the formula

[O H^{-}]= [O H^{-} ]_{base} + \frac{10^{-14}}{ [OH^{-}]_{acido}}

which determines a value of pH  in terms of volumes and concentrations equal to

pH = 14 + \frac{V_TC_T-V_AC_A}{V_A+V_T} + 10^{-14} \frac{V_A + V_T}{V_TC_T - V_AC_A}

The condition where    [O H^{+} ]_{base} \geq \frac{10^{-14}}{[O H^+]_{base}} , where the pH is

calculated with the formula

pH = 14 +  \frac{V_TC_T - V_AC_A}{V_A + V_T} + \frac{10^{-14}}{10^{-7} + \frac{V_A+V_T}{V_TC_T - V_AC_A}} .

Figure 3 shows the titration of a hydrochloric acid solution with sodium hydroxide solution as the titrant.

Figure 3: Example of a titration curve of a strong acid with a strong base.

The titration of a strong base with a strong acid

As shown in Figure 4, the titration curve of a strong base with a strong acid is symmetrical about the equivalence point (pH = 7) to that of the titration of a strong base with a strong acid.

Figure 4: Example of titration curve of a strong base with a strong acid.

Therefore, in this case, the equations of pH in the various conditions can be obtained by simply applying the relation

pH^{tit.base} =14- pH.

Where pH  the relationships obtained in the previous paragraph are replaced by.

In a future article we will consider the case of titrations with weak uni-protic acids and bases.

The program in BASIC

The curves shown in this article have been obtained with the BASIC program reported in the appendix of the version in the Italian language of this article. The program is an updated version of the original MSX basic code. I used the QB64 open-source compiler to develop the program ( ). This BASIC compiler is compatible with QuickBasic. QB64 first translates the program into C++, then compiling it with a C++ compiler. Thus, the resulting executable is significantly faster than a translated BASIC program.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.