Assignment 3 - 2010 - Solution

From Process Model Formulation and Solution: 3E4
Revision as of 08:51, 16 September 2018 by Kevindunn (talk | contribs)
Jump to navigation Jump to search

<rst> <rst-options: 'toc' = False/> <rst-options: 'reset-figures' = False/> .. |m3| replace:: m\ :sup:`3`

Question 1 [2]

====

The Secant method is the most widely used algorithm for solving a nonlinear equation, in chemical engineering, and other areas. Write a MATLAB or Python function that implements the Secant method, using a minimum number of function evaluations. (Python users: please do not just copy the built-in Secant method).

Your function should accept the following inputs:

  • a function handle to :math:`f(x)` [see the `software tutorial <http://modelling3e4.connectmv.com/wiki/Software_tutorial/Functions_as_objects>`_ on the course website for a description of function handles]
  • a relaxation coefficient, :math:`0 < \alpha \leq 1.0`
  • the stopping tolerance, :math:`\varepsilon_\text{tol}`
  • the maximum number of iterations, ``maxiter`` (default = 200)
  • a single starting guess, :math:`x^{(0)}`

Your code should automatically calculate :math:`x^{(-1)} = 1.001x^{(0)}`, and should use a minimum number of function evaluations. The stopping criterion should be as shown in the course notes:

.. math::

\left|f(x^{(k)})\right| \leq \epsilon_{\rm tol} \qquad \text{and/or} \qquad \left|\frac{x^{(k)}-x^{(k-1)}}{x^{(k)}}\right| \leq \epsilon_{\rm tol}

Please print out a table at each iteration that shows these 5 outputs:

  • Iteration :math:`k`
  • :math:`x^{(k)}`
  • :math:`f(x^{(k)})`
  • :math:`\displaystyle \left|\frac{x^{(k)}-x^{(k-1)}}{x^{(k)}}\right|`
  • Relaxed :math:`\Delta x`

Solution


See the following MATLAB and Python code:

.. twocolumncode:: :code1: ../che3e4/Assignments/Assignment-3/code/secant_method.m :language1: matlab :header1: MATLAB code :code2: ../che3e4/Assignments/Assignment-3/code/secant.py :language2: python :header2: Python code

Question 2 [2]

===

In your reactor design course you will learn about adiabatic CSTR's exhibiting multiple steady states, depending on the reactor inlet temperature. In practice reactors are sometimes operated at an unstable steady point, due to process economics or improved conversion. The equation below was derived for such a system:

.. math::

f(T) = (T-T_\text{feed}) - 150 \times \frac{1.34\times 10^9 e^{-\frac{7554}{T}}}{1+1.34\times 10^9 e^{-\frac{7554}{T}}}

There is more than one temperature at which :math:`f(T) = 0`; each :math:`f(T) = 0` corresponds to a reactor steady state. Use the secant method, with relaxation factor :math:`\alpha = 0.9`, and :math:`T_\text{feed} = 300` K to find one of these steady state temperatures, using starting values of :math:`T^{(0)}=320` K and :math:`T^{(-1)}= 1.001 \times 320` K.

  1. . Show the first 3 iterations by hand. Explains what happens in the 3rd iteration, by means of a plot of :math:`f(x)`, and marking the iterations used so far on this plot.
  2. . What could you change to avoid the problem in iteration 3?
  3. . Compare your manual calculations in step 1 with the computer output from the previous question. Also report the temperature your computer code finds for :math:`f(T)=0` at this starting guess. Select a reasonable tolerance value.
  4. . Use the computer code from question 1, but with a starting value of :math:`T = 400` K, and report the steady state operating temperature found.
  5. . Comment on the solutions found from the two different starting points.

Solution


First we evaluate the function at the two initial guesses (given :math:`T_\text{feed}=300`): :math:`f(T^{(0)}=320)=9.535`, and :math:`f(T^{(-1)})=1.001\times 320)= 9.623`. Now we apply the secant formula to find the first approximation :math:`T^{(1)}`:

.. math::

T^{(1)}=T^{(0)}-\alpha\displaystyle\frac{f(T^{(0)})}{\displaystyle\frac{f(T^{(0)})-f(T^{(-1)})}{T^{(0)}-T^{(-1)}}}= 320.0 - 0.9 \displaystyle \frac{9.535}{\displaystyle \frac{9.535 - 9.623}{320 - 320.32}} = 320.0 - 0.9 \times 34.67 = 288.8

