Tutorial 5 - 2010
Due date(s): | 25 October 2010 |
(PDF) | Tutorial questions |
Other instructions | Hand-in at class. |
<rst> <rst-options: 'toc' = False/> <rst-options: 'reset-figures' = False/>
.. rubric:: Tutorial objectives: solution of a single, nonlinear equation.
.. note:: All questions below will consider the following problem.
The heat of reaction for a certain reaction is given by :math:`\Delta H_{r}^{0}(T)= -24097 -0.26 T+1.69\times 10^{-3}T^2 + {\displaystyle{\frac{1.5\times10^5}{T}}}\;` cal/mol. Compute the temperature at which :math:`\Delta H_{r}^{0}(T)= -23505` cal/mol.
Question 1 [1]
===
Show the first 4 iterations of the bisection method to solve for :math:`T`, justifying your choice for the initial bracket.
For iteration 2, 3, and 4, please also report these two relative errors:
.. math::
\varepsilon_\text{rel,x}^{(k)} = \displaystyle \left|\frac{x_m^{(k)} - x_m^{(k-1)}}{x_m^{(k)}} \right| \qquad\qquad \varepsilon_\text{rel,f}^{(k)} = \displaystyle \left|\frac{f(x_m^{(k)}) - f(x_m^{(k-1)})}{f(x_m^{(k)})} \right|
Question 2 [1]
===
- . Derive a :math:`g(x) = x` function to use in the fixed-point algorithm.
- . Show the first 3 iterations of using the fixed-point algorithm, starting with an initial guess of :math:`T = 380` K.
- . Will the fixed-point method converge for this problem, using your :math:`g(x)`?
Question 3 [1]
==
- . Write the Newton-Raphson iteration formula that you would use to solve this nonlinear equation.
- . Apply 3 iterations of this formula, also starting from :math:`T = 380` K, and calculate the error tolerances.
Question 4 [1]
==
Comment on the 3 approaches used so far. Are your calculations what you would expect from each method?
Bonus question [1]
=======
A naive code for the bisection algorithm would evaluate the function :math:`f(x)` at the three points, :math:`[x_\ell, x_m, x_u]` in every iteration. Fewer function evaluations can be obtained though.
Write a function, in either MATLAB or Python, that implements the bisection method, that evaluates :math:`f(x)` as few times as possible. You should report the following 8 outputs in each iteration: :math:`[x_\ell^{(k)},\, x_m^{(k)},\, x_u^{(k)},\, f(x_\ell^{(k)}),\, f(x_m^{(k)}),\, f(x_u^{(k)}),\, \varepsilon_\text{rel,x}^{(k)},\, \varepsilon_\text{rel,f}^{(k)}]`.
Use this code to find the solution to the above problem, within a tolerance of :math:`\sqrt{\text{eps}}` based on :math:`\varepsilon_\text{rel,x}^{(k)}`.
.. raw:: latex
\vspace{0.25cm} \hrule \begin{center}END\end{center} </rst>