THE REINSURANCE ACTUARY
  • Blog
  • Project Euler
  • Category Theory
  • Disclaimer

Chemical Equations and Diophantine Equations

17/10/2016

 

I was reading about SpaceX on Wikipedia the other day, just after they announced their plan to travel to Mars, and about an hour later, as can happen on Wikipedia, I found myself reading about Chemistry and feeling nostalgic about all the subjects that I used to know in detail but now have just a hazy recollection of. 

Reading the material on Chemistry got me thinking that there are quite a few similarities between chemical elements and prime numbers. All chemical compounds can be reduced to a combination of chemical elements in a unique way, and all integers can be reduced to a product of prime factors in a unique way. Both serve as the building blocks from which more complicated objects are constructed.

What happens if we attempt to formalise this relationship? It turns out we can actually come up with a mathematical process for balancing chemical equations. And this solution is related to the study of mathematical objects called Diophantine equations.

What is a Chemical Equation?

Let’s start by reviewing what a chemical is. A chemical equation is an equation which defines a chemical reaction. The left hand side has the inputs to the reaction and the right hand side has the outputs. So for example, the process of adding hydrogen and oxygen to create water can be written as:

          H + O -> H2O

This equation though is not balanced. We’ve got two hydrogens on the right, but only one on the left. Therefore there is some information missing.

Balancing a Chemical Equation

How do we balance a Chemical Equation? We need to define the relative amounts of the inputs and outputs so that the total numbers of each element are the same on both sides of the equation. We do this by writing an integer before each input and an integer before each output to denote the relative amounts of each molecule in the reaction.
In the case of the combustion reaction above, we can see by inspection that we need two hydrogen elements and one water element to create a water molecule, that is:

          2 H + O = H2O

What happens though if we need to balance a more complicated Equation? For example, here is the equation for the combustion of gunpowder:

          KNO3 + S + C → K2S + N2 + CO2

It is not immediately obvious to me how to balance this equation. It’s not too complicated and could probably be balanced by inspection, but what if the equation was much more complicated?

Chemical Elements and Prime Numbers

If we take the step of associating a prime number to each element in the equation, for example, let’s make the following associations:

  • K = 67 (the 19th prime number, Potassium being the 19th element)
  • N = 17 (the 7th prime number, Nitrogen being the 7th element)
  • O = 19 (the 8th prime number, Oxygen being the 8th element)
  • S = 47 (the 16th prime number, Silicon being the 16th element)
  • C = 13 (the 13th prime number, Carbon being the 13th element)

And we also replace the additive notation with a multiplicative notation, then we get the following mathematical equation for the combustion of gunpowder:

$(67*17*(19^3))^a * 47^b * 13^c = ((67^2)*47)^d * (17^2)^e *(13*(19^2))^f$

​Equating prime factors on the right and prime factors on the left gives us a system of linear Diophantine equations, one for each prime:

a = 2d
a = 2e
3a = 2f
b = d
c = f

Diophantine Equations

A Diophantine equation is a polynomial equation for which we are only interested in integer solutions. Since a chemical equation must have integer coefficients, the resulting system of linear equations is actually a system of Diophantine equations.

So returning to our chemical equation above, we can solve this equation using linear algebra. In this case, I put the system of linear equations into an online calculator, and we find that solutions to this system are of the following form for integers n:
 
a = 2 n
b = n
c = 3 n
d = n
e = n
f = 3n

I used the following online calculator:


http://www.quickmath.com/webMathematica3/quickmath/equations/solve/advanced.jsp​
 
As we are interested in integer solutions, we need to now find n such that all our coefficients take integer values. In this case, we can take n to be 1 giving us:

a = 2
b = 1
c = 3
d = 1
e = 1
f = 3
 
Putting this back into our equation above we get:
 
          2 KNO3 + S + 3 C → K2S + N2 + 3 CO2

Which we can see is a balanced chemical equation.
​
This process can be extended to balance any chemical equation, no matter how complicated.

​​

Your comment will be posted after it is approved.


Leave a Reply.

    Author

    ​​I work as an actuary and underwriter at a global reinsurer in London.

    I mainly write about Maths, Finance, and Technology.
    ​
    If you would like to get in touch, then feel free to send me an email at:

    ​LewisWalshActuary@gmail.com

      Sign up to get updates when new posts are added​

    Subscribe

    RSS Feed

    Categories

    All
    Actuarial Careers/Exams
    Actuarial Modelling
    Bitcoin/Blockchain
    Book Reviews
    Economics
    Finance
    Forecasting
    Insurance
    Law
    Machine Learning
    Maths
    Misc
    Physics/Chemistry
    Poker
    Puzzles/Problems
    Statistics
    VBA

    Archives

    March 2023
    February 2023
    October 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    October 2021
    September 2021
    August 2021
    July 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    May 2020
    March 2020
    February 2020
    January 2020
    December 2019
    November 2019
    October 2019
    September 2019
    April 2019
    March 2019
    August 2018
    July 2018
    June 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    June 2017
    May 2017
    April 2017
    March 2017
    February 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    April 2016
    January 2016

  • Blog
  • Project Euler
  • Category Theory
  • Disclaimer