Evaluate :math:`f(T^{(1)})`, and repeat the above calculation to obtain :math:`T^{(1)}`:

.. math::

T^{(2)}=T^{(1)}-\alpha\displaystyle\frac{f(T^{(1)})}{\displaystyle\frac{f(T^{(1)})-f(T^{(0)})}{T^{(1)}-T^{(0)}}}= 304.5\\

Evaluate :math:`f(T^{(2)})`, and repeat the above calculation to obtain :math:`T^{(3)}`:

.. math:: T^{(3)}=T^{(2)}-\alpha\displaystyle\frac{f(T^{(2)})}{\displaystyle\frac{f(T^{(2)})-f(T^{(1)})}{T^{(2)}-T^{(1)}}}=303.2

The first three iterations (and the initial guess) are plotted below:

.. figure:: ../che3e4/Assignments/Assignment-3/images/secant-iterations.png :scale: 50 :align: center

As you can see above, the first three iterations result in reasonable values, meaning that, as a sign of convergence, the difference between successive temperatures are getting less and less. Also, the value of the function itself is continually getting close to zero with the iterations. However, if you got, for example, negative absolute temperatures which is not physically acceptable, or the function value diverged from zero instead of getting closer to it, you could change your initial guesses or the :math:`\alpha` value to avoid the problem.

The output from the code in question 1 is as follows::

Iteration x f(x) Rel step alpha * Delta x 1 320.00000 9.53534 0.00100 -31.17468 2 288.82532 -12.04971 0.10794 15.66275 3 304.48807 1.18307 0.05144 -1.26028 4 303.22778 0.24013 0.00416 -0.28886 5 302.93892 0.02004 0.00095 -0.02368 6 302.91525 0.00194 0.00008 -0.00228 7 302.91296 0.00019 0.00001 -0.00023 8 302.91274 0.00002 0.00000 -0.00002 9 302.91271 0.00000 0.00000 -0.00000 10 302.91271 0.00000 0.00000 -0.00000 302.912711645

The output from the code matches the hand calculations (otherwise something is wrong!). With the tolerance chosen as :math:`\varepsilon_\text{tol}=\sqrt{\text{eps}}`, the obtained temperature on convergence will be :math:`T^{(10)}=302.9` K.

With a different initial guess as :math:`T^{(0)}=400.0`, and all other settings being the same, the obtained temperature will be: :math:`T^7=447.7`. You see that a different initial guess resulted in a far different solution. This is because the given function has multiple solutions. When an iterative method is used to solve the function, the obtained solution will depend on the choice of the initial guess. So, in order to find all solutions to a nonlinear equation, one way is to try different initial guesses. (Now try :math:`T^{(0)}=340.0` and see what you get!)

The following computer code was used to solve this question:

.. twocolumncode:: :code1: ../che3e4/Assignments/Assignment-3/code/Q2_func.m :language1: matlab :header1: MATLAB code :code2: ../che3e4/Assignments/Assignment-3/code/reactor.py :language2: python :header2: Python code

Question 3 [2]

==

In assignment 1 we derived the dynamic balance for a bioreactor system. The steady state nutrient concentration, :math:`{\sf \overline{N}}` and the steady state biomass concentration, :math:`{\sf \overline{B}}`, can be shown to be:

.. math::

\frac{dN}{dt} &= 0 = {\sf \overline{N}}_\text{in}\frac{F}{V} - {\sf \overline{N}}\frac{F}{V} - \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{K+{\sf \overline{N}}}\right){\sf \overline{B}}\\ \frac{dB}{dt} &= 0 = - {\sf \overline{B}}\frac{F}{V} + \left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{K+{\sf \overline{N}}}\right){\sf \overline{B}}

Although we showed in assignment 1 that we can solve one equation and substitute it into the other, you should not do that for this question.

