# Tutorial 6 - 2010 - Solution

 Due date(s): 28 October 2010 (PDF) Tutorial questions (PDF) Solutions Other instructions Hand-in at class.

<rst> <rst-options: 'toc' = False/> <rst-options: 'reset-figures' = False/>

.. |m3| replace:: m\ :sup:3 .. highlight:: python

.. rubric:: Tutorial objectives: Lagrange and Newton interpolation; due 28 October.

Question 1 [2]

###### ====

Use the heat capacity data in the course slides (slide 5) at :math:T = [300, 500, 900] K, with corresponding heat capacities :math:C_p = [29.85, 30.51, 33.42] \rm J\ mol^{-1}\ K^{-1}

1. . Construct the Lagrange interpolating polynomial of order 2 that passes through all three data points. There is no need to simplify the polynomial.
2. . Using this polynomial, compute (i.e. predict) the estimated heat capacity at :math:T = 400 K and :math:T = 800 K. Are the predictions reasonable?
3. . Create a computer plot that shows your polynomial, over the range :math:T \in [300, 1600] K. Superimpose on this plot the 14 data points from slide 5 in the course notes.

Where is the greatest prediction error in your polynomial? Is this expected?

1. . If you were to construct the Newton interpolating polynomial and estimate the heat capacities at :math:T = 400 K and :math:T = 800 K, what answer would you get? Explain.

Solution

1. . The second order Lagrange polynomial that approximates the heat capacity function, :math:C_p(T) has the form:

.. math::

C_p(T) \approx p_2(T) = y_1 \ell_1(T) + y_2 \ell_2(T) + y_3 \ell_3(T)

where each of the Lagrange cardinal functions, for this case is:

.. math::

\ell_1(T) &= \displaystyle \frac{(T-500)(T-900)}{(300-500)(300-900)} \\ \ell_2(T) &= \displaystyle \frac{(T-300)(T-900)}{(500-300)(500-900)} \\ \ell_3(T) &= \displaystyle \frac{(T-300)(T-500)}{(900-300)(900-500)}

So the Lagrange polynomial approximation is:

.. math::

C_p(T) \approx = \displaystyle 29.85 \cdot \frac{(T-500)(T-900)}{120000} + 30.51 \cdot \frac{(T-300)(T-900)}{-80000} + 33.42 \cdot \frac{(T-300)(T-500)}{240000}

1. .

:math:C_p(T=400K) \approx (29.85)(0.4167) + (30.51)(0.625) + (33.42)(-0.04167) = 30.11 J/(mol.K)

:math:C_p(T=800K) \approx (29.85)(-0.25) + (30.51)(0.625) + (33.42)(0.625) = 32.49 J/(mol.K)

The predictions are within the range of the neighbouring data points, and fall within the upward trend relationship shown between temperature and heat capacity. Further, they are similar (less than 1% error) to the values shown at these data points in the course slides.

1. . The plot shows the 14 data points (black circles), of which 3 (red asterisks) were used to develop the Lagrange polynomial. The polynomial's accuracy is greatest with the range of these 3 points. Above them the accuracy deteriorates very rapidly, indicating the problem with extrapolation.

.. figure:: images/tut6-lagrange-polynomial.png :scale: 60 :align: center

Importantly, the Lagrange polynomial passes through the 3 source data points.

1. . You get the same answers as in part 2, since the polynomial was created as a second order polynomial passing through 3 data points. This implies the polynomial is unique, and that the Newton form and the Lagrange form of the polynomial, when simplified to :math:p_2(x) = a_0 + a_1x + a_2 x^2, would be identical. There was no need to actually calculate the Newton form for this question.

Question 2 [1]

###### ====

The heat of reaction for a specific reaction depends on temperature as follows:

##### ======================================= ====== ===== ===== ===== =====
math:T \rm[^\circ C] -250 -200 -100 0 100 300

------ ----- ----- ----- ----- -----

math:\Delta H_R \rm[J\ mol^{-1}\ K^{-1}] 160.0 318.0 699.0 870.0 941.0 1040
##### ======================================= ====== ===== ===== ===== =====
1. . Express :math:\Delta H_R as a 5th-order polynomial using the Newton form of the interpolating polynomials. Report your intermediate results in a chart, as shown in the course material.
2. . Estimate :math:\Delta H_R(T=200 \rm ^\circ C) and :math:\Delta H_R(T=400 \rm ^\circ C) using the Newton polynomials. Comment on the results.

Solution

1. . Newton interpolating polynomials are best determined using a table format:

.. math::

\begin{array}{rrrrrrr} \hline \hline ~ T & \Delta H_R & \text{Two terms} & \text{Three terms} & \text{Four terms} & \text{Five terms} & \text{Six terms}\\ -250 & \underline{160.0} & \frac{318-160}{-200-(-250)}=\underline{3.16} & \frac{3.81 - 3.16}{-100-(-250)} = \underline{4.33\times 10^{-3}} & \underline{ -5.933\times 10^{-5}} & \underline{2.219\times 10^{-7}} & \underline{-4.312\times 10^{-10}} \\ -200 & 318.0 & \frac{699-318}{-100-(-200)} = 3.81 & \frac{1.71 - 3.81}{0-(-200)} = -1.05 \times 10^{-2} & 1.833\times 10^{-5} & -1.525\times 10^{-8} & \\ -100 & 699.0 & \frac{870-699}{0-(-100)} = 1.71 & \frac{0.71 - 1.71}{100-(-100)} = -5.0 \times 10^{-3} & 1.071\times 10^{-5} & & \\ 0 & 870.0 & \frac{941-870}{100-0} = 0.71 & \frac{0.495 - 0.71}{300-0} = -7.167 \times 10^{-4} & & & \\ 100 & 941.0 & \frac{1040-941}{300-100} = 0.495 & & & & \\ 300 & 1040 & & & & & \\ \hline \hline \end{array}

Therefore the Newton interpolating polynomial for the data set described in this equation is the following.

.. math::

f(x) &= b_{0}+b_{1}(x-x_{1})+b_{2}(x-x_{1})(x-x_{2})+ \ldots +b_{5}(x-x_{1})(x-x_{2})(x-x_{3})(x-x_{4})(x-x_{5}) \\ &= {\bf 160.0} + {\bf 3.16} (x+250) + {\bf 4.33\times 10^{-3}} (x+250) (x+200) {\bf -5.933\times 10^{-5}} (x+250) (x+200) (x+100) + \nonumber \\ &{\bf 2.219\times 10^{-7}} (x+250) (x+200) (x+100) (x-0) {\bf -4.312\times 10^{-10}}(x+250) (x+200) (x+100) (x-0) (x-100) \nonumber

1. . The requested estimates are: :math:f(200) = 1088 J/(mol.K) and :math:f(400) = -447 J/(mol.K)

The estimate for :math:T=200\ \rm ^\circ C makes sense, as the specific heat capacity value falls between the values for :math:T=100\ \rm ^\circ C and :math:T=300\ \rm ^\circ C. The estimate for :math:T=400\ \rm ^\circ C does not make sense however, as it is *much lower* than the value at :math:T=300\ \rm ^\circ C. Since we see in the raw data that specific heat capacity increases with temperature, this estimate is clearly not very good. This illustrates the fact that an interpolating polynomial is only good for values within its bounds. Extrapolated estimates should not be relied upon.

The figure illustrates what is happening for this case, where the Newton polynomial has been superimposed on the raw data (circles) and the two predictions (asterisks).

.. figure:: images/tut6-newton-polynomial.png :scale: 60 :align: center

.. raw:: latex

\vspace{0.25cm} \hrule \begin{center}END\end{center} </rst>