# Practice questions

Various practice questions will be posted here as the semester progresses. These questions are from previous exams, assignments and tutorials. No solutions will be posted, so you should validate your answers using any appropriate software.

## Course textbook

Please attempt several of the (chemical) engineering type problems at the end of every section in the official course textbook. Notably:

• Linear equation systems: questions 12.9 to 12.12
• Solving nonlinear equations: question 8.10 to 8.13
• Curve fitting: questions 20.6, 20.10, 20.11, 20.12, 20.15, 20.17, 20.18
• Numerical differentiation and integration: questions 24.6 to 24.13
• ODEs: questions 28.10 to 28.16

## Tutorial 3, 2009

• Convert into decimal representation: (a) $$(10011101)_2$$; (b) $$(0.001101)_2$$
• Convert into binary representation: (a) $$(45.625)_{10}$$; (b) $$(0.1)_{10}$$
• Consider the following system of linear algebraic equations.
• Use Gauss elimination (without pivoting) to solve these equations for $$(x_1,x_2,x_3)$$.
• Validate your solution by comparing it to the one obtained with computer software.

\begin{align*} \left\{\begin{array}{rcl} 2 x_1 -2x_2 +4 x_3 & = & 0 \\ x_1 -3 x_2 + 4x_3 & = & -1 \\ 3x_1 - x_2 +5x_3 &= & 0 \end{array}\right. \end{align*}

## Tutorial 4, 2009

• We have already seen several elimination techniques for linear equation solving. In this question, you are to solve the following linear algebraic equations, using LU decomposition

\begin{align*} \left\{\begin{array}{rcl} 2 x_1 -2x_2 +4 x_3 & = & 0 \\ x_1 -3 x_2 + 4x_3 & = & -1 \\ 3x_1 - x_2 +5x_3 &= & 0 \end{array}\right. \end{align*}

• We have also seen that the LU decomposition technique can be used to calculate matrix inverses. Using the results obtained in the question above, compute the inverse of the following matrix,

\begin{align*} A &= \left[ \begin{array}{rrr} 2 & -2 & 4 \\ 1 & -3 & 4 \\ 3 & -1 & 5 \end{array} \right] \end{align*}

## Tutorial 5, 2009

In addition to elimination methods, we have seen that iterative methods can be used to solve systems of linear equations. In this question, you are to solve the following linear algebraic equations, using (a) the Jacobi method, (b) the Gauss-Seidel method and (c) the relaxed Gauss-Seidel method, with $$\omega=0.5$$.

In each case, start from the initial guess $$x_1^{(0)}=x_2^{(0)}=x_3^{(0)}=0$$ and perform 3 full iterations. Can anything be said regarding the convergence/divergence of these methods for that equation system? \begin{align*} \left\{\begin{array}{rcl} 2 x_1 -2x_2 +4 x_3 & = & 0 \\ x_1 -3 x_2 + 4x_3 & = & -1 \\ 3x_1 - x_2 +5x_3 &= & 0 \end{array}\right. \end{align*}

## Midterm, 2009

Grading: 5 points out of 22, 2 hour exam

Consider a mixing tank fed with two fluids A and B at volumetric flow rates $$F_{\sf A}$$ and $$F_{\sf B}$$ and temperatures $$T_{\sf A}$$ and $$T_{\sf B}$$, respectively. Both fluids have the same constant density $$\rho$$ and specific heat capacity $$C_p$$. The tank has one outlet stream and constant fluid volume $$V$$. Moreover, the fluid in the tank looses heat to the environment at a rate $$q=k(T-T_w)$$, where $$T$$ denotes the current fluid temperature, $$T_w<T$$ is the constant tank wall temperature, and $$k$$ is a constant.

1. Derive a dynamical balance describing the evolution of the liquid temperature in the tank.
2. Can the liquid temperature in the tank at steady state exit be higher than both $$T_A$$ and $$T_B$$? Explain.

Grading: 5 points out of 22, 2 hour exam

Consider the reaction ${\rm P_2I_4} + n\,{\rm P_4} + p\,{\rm H_2O} \longrightarrow 4\,{\rm PH_4I} + q\,{\rm H_3PO_4}$ where $$n, p$$ and $$q$$ denote the stoichiometric coefficients for $$\rm P_4$$, $$\rm H_2O$$ and $$\rm H_3PO_4$$ respectively.

• Derive the equations necessary to solve for $$n, p$$ and $$q$$ by equating atoms of $${\rm P}$$, $${\rm H}$$, and $${\rm O}$$ on the reactant and product sides.
• Use Gauss elimination with partial pivoting to compute the solution. Show clearly all steps.

Grading: 5 points out of 22, 2 hour exam. One mark for each question.

1. A colleague of yours was able to solve a system of nonlinear algebraic equations using the multivariable Newton-Raphson method. You are trying to reproduce his results, using the exact same method, but obtain divergent iterates. Explain what could be the problem.
2. Answer the same question as before, but for the solution of a system of linear algebraic equations using the Gauss-Seidel method (without relaxation).
3. Consider a floating-point number that has a finite decimal representation (i.e., a finite number of digits before and after the decimal point). Is it true that this number will always have a finite binary representation?
4. You are provided a computer program (black-box function) that predicts the temperature, $$T$$, of a reactor at steady-state for a given concentration of reactant, $$c$$. You want to determine for which concentration $$c$$ the reactor temperature is equal to $$T=350\ \rm K$$. Which of the following methods can you use for this purpose?
• The bisection method
• The Newton-Raphson method
• The secant method
5. The following set of instructions is entered in the MATLAB or Python command window. Explain the meaning of these instructions and what the expected result of the last instruction will be. This question does not require any calculations.
MATLAB Python
>> A = [1, 2, 4; 2, 3, 2; 1, 4, -1];
>> b = [1; 0; 0];
>> mldivide(A,b)  % or equivalently: A\b

>>> import numpy as np
>>> A = np.array([[1, 2, 4], [2, 3, 2], [1, 4, -1]])
>>> b = np.array([1, 0, 0])
>>> np.linalg.solve(A, b)


Grading: 5 points out of 22, 2 hour exam.

The heat of reaction for a certain reaction is given by $\Delta H_{r}^{0}(T) = -10000 -0.2 T+1.5\times 10^{-3}T^2+\displaystyle{\frac{2\times10^5}{T}} \quad [\rm cal\ mol^{-1}]$

You are to calculate the temperature at which $$\Delta H_{r}^{0}(T)=-9.258\ \rm kcal\ mol^{-1}$$ using the Newton-Raphson method. Compute $$T^{(3)}$$ (i.e. perform 3 iterations), starting from $$T^{(0)} = 301.0$$; check the termination criteria at each iteration.

## Final exam, 2009

Grading: 8 points out of 50, 3 hour exam.

Consider the following 3-by-3 matrix: $A = \left(\begin{array}{ccc} x_1^2 & x_1 & 1\\ x_2^2 & x_2 & 1\\ x_3^2 & x_3 & 1\\ \end{array}\right)$

with $$x_1=-1, \,\, x_2=2, \,\, x_3=-3$$.

1. Determine the LU decomposition of $$A$$ without pivoting. Report all the intermediate steps in your paper. Check your results by validating that $$LU=A$$.
2. Calculate the inverse of $$A$$.
3. Determine the condition number of $$A$$ based on the row-sum norm $$\|A\|_\infty$$. What are the implications in terms of accuracy?

## Final exam, 2009

Grading: 8 (3+1+1+1+2) points out of 50, 3 hour exam.

Consider a batch reactor (no inlet or outlet stream), initially filled with a volume $$V$$ of a liquid mixture that consists of two species $$\sf A$$ and $$\sf B$$ at concentrations $$C_{\sf A}^0$$ and $$C_{\sf B}^0$$, respectively. The following reactions take place in the reactor:

${\sf A} + {\sf B}\ \mathop{\rightleftharpoons}_{k_{1,b}}^{k_{1,f}}\ 2{\sf C}, \qquad\qquad {\sf C}\ \mathop{\longrightarrow}^{k_2}\ 2{\sf D} + {\sf E}$

The concentrations and molecular weights of the reactants and products are denoted by $$C_{\sf A}, C_{\sf B}, C_{\sf C}, C_{\sf D}, C_{\sf E}$$ and $$MW_{\sf A}, MW_{\sf B}, MW_{\sf C}, MW_{\sf D}, MW_{\sf E}$$, respectively. Both the forward and the backward reactions in the first reaction are of second order with respect to the reactants, $$r_{1,f}=k_{1,f} C_{\sf A} C_{\sf B}$$, and $$r_{1,b}=k_{1,b} C_{\sf C}^2$$, while the second reaction is of first order, $$r_{2} = k_2 C_{\sf C}$$.

1. Determine the dynamic equations describing the evolution of the concentrations $$C_{\sf A}(t), C_{\sf C}(t)$$, and $$C_{\sf D}(t)$$ in the tank.
2. Using total mass conservation, derive an algebraic equation relating all five species concentrations $$C_{\sf A}(t), C_{\sf B}(t), C_{\sf C}(t), C_{\sf D}(t), C_{\sf E}(t)$$ with the initial concentrations $$C_{\sf A}^0$$, $$C_{\sf B}^0$$.
3. Determine an algebraic equation between the concentrations $$C_{\sf A}(t), C_{\sf B}(t)$$ and the initial concentrations $$C_{\sf A}^0$$, $$C_{\sf B}^0$$. Hint: Use the fact that 1 mol of A is reacting with 1 mol of B.
4. Determine an algebraic equation between the concentrations $$C_{\sf D}(t)$$ and $$C_{\sf E}(t)$$. Hint: Use the fact that reaction 2 produces 2 mol of D for 1 mol of E.
5. Calculate the steady-state concentration values of A, B, C, D and E for the data given:
• $$MW_{\sf A} = 60$$ g/mol
• $$MW_{\sf B} = 88$$ g/mol
• $$MW_{\sf C} = 74$$ g/mol
• $$MW_{\sf D} = 18$$ g/mol
• $$MW_{\sf E} = 38$$ g/mol
• $$C_{\sf A}^0 = 1$$ mol/L
• $$C_{\sf B}^0 = 2$$ mol/L

## Midterm test 1, 2000, 50 minutes

1. 15 marks
• In solving the equation $$f(x)=0$$ in a single variable $$x$$, how many steps of the bisection method are necessary to guarantee that the width of the original interval that brackets the solution is reduced by a factor of 1000?
• Do one iteration of the bisection method for the equation $$f(x) = e^{1.5x} - 5x^2 = 0$$ starting with the interval $$x_L = 1.5$$ and $$x_U=2.5$$.
• Do one iteration of the equation above with the Newton-Raphson method, starting at $$x=3$$.
2. 10 marks
• Describe the procedure of pivoting in the Gaussian elimination method of solving a set of linear equations. Why is it done?
• What is meant by ill-conditioning of a set of linear equations. How would you test for it with computer software?
3. 10 marks
The following set of equations can be solved using Newton's method. Write the set of equations that need to solved at each step of Newton's method to produce the next estimate of the solution, given the current estimate:

\begin{align}f_1(x) = 2e^{-x_2} + e^{-3x_3} - e^{-x_1} = 0\\f_2(x) = 3x_1 + 5x_2 +2x_3 = 0\\f_3(x) = 1.5x_2^2 - x_3^2 = 0 \end{align}

## From Midterm test 2, 2000, 50 minutes, 40 marks

15 marks

• Given the data below from a polynomial of unknown degree, what is the highest degree of polynomial that would fit that many points exactly?
• Use finite differences to determine whether these data come from a lower degree polynomial. Write down the polynomial that exactly fits the data, using the Newton form of polynomial interpolation.
• Estimate the first derivative of $$y$$ with respect to $$x$$ in the table at $$x=2$$, using the central difference formula with $$h=2$$.
$$x$$ $$y$$
0 8
1 7
2 18
3 47
4 100
5 183

## Midterm test, 1982, 50 minutes, 50 marks

15 marks

Suppose you have fitted a set of data $$x_i, y_i$$ for $$i=1, 2, \ldots, n$$ to a cubic spline, $$y(x)$$ with $$x$$ as the independent variable.

• How could you use the spline to evaluate $\int_{a}^{b}{y(x) dx}$ where $$x_1 \leq a < b \leq x_n$$
• How could you use the spline to evaluate $$dy/dx$$ at any $$x$$ in the given range?

## Midterm test, 1976, 2 hours, 100 marks

Question 1, 20 marks

Choose one of the following numerical methods. Describe the algorithm and discuss its advantages and disadvantages. Show an example of a problem to which you would apply the method.

• Interpolation and its use for integral formulas
• Runge-Kutta fourth-order methods

Question 4, 15 marks

Use a Runge-Kutta 2nd order method to integrate over one interval the following pair of differential equations from $$t=0$$ with $$h=0.1$$ \begin{align} \frac{dy_1}{dt} &= 2y_1^2 + \frac{1}{y_2} \\ \frac{dy_1}{dt} &= y_1y_2 \end{align}

Question 5, 10 marks

Given a set of values for a function $$y = f(x)$$ from integer values of $$x$$, estimate $$dy/dx$$ at $$x=3$$:

$$x$$ $$f(x)$$
1 1
2 32
3 243
4 1024
5 3125

## Final exam, 1980, 3 hours, 100 marks

Question 4, 20 marks

The following vapour pressure data for pure ammonia are from the Chemical Engineers' Handbook, 3rd edition, p 149:

Vapour pressure, $$P^0$$ [atm] Temperature $$T$$, [$$^\circ$$C]
1 -33.6
2 -18.7
5 4.7
10 25.7

Describe the steps you would take using these data to estimate the enthalpy of vapourization of ammonia at 0$$^\circ$$C from the Clausius-Claperyon equation: $\frac{d \text{ln}P^0}{dT} = \frac{\Delta H_\text{vap}}{RT^2}$