Rather, let :math:`\displaystyle \frac{dN}{dt} = f_1({\sf \overline{N}}, {\sf \overline{B}}) = 0` and let :math:`\displaystyle \frac{dB}{dt} = f_2({\sf \overline{N}}, {\sf \overline{B}}) = 0`. Solve this coupled set of nonlinear equations for :math:`{\bf x} = ({\sf \overline{N}}, {\sf \overline{B}})` using Newton's method.

Use the following approach in your answer:

#. Construct the Jacobian matrix, :math:`{\bf J}`, symbolically in terms of the variables used in the equations. #. Simplify the Jacobian by substituting in these known constants:

* :math:`{\sf \overline{N}}_\text{in} = 100` g/|m3| * :math:`F = 5000` |m3|/day * :math:`V = 1600` |m3| * :math:`Y_B = 0.80` conversion efficiency * :math:`\mu_\text{max} = 5` 1/day * :math:`K = 20` g/|m3|

#. Let your initial guess be :math:`{\bf x}^{(0)} = (40 \text{g/m$^3$}, 20 \text{g/m$^3$})`. Calculate 2 iterations of the multivariate Newton-Raphson method, to show :math:`{\bf x}^{(1)}` and :math:`{\bf x}^{(2)}`. Take a full Newton step at every iteration. #. Calculate and show the convergence tolerance, using the 2-norm for each iteration. #. Compare these iterations to the true solution presented by Elliot in assignment 1. Is Newton's method converging to this answer?

Feel free to code up the Jacobian matrix, and the functions :math:`f_1` and :math:`f_2` in MATLAB or Python and use your code to evaluate :math:`{\bf J}({\sf \overline{N}}, {\sf \overline{B}})`, to avoid manual calculation errors.

Solution


  1. . We start by deriving the Jacobian matrix for our two function system:

.. math::

J\left({\sf \overline{N}},{\sf \overline{B}}\right) &= \left[\begin{array}{ll} \frac{\partial f_1({\sf \overline{N}}, {\sf \overline{B}})}{\partial {\sf \overline{N}}} & \frac{\partial f_1({\sf \overline{N}}, {\sf \overline{B}})}{\partial {\sf \overline{B}}} \\ \frac{\partial f_2({\sf \overline{N}}, {\sf \overline{B}})}{\partial {\sf \overline{N}}} & \frac{\partial f_2({\sf \overline{N}}, {\sf \overline{B}})}{\partial {\sf \overline{B}}} \\ \end{array}\right]\\ J\left({\sf \overline{N}},{\sf \overline{B}}\right) &= \left[\begin{array}{ccc} - \frac{F}{V} - \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{1}{K+{\sf \overline{N}}}\right){\sf \overline{B}} + \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{\left(K+{\sf \overline{N}}\right)^{2}}\right){\sf \overline{B}} & \quad , \quad & - \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{K+{\sf \overline{N}}}\right) \\ \left(\mu_{\text{max}}\frac{1}{K+{\sf \overline{N}}}\right){\sf \overline{B}} - \left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{\left(K+{\sf \overline{N}}\right)^{2}}\right){\sf \overline{B}} & \quad , \quad & - \frac{F}{V} + \left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{K+{\sf \overline{N}}}\right) \\ \end{array}\right]

  1. . Subbing in the constant values provided for this question results in the following simplified Jacobian.

.. raw:: latex

\\ {\footnotesize [The PDF version of the solutions is cut off on the right edge of the page; please refer to the course website to get the full solution.]}

.. math::

J\left({\sf \overline{N}},{\sf \overline{B}}\right) &= \left[\begin{array}{ccc} - \frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)} - \left(\frac{1}{\left(0.80\right)}\right)\left(\left(5 \frac{1}{day}\right)\frac{1}{\left(20 \frac{gCOD}{m^{3}}\right)+{\sf \overline{N}}}\right){\sf \overline{B}} + \left(\frac{1}{\left(0.80\right)}\right)\left(\left(5 \frac{1}{day}\right)\frac{{\sf \overline{N}}}{\left(\left(20 \frac{gCOD}{m^{3}}\right)+{\sf \overline{N}}\right)^{2}}\right){\sf \overline{B}} & \quad , \quad & - \left(\frac{1}{\left(0.80\right)}\right)\left(\left(5 \frac{1}{day}\right)\frac{{\sf \overline{N}}}{\left(20 \frac{gCOD}{m^{3}}\right)+{\sf \overline{N}}}\right) \\ \left(\left(5 \frac{1}{day}\right)\frac{1}{\left(20 \frac{gCOD}{m^{3}}\right)+{\sf \overline{N}}}\right){\sf \overline{B}} - \left(\left(5 \frac{1}{day}\right)\frac{{\sf \overline{N}}}{\left(\left(20 \frac{gCOD}{m^{3}}\right)+{\sf \overline{N}}\right)^{2}}\right){\sf \overline{B}} & \quad , \quad & - \frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)} + \left(\left(5 \frac{1}{day}\right)\frac{{\sf \overline{N}}}{\left(20 \frac{gCOD}{m^{3}}\right)+{\sf \overline{N}}}\right) \\ \end{array}\right]

  1. . In this case we are in the luckiest of situations, we know the exact solution so we can track both relative and absolute errors. The exact solution (taken from Assignment 1) is given by the following equations:

