Homework 13

CHE 116: Numerical Methods and Statistics

Prof. Andrew White

Version 1.6 (4/24/2015)


Conceptual Questions (2 Points)

  1. Is Error Propogation using partial derivatives exact or an approximation? If it is an approximation, when and why is it valid?

  2. If you have a constant error in your independent variable, you almost always require weighted least-squares instead of ordinary least-squares for non-linear regression. Why?

Exercises (8 Points)

  1. If you have a measurement error of $\sigma_{\lambda} = 2.0$ and you are using the equation:

    $$ y = \lambda e^{-\lambda x}$$

    what is your uncertainty in $y$? Assume $x$ is exact.

  2. What is the equation for standard error in residuals with constant uncertainty in the independent variable?

  3. What is the equation for standard error in residuals with variable uncertainty in the dependent variable?

  4. Give two cases of when to use weighted least-squares

Arrhenius Equation Problem (20 Points)

The Arrhenius Equation allows you to find a reaction rate at a temperature. It is:

$$ k = A e^{-\frac{E_a}{RT}} $$

where $k$ is the reaction rate, $A$ is an empirical constant, $E_a$ is the activation energy, $R$ is the Universal gas constant and $T$ is temperature. In this homework problem, you will determine $A$ and $E_a$ and their confidence intervals.

The chemical reaction that you're observing is the unimolecular dissolution of a 125 Dalton compound in water. This reaction occurs over the course of days inside a large tank which has a controlled temperature. You take an approximately 250mL sample every four hours from the tank and can compute a concentration of the compound by drying the water off and weighing the dry mass. The measurement process takes about 10 minutes and so you may estimate your measurement error in time as 5 minutes, since the reaction continues during the drying process and taking the sample requires some time. Your volume measurements have a measurement error of 0.25 mL and your balance has a measurement error of 0.5 g. You know the temperature exactly.

Knowing the information above, you may fit your concentration data vs time to an exponential decay:

$$C(t) = C_0 e^{-kt}$$

and thus compute a reaction rate. Using reaction rates at four temperatures, you may estimate the activation energy and pre-exponential empricial factor $A$ from the Arrhenius equation. Carefully propogate error at all steps and ensure your final confidence interval includes error from the measurements and the regression. Report the reaction rate in mol / s$\cdot$L and activation energy in kJ. Also, plot concentration vs time for one experiment with error bars on the data and your best fit line. Also plot the best-fit Arrhenius equation and your data with error bars. As a hint, here's the basic workflow of this problem:

  1. Compute concentration and error in concentration at each temperature
  2. Fit the exponential equation above to the concentration vs time for each temperature to get a rate
  3. Compute the error in that rate for each tempeture
  4. Put the rates and temperatures onto one plot
  5. Fit the Arrhenius equation to that plot
  6. Compute the error in the Arrhenius plot terms

Hints: you'll need to use basinhopping with bounds to do the minimization. Also, you should have variable measurement error for concentration due to error propogation. For the final regression to the Arrhenius equation, be careful that your k is a length 4 array, not a 1x4 matrix. I had to reshape mine by using k = np.reshape(k, 4 )

More Hints

The equation for standard error in your concentration fitting should be: $$S_{\epsilon}^2 = \frac{SSR + \sum_i^N \hat{C}_0^2\hat{k}^2e^{-2\hat{k}t} \sigma_t^2 + \sum_i^N \sigma_{c_i}^2}{N}$$

where $SSR = \sum_i^N (\hat{y} - y)^2$.

The final answer should be $E_a \approx 50$ and $A \approx 1000 $ with large uncertainty. I had to use niter=10000 as an extra argument to basinhopping for the final regression.

$T = 25^\circ$C

  • volume in mL
  • mass in g
  • time in minutes

In [2]:
import numpy as np

volume_25 = np.array([276.1, 240.5,  277.6,  260.3,  296.0,  237.1,  247.5,  263.2,  232.2,  264.1,  236.0,  262.2,  293.4,  268.6,  222.7,  280.5,  239.3,  267.6,  242.6,  225.5,  278.0])
mass_25 = np.array([ 13.8,  10.1,   12.8,   12.3,   12.8,    9.7,    9.2,   10.3,    8.2,    8.1,    7.8,    8.1,    8.4,    7.6,    5.3,    7.4,    5.2,    5.4,    5.2,    4.2,    4.9])
time = np.array([0, 480,  960,  1440,  1920,  2400,  2880,  3360,  3840,  4320,  4800,  5280,  5760,  6240,  6720,  7200,  7680,  8160,  8640,  9120,  9600])

$T = 30^\circ$C

  • volume in mL
  • mass in g
  • time - same as above

In [9]:
volume_30 = np.array([243.7, 262.7,  247.4,  224.4,  225.0,  298.5,  233.0,  285.7,  227.5,  243.3,  240.3,  276.1,  276.4,  228.0,  245.2,  236.0,  261.1,  243.3,  275.9,  239.5,  208.0])
mass_30 = np.array([ 12.1,  12.4,    9.0,    8.5,    7.3,    8.3,    4.8,    5.3,    3.3,    3.6,    2.6,    2.6,    2.4,    1.5,    2.4,    1.2,    2.3,    2.0,    2.2,    0.9,    0.4])

$T = -10^\circ$C

  • volume in mL
  • mass in g
  • time - same as above

In [10]:
volume_minus_10 = np.array([254.1, 280.5,  265.7,  233.8,  258.8,  239.6,  279.0,  194.8,  285.9,  278.6,  281.0,  302.7,  265.3,  209.9,  278.0,  213.2,  243.3,  274.4,  238.9,  259.3,  251.6])
mass_minus_10 = np.array([ 12.8,  13.6,   12.5,   11.4,   13.4,   12.5,   12.7,   10.2,   14.0,   13.7,   13.1,   14.2,   12.8,    9.2,   13.0,    8.9,   11.7,   12.8,   10.6,   12.2,   11.1])

$T = 8^\circ$C

  • volume in mL
  • mass in g
  • time - same as above

In [8]:
volume_8 = np.array([249.3, 251.0,  202.6,  291.9,  251.6,  214.1,  272.5,  257.8,  274.7,  261.7,  227.6,  260.9,  295.4,  277.4,  237.2,  260.8,  243.0,  249.6,  258.0,  260.6,  272.4])
mass_8 = np.array([ 12.8,  12.3,    9.6,   14.2,   11.8,   10.1,   12.0,   11.0,   11.4,   11.1,    9.2,   11.0,   11.4,   11.2,    9.6,   10.1,   10.2,    9.2,    9.2,    8.8,   10.5])