# Tutorial 5 - 2010

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

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 $$\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 $$\Delta H_{r}^{0}(T)= -23505$$ cal/mol.

# Question 1 [1]

Show the first 4 iterations of the bisection method to solve for $$T$$, justifying your choice for the initial bracket.

For iteration 2, 3, and 4, please also report these two relative errors:

$\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]

1. Derive a $$g(x) = x$$ function to use in the fixed-point algorithm.
2. Show the first 3 iterations of using the fixed-point algorithm, starting with an initial guess of $$T = 380$$ K.
3. Will the fixed-point method converge for this problem, using your $$g(x)$$?

# Question 3 [1]

1. Write the Newton-Raphson iteration formula that you would use to solve this nonlinear equation.
2. Apply 3 iterations of this formula, also starting from $$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 $$f(x)$$ at the three points, $$[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 $$f(x)$$ as few times as possible. You should report the following 8 outputs in each iteration: $$[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 $$\sqrt{\text{eps}}$$ based on $$\varepsilon_\text{rel,x}^{(k)}$$.