.. math::

{\sf \overline{N}} &= \left(\frac{\frac{F}{V_{R}}K}{\left(\mu_{\text{max}}-\frac{F}{V_{R}}\right)}\right)\\ {\sf \overline{B}} &= \frac{\frac{F}{V_{R}}\left(N_{0} - {\sf \overline{N}}\right)}{\left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{{\sf \overline{N}}}{K+{\sf \overline{N}}}\right)}

Subbing in the given constants

.. math::

{\sf \overline{N}} &= \left(\frac{\left(\frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)}\right)\left(20 \frac{gCOD}{m^{3}}\right)}{\left(\left(5 \frac{1}{day}\right)-\left(\frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)}\right)\right)}\right)\\ {\sf \overline{N}} &= 33.\overline{3} \frac{gCOD}{m^{3}}\\ & \\ {\sf \overline{B}} &= \frac{\left(\frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)}\right)\left(\left(100 \frac{gCOD}{m^{3}}\right) - \left(33.\overline{3} \frac{gCOD}{m^{3}}\right)\right)}{\left(\frac{1}{\left(0.80\right)}\right)\left(\left(5 \frac{1}{day}\right)\frac{\left(33.\overline{3} \frac{gCOD}{m^{3}}\right)}{\left(20 \frac{gCOD}{m^{3}}\right)+\left(33.\overline{3} \frac{gCOD}{m^{3}}\right)}\right)}\\ {\sf \overline{B}} &= 53.\overline{3} \frac{gCOD}{m^{3}}

**ITERATION 1**

*Calculate Jacobian*

.. math::

J^{(0)}\left(40 \frac{gCOD}{m^{3}},20 \frac{gCOD}{m^{3}}\right) &= \left[\begin{array}{ccc} -3.8194 \frac{1}{day} & \quad , \quad & -4.1667 \frac{1}{day}\\ 0.5556 \frac{1}{day} & \quad , \quad & 0.2083 \frac{1}{day}\\ \end{array}\right]

*Calculate function values*

.. raw:: latex

\\ {\footnotesize [The PDF version of the solutions is cut off on the right edge of the page; please refer to the course website to get the full solution.]}

.. math::

f^{(0)}\left(40 \frac{gCOD}{m^{3}},20 \frac{gCOD}{m^{3}}\right) &= \left[\begin{array}{c} \frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)}\left(100 \frac{gCOD}{m^{3}}\right) - \frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)}\left(40 \frac{gCOD}{m^{3}}\right) - \left(\frac{1}{\left(0.80\right)}\right)\left(\left(5 \frac{1}{day}\right)\frac{\left(40 \frac{gCOD}{m^{3}}\right)}{\left(20 \frac{gCOD}{m^{3}}\right)+\left(40 \frac{gCOD}{m^{3}}\right)}\right)\left(20 \frac{gCOD}{m^{3}}\right) \\ - \frac{\left(5000 \frac{m^{3}}{day}\right)}{\left(1600 m^{3}\right)}\left(20 \frac{gCOD}{m^{3}}\right) + \left(\left(5 \frac{1}{day}\right)\frac{\left(40 \frac{gCOD}{m^{3}}\right)}{\left(20 \frac{gCOD}{m^{3}}\right)+\left(40 \frac{gCOD}{m^{3}}\right)}\right)\left(20 \frac{gCOD}{m^{3}}\right) \\ \end{array}\right]\\ &= \left[\begin{array}{c} 104.1667 \frac{gCOD/m^{3}}{day} \\ 4.1667 \frac{gCOD/m^{3}}{day} \\ \end{array}\right]

