16
$\begingroup$

I am a high school student taking chemistry who was tasked to solve a large set of Hess's Law problems. Naturally I tried to find a way to get my computer to carry out this repetitive piece of work for me.

I tried to model the problem mathematically and figured out that Hess's Law problems basically had me finding the correct linear combinations.

Suppose we have a problem like this

\begin{align} \ce{4 NH3 + 3 O2 &->6 H2O + 2N2} &\qquad &\Delta_\mathrm{r}H_1 = \pu{-1516 kJ/mol} \tag{1} \\ \ce{2 H2 + O2 &-> 2 H2O} &\qquad &\Delta_\mathrm{r}H_2 = \pu{-572 kJ/mol} \tag{2} \\ \end{align}

And our goal is to try to find the enthalpy of formation of ammonia. How would I express this as a matrix and solve it to find the linear combination. I assume we have to use the row reduce echelon method here. Just not sure how.

$\endgroup$
5
  • 2
    $\begingroup$ Searching for linear algebra tutorial gives a lot of interesting links. $\endgroup$
    – Poutnik
    Jul 8 at 8:04
  • 1
    $\begingroup$ A generally useful and efficient method is the Gauss elimination method, getting the triangular matrix. Many software platforms, including Excel worksheet functions, provide matrix and vector operations to directly solve the set of n linear equations of n variables. But for n=2, the manual substitution approach is easy. $\endgroup$
    – Poutnik
    Jul 8 at 8:17
  • $\begingroup$ It gets set up as the part of the Gauss' algorithm itself. You nulify the numbers below the diagonale by substrating (multiplied ) other rows. $\endgroup$
    – Poutnik
    Jul 8 at 8:21
  • $\begingroup$ Formulate the equation of the Hess law for each reaction and then transform it to the algebraic equation set. $\endgroup$
    – Poutnik
    Jul 8 at 8:24
  • $\begingroup$ Both. Coefficients for the same reaction on the same row of A. Coefficients for the same variable ( unknown Delta H ) to the same column of A. Absolute terms of f(x)=0 to the separate column b. $\endgroup$
    – Poutnik
    Jul 8 at 8:44
24
$\begingroup$

To convert this into a generic linear algebra problem you'd rewrite it in the form $Ax=b$ where $A$ is a matrix of stoichiometric coefficients of size $m \times n$; $x$ is a vector of length n of unknown fitting parameters (the heats you want to determine) and $b$ a known vector of length n.

For the example problem the set of equations can be written in matrix form as

$$\left[\begin{array}{rrrrr} 0 & -4 & -3 & 6 & 2\\ -2 & 0 & -1 & 2 & 0 \end{array}\right]\left[ \begin{array}{l} \Delta_\mathrm{f} H(\ce{H_2(g)})\\\Delta_\mathrm{f} H(\ce{NH_3(g)})\\\Delta_\mathrm{f} H(\ce{O_2(g)})\\\Delta_\mathrm{f} H(\ce{H_2O(l)})\\\Delta_\mathrm{f} H(\ce{N_2(g)}) \\ \end{array}\right] = \left[ \begin{array}{c } \Delta _\mathrm{r}H_1\\\Delta_\mathrm{r}H_2 \end{array}\right]$$

Since many of the terms in the vector of heats on the left-hand-side are known and equal to zero this can be rewritten as

$$\left[\begin{array}{rrlll} -4 & 6 \\ 0 & 2 \end{array}\right]\left[ \begin{array}{c } \Delta_\mathrm{f} H(\ce{NH_3(g)})\\\Delta_\mathrm{f} H(\ce{H_2O(l)}) \end{array}\right] = \left[ \begin{array}{c } \Delta_\mathrm{r} H_1\\\Delta_\mathrm{r} H_2 \end{array}\right]$$

(alternatively the original equation can be written as a $5 \times 5$ array by including additional trivial equations defining the heats of formation of the diatomic gases).

Solution of the above system should be easy, for instance in MATLAB:

A = [-4 6; 0 2];
b = [-1516 -572]';
x = A\b

The problem can of course be solved by inspection. The second equation can be solved for $\Delta_\mathrm{f} H(\ce{H_2O(l)})$, which can be inserted into the first to solve for $\Delta_\mathrm{f} H(\ce{NH3(g)})$.

$\endgroup$
2
  • 1
    $\begingroup$ octave 5.2.0 > A = [-4 6; 0 2]; b = [-1516 -572]'; x = A\b $\endgroup$
    – Galen
    Jul 10 at 19:49
  • 1
    $\begingroup$ Python 3.8.10 >>> import numpy as np; A = np.array([[-4, 6], [0,2]]); b = np.array([-1516, -572]); np.linalg.solve(A,b) $\endgroup$
    – Galen
    Jul 10 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.