*Solve the system* :math:`J\Delta x = -f` (Use MATLAB or Python)

.. math::

\left[\begin{array}{ccc} -3.8194 \frac{1}{day} & \quad , \quad & -4.1667 \frac{1}{day}\\ 0.5556 \frac{1}{day} & \quad , \quad & 0.2083 \frac{1}{day}\\ \end{array}\right] \Delta x &= -\left[\begin{array}{c} 104.1667 \frac{gCOD/m^{3}}{day} \\ 4.1667 \frac{gCOD/m^{3}}{day} \\ \end{array}\right]\\ \Delta x &= \left[\begin{array}{c} -25.7143 \frac{gCOD}{m^{3}} \\ 48.5714 \frac{gCOD}{m^{3}} \\ \end{array}\right]

*calculate new x*

.. math::

x^{(1)} &= x^{(0)} + \Delta x \\ x^{(1)} &= \left[\begin{array}{c} 40 \frac{gCOD}{m^{3}} \\ 20 \frac{gCOD}{m^{3}} \\ \end{array}\right] + \left[\begin{array}{c} -25.7143 \frac{gCOD}{m^{3}} \\ 48.5714 \frac{gCOD}{m^{3}} \\ \end{array}\right]\\ x^{(1)} &= \left[\begin{array}{c} 14.2857 \frac{gCOD}{m^{3}} \\ 68.5714 \frac{gCOD}{m^{3}} \\ \end{array}\right]

*Calculate relative, absolute, and function error norms*

We will assume an :math:`\epsilon_{tol}` of :math:`10^{-8}` and for this solution we will use the 2-norm.

Relative error

.. math::

\frac{\parallel x^{(1)} - x^{(0)} \parallel}{\parallel x^{(1)} \parallel} & < \epsilon_{tol} \; ? \\ \frac{\parallel \Delta x \parallel}{\parallel x^{(1)} \parallel} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{\sum_{i=1}^{n} \left[ \Delta x_{i} \right]^{2}}{\sum_{i=1}^{n} \left[ x_{i}^{(1)} \right]^{2}}} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{(-25.7143)^{2} + (48.5714)^{2}}{(14.2857)^{2} + (68.5714)^{2}}} & < \epsilon_{tol} \; ? \\ 0.7846 & < \epsilon_{tol} \; ? \; \text{No, so keep going!}

Absolute error

.. math::

\frac{\parallel x^{(1)} - x^{(true)} \parallel}{\parallel x^{(true)} \parallel} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{\sum_{i=1}^{n} \left[ x_{i}^{(1)} - x_{i}^{(true)} \right]^{2}}{\sum_{i=1}^{n} \left[ x_{i}^{(true)} \right]^{2}}} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{(14.2857 - 33.\overline{3})^{2} + (68.5714 - 53.\overline{3})^{2}}{(33.\overline{3})^{2} + (53.\overline{3})^{2}}} & < \epsilon_{tol} \; ? \\ 0.3878 &< \epsilon_{tol} \; ? \; \text{No, so keep going!}

Function error

.. math::

\parallel f(x^{(1)}) \parallel & < \epsilon_{tol} \; ? \\ \sqrt{\sum_{i=1}^{n} \left[ f(x^{(1)})_{i} \right]^{2}} & < \epsilon_{tol} \; ? \\ \sqrt{(89.2857)^{2} + (-71.4286)^{2}} & < \epsilon_{tol} \; ? \\ 114.3415 &< \epsilon_{tol} \; ? \; \text{No, so keep going!}

**ITERATION 2**

*Calculate Jacobian*

.. math::


J^{(1)}\left(14.2857 \frac{gCOD}{m^{3}},68.5714 \frac{gCOD}{m^{3}}\right) &= \left[\begin{array}{ccc} -10.4167 \frac{1}{day} & \quad , \quad & -2.6042 \frac{1}{day}\\ 5.8333 \frac{1}{day} & \quad , \quad & -1.0417 \frac{1}{day}\\ \end{array}\right]

*Calculate function values*

.. math::

f^{(1)}\left(14.2857 \frac{gCOD}{m^{3}},68.5714 \frac{gCOD}{m^{3}}\right) &= \left[\begin{array}{c} 89.2857 \frac{gCOD/m^{3}}{day} \\ -71.4286 \frac{gCOD/m^{3}}{day} \\ \end{array}\right]

*Solve the system* :math:`J\Delta x = -f` (Use MATLAB or Python)

.. math::

\left[\begin{array}{ccc} -10.4167 \frac{1}{day} & \quad , \quad & -2.6042 \frac{1}{day}\\ 5.8333 \frac{1}{day} & \quad , \quad & -1.0417 \frac{1}{day}\\ \end{array}\right] \Delta x &= -\left[\begin{array}{c} 89.2857 \frac{gCOD/m^{3}}{day} \\ -71.4286 \frac{gCOD/m^{3}}{day} \\ \end{array}\right]\\ \Delta x &= \left[\begin{array}{c} 10.7143 \frac{gCOD}{m^{3}} \\ -8.5714 \frac{gCOD}{m^{3}} \\ \end{array}\right]

*Calculate new x*

.. math::

x^{(2)} &= x^{(1)} + \Delta x \\ x^{(2)} &= \left[\begin{array}{c} 14.2857 \frac{gCOD}{m^{3}} \\ 68.5714 \frac{gCOD}{m^{3}} \\ \end{array}\right] + \left[\begin{array}{c} 10.7143 \frac{gCOD}{m^{3}} \\ -8.5714 \frac{gCOD}{m^{3}} \\ \end{array}\right]\\ x^{(2)} &= \left[\begin{array}{c} 25.0000 \frac{gCOD}{m^{3}} \\ 60.0000 \frac{gCOD}{m^{3}} \\ \end{array}\right]

*Calculate relative, absolute, and function error norms*

We will assume an :math:`\epsilon_{tol}` of :math:`10^{-8}` and for this solution we will use the 2-norm.

Relative error

.. math::

\frac{\parallel x^{(2)} - x^{(1)} \parallel}{\parallel x^{(2)} \parallel} & < \epsilon_{tol} \; ? \\ \frac{\parallel \Delta x \parallel}{\parallel x^{(2)} \parallel} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{\sum_{i=1}^{n} \left[ \Delta x_{i} \right]^{2}}{\sum_{i=1}^{n} \left[ x_{i}^{(2)} \right]^{2}}} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{(10.7143)^{2} + (-8.5714)^{2}}{(25.0000)^{2} + (60.0000)^{2}}} & < \epsilon_{tol} \; ? \\ 0.2111 &< \epsilon_{tol} \; ? \; \text{No, so keep going!}

Absolute error

.. math::

\frac{\parallel x^{(2)} - x^{(true)} \parallel}{\parallel x^{(true)} \parallel} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{\sum_{i=1}^{n} \left[ x_{i}^{(2)} - x_{i}^{(true)} \right]^{2}}{\sum_{i=1}^{n} \left[ x_{i}^{(true)} \right]^{2}}} & < \epsilon_{tol} \; ? \\ \sqrt{\frac{(25.0000 - 33.\overline{3})^{2} + (60.0000 - 53.\overline{3})^{2}}{(33.\overline{3})^{2} + (53.\overline{3})^{2}}} & < \epsilon_{tol} \; ? \\ 0.1697 &< \epsilon_{tol} \; ? \; \text{No, so keep going!}

Function error

.. math::

\parallel f(x^{(2)}) \parallel & < \epsilon_{tol} \; ? \\ \sqrt{\sum_{i=1}^{n} \left[ f(x^{(2)})_{i} \right]^{2}} & < \epsilon_{tol} \; ? \\ \sqrt{(26.0417)^{2} + (-20.8333)^{2}} & < \epsilon_{tol} \; ? \\ 33.3496 & < \epsilon_{tol} \; ? \; \text{No, so keep going!}

Note that all three errors appear to be decreasing from step to step so we are fairly confident the algorithm is converging and in fact this is true. If one were to continue the iterative process it would converge to within the specified relative tolerance within 7 iterations.

.. raw:: latex

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