Numerical methods are essential tools in chemical engineering for solving equations that arise from modeling physical and chemical processes, especially when analytical solutions are difficult or impossible to obtain. In Kenya's chemical industry, engineers frequently encounter nonlinear equations and differential equations describing reaction kinetics, heat transfer, and mass transfer. This chapter covers key numerical techniques, Simpson’s rule for integration, the Newton-Raphson method for root finding, and the Runge-Kutta method for solving differential equations, providing the mathematical foundation and practical application examples relevant to chemical engineering problems.
Simpson’s rule is a numerical integration technique used to approximate the definite integral of a function when an analytical integral is difficult to evaluate. It is particularly useful in chemical engineering for calculating areas under curves such as concentration profiles or reaction rate graphs. The rule approximates the integral by fitting parabolas through segments of the function.
The formula for Simpson’s rule over an interval \([a, b]\) divided into an even number \(n\) of subintervals of equal width \(h = \frac{b, a}{n}\) is:
$$ \int_a^b f(x) \, dx \approx \frac{h}{3} [ f(x_0) + 4 \sum_{i=1,\, \text{odd}}^{n-1} f(x_i) + 2 \sum_{i=2,\, \text{even}}^{n-2} f(x_i) + f(x_n) ] $$
Example 1: Approximate the integral of the reaction rate \(r(x) = 2x^2 + 3x + 1\) from \(x=0\) to \(x=4\) using Simpson’s rule with \(n=4\).
Given: \(a=0\), \(b=4\), \(n=4\), \(h=\frac{4-0}{4}=1\)
Calculate function values:
\(x_0=0, f(x_0) = 2(0)^2 + 3(0) + 1 = 1\)
\(x_1=1, f(x_1) = 2(1)^2 + 3(1) + 1 = 2 + 3 + 1 = 6\)
\(x_2=2, f(x_2) = 2(2)^2 + 3(2) + 1 = 8 + 6 + 1 = 15\)
\(x_3=3, f(x_3) = 2(3)^2 + 3(3) + 1 = 18 + 9 + 1 = 28\)
\(x_4=4, f(x_4) = 2(4)^2 + 3(4) + 1 = 32 + 12 + 1 = 45\)
Apply Simpson’s formula:
$$ I \approx \frac{1}{3} [f(x_0) + 4(f(x_1) + f(x_3)) + 2 f(x_2) + f(x_4)] $$
$$ I \approx \frac{1}{3} [1 + 4(6 + 28) + 2(15) + 45] $$
$$ I \approx \frac{1}{3} [1 + 4(34) + 30 + 45] = \frac{1}{3} [1 + 136 + 30 + 45] = \frac{1}{3} [212] $$
$$ I \approx 70.67 $$
Answer: 70.67 units
Example 2: Calculate the volume of liquid in a tank where cross-sectional area \(A(x)\) varies with height \(x\) as \(A(x) = 5 + 2x^2\) from \(x=0\) to \(x=3\) using Simpson’s rule with \(n=6\).
Given: \(a=0\), \(b=3\), \(n=6\), \(h = \frac{3-0}{6} = 0.5\)
Calculate \(A(x_i)\) at points:
\(x_0=0, A_0=5 + 2(0)^2 = 5\)
\(x_1=0.5, A_1=5 + 2(0.5)^2 = 5 + 2(0.25) = 5.5\)
\(x_2=1.0, A_2=5 + 2(1)^2 = 5 + 2 = 7\)
\(x_3=1.5, A_3=5 + 2(1.5)^2 = 5 + 2(2.25) = 9.5\)
\(x_4=2.0, A_4=5 + 2(2)^2 = 5 + 8 = 13\)
\(x_5=2.5, A_5=5 + 2(2.5)^2 = 5 + 2(6.25) = 17.5\)
\(x_6=3.0, A_6=5 + 2(3)^2 = 5 + 18 = 23\)
Apply Simpson’s rule:
$$ V \approx \frac{h}{3} [ A_0 + 4 (A_1 + A_3 + A_5) + 2 (A_2 + A_4) + A_6 ] $$
$$ V \approx \frac{0.5}{3} [5 + 4(5.5 + 9.5 + 17.5) + 2(7 + 13) + 23] $$
Calculate sums:
\(4(5.5 + 9.5 + 17.5) = 4(32.5) = 130\)
\(2(7 + 13) = 2(20) = 40\)
Sum all terms:
\(5 + 130 + 40 + 23 = 198\)
$$ V \approx \frac{0.5}{3} \times 198 = \frac{0.5 \times 198}{3} = \frac{99}{3} = 33 $$
Answer: 33 cubic units
Example 3: Estimate the heat transfer rate by integrating the temperature distribution \(T(x) = 100 e^{-0.2x}\) from \(x=0\) to \(x=5\) with \(n=10\).
Given: \(a=0\), \(b=5\), \(n=10\), \(h = \frac{5-0}{10} = 0.5\)
Calculate \(T(x_i) = 100 e^{-0.2 x_i}\) at \(x_i = 0, 0.5, 1.0, \ldots, 5.0\):
\(T_0 = 100 e^{0} = 100\)
\(T_1 = 100 e^{-0.1} = 100 \times 0.9048 = 90.48\)
\(T_2 = 100 e^{-0.2} = 100 \times 0.8187 = 81.87\)
\(T_3 = 100 e^{-0.3} = 100 \times 0.7408 = 74.08\)
\(T_4 = 100 e^{-0.4} = 100 \times 0.6703 = 67.03\)
\(T_5 = 100 e^{-0.5} = 100 \times 0.6065 = 60.65\)
\(T_6 = 100 e^{-0.6} = 100 \times 0.5488 = 54.88\)
\(T_7 = 100 e^{-0.7} = 100 \times 0.4966 = 49.66\)
\(T_8 = 100 e^{-0.8} = 100 \times 0.4493 = 44.93\)
\(T_9 = 100 e^{-0.9} = 100 \times 0.4066 = 40.66\)
\(T_{10} = 100 e^{-1.0} = 100 \times 0.3679 = 36.79\)
Apply Simpson’s rule:
$$ I \approx \frac{h}{3} [ T_0 + 4 \sum_{\text{odd}} T_i + 2 \sum_{\text{even,} i \neq 0,n} T_i + T_n ] $$
Calculate sums:
Sum odd indices \(T_1 + T_3 + T_5 + T_7 + T_9 = 90.48 + 74.08 + 60.65 + 49.66 + 40.66 = 315.53\)
Sum even indices (excluding \(T_0, T_{10}\)) \(T_2 + T_4 + T_6 + T_8 = 81.87 + 67.03 + 54.88 + 44.93 = 248.71\)
Calculate integral:
$$ I \approx \frac{0.5}{3} [100 + 4(315.53) + 2(248.71) + 36.79] $$
$$ I \approx \frac{0.5}{3} [100 + 1262.12 + 497.42 + 36.79] = \frac{0.5}{3} [1896.33] $$
$$ I \approx \frac{0.5 \times 1896.33}{3} = \frac{948.16}{3} = 316.05 $$
Answer: 316.05 units
Use Simpson’s rule with \(n=4\) to estimate the integral of \(f(x) = 3x^3 + 2x + 1\) from \(x=1\) to \(x=5\). (5 marks)
Calculate the volume of liquid in a tank where the cross-sectional area is \(A(x) = 4 + x^2\), from \(x=0\) to \(x=4\), using Simpson’s rule with \(n=8\). (6 marks)
Estimate the integral of \(f(x) = 50 e^{-0.1x}\) from \(x=0\) to \(x=6\) using Simpson’s rule with \(n=6\). (5 marks)
The Newton-Raphson method is an iterative numerical technique used to find roots of nonlinear equations, which frequently arise in chemical engineering problems such as determining equilibrium concentrations or reaction extents. The method uses the function and its derivative to approximate the root with high accuracy.
The iterative formula is:
$$ x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} $$
where \(x_n\) is the current approximation, and \(f'(x_n)\) is the derivative of \(f(x)\) at \(x_n\).
Example 1: Find the root of \(f(x) = x^2 - 4 = 0\) starting with initial guess \(x_0 = 3\).
Given: \(f(x) = x^2 - 4\), \(f'(x) = 2x\), \(x_0 = 3\)
Iteration 1:
$$ x_1 = x_0 - \frac{f(x_0)}{f'(x_0)} = 3 - \frac{3^2 - 4}{2 \times 3} = 3 - \frac{9 - 4}{6} = 3 - \frac{5}{6} = 2.1667 $$
Iteration 2:
$$ x_2 = 2.1667 - \frac{(2.1667)^2 - 4}{2 \times 2.1667} = 2.1667 - \frac{4.6945 - 4}{4.3334} = 2.1667 - \frac{0.6945}{4.3334} = 2.1667 - 0.1603 = 2.0064 $$
Iteration 3:
$$ x_3 = 2.0064 - \frac{(2.0064)^2 - 4}{2 \times 2.0064} = 2.0064 - \frac{4.0257 - 4}{4.0128} = 2.0064 - \frac{0.0257}{4.0128} = 2.0064 - 0.0064 = 2.0000 $$
Answer: Root approximately \(x = 2.0000\)
Example 2: Determine the root of \(f(x) = x^3 - 2x - 5 = 0\) with initial guess \(x_0=2\).
Given: \(f(x) = x^3 - 2x - 5\), \(f'(x) = 3x^2 - 2\), \(x_0=2\)
Iteration 1:
$$ x_1 = 2 - \frac{2^3 - 2 \times 2 - 5}{3 \times 2^2 - 2} = 2 - \frac{8 - 4 - 5}{12 - 2} = 2 - \frac{-1}{10} = 2 + 0.1 = 2.1 $$
Iteration 2:
$$ x_2 = 2.1 - \frac{(2.1)^3 - 2(2.1) - 5}{3(2.1)^2 - 2} = 2.1 - \frac{9.261 - 4.2 - 5}{13.23 - 2} = 2.1 - \frac{0.061}{11.23} = 2.1 - 0.0054 = 2.0946 $$
Iteration 3:
$$ x_3 = 2.0946 - \frac{(2.0946)^3 - 2(2.0946) - 5}{3(2.0946)^2 - 2} = 2.0946 - \frac{9.189 - 4.189 - 5}{13.16 - 2} = 2.0946 - \frac{0.0001}{11.16} = 2.0946 - 0.000009 = 2.0946 $$
Answer: Root approximately \(x = 2.0946\)
Example 3: Solve \(f(x) = e^{-x} - x = 0\) with initial guess \(x_0 = 0.5\).
Given: \(f(x) = e^{-x} - x\), \(f'(x) = -e^{-x} - 1\), \(x_0 = 0.5\)
Iteration 1:
$$ x_1 = 0.5 - \frac{e^{-0.5} - 0.5}{-e^{-0.5} - 1} = 0.5 - \frac{0.6065 - 0.5}{-0.6065 - 1} = 0.5 - \frac{0.1065}{-1.6065} = 0.5 + 0.0663 = 0.5663 $$
Iteration 2:
$$ x_2 = 0.5663 - \frac{e^{-0.5663} - 0.5663}{-e^{-0.5663} - 1} = 0.5663 - \frac{0.5677 - 0.5663}{-0.5677 - 1} = 0.5663 - \frac{0.0014}{-1.5677} = 0.5663 + 0.0009 = 0.5672 $$
Iteration 3:
$$ x_3 = 0.5672 - \frac{e^{-0.5672} - 0.5672}{-e^{-0.5672} - 1} = 0.5672 - \frac{0.5671 - 0.5672}{-0.5671 - 1} = 0.5672 - \frac{-0.0001}{-1.5671} = 0.5672 - 0.00006 = 0.5671 $$
Answer: Root approximately \(x = 0.5671\)
Use the Newton-Raphson method to find the root of \(f(x) = x^3 - 7 = 0\) with initial guess \(x_0=2\), up to 3 iterations. (6 marks)
Determine the root of \(f(x) = \ln(x) + x^2 - 4 = 0\) starting with \(x_0=1.5\). Perform 3 iterations. (6 marks)
Find the root of \(f(x) = \sin x - 0.5 = 0\) near \(x=0.5\) using Newton-Raphson for 3 iterations. (5 marks)
The Runge-Kutta methods are powerful numerical techniques for solving ordinary differential equations (ODEs) that arise in chemical engineering, such as reaction kinetics and heat transfer rate laws. The fourth-order Runge-Kutta method provides a good balance between accuracy and computational effort.
For the first-order ODE \( \frac{dy}{dx} = f(x,y) \) with initial condition \( y(x_0) = y_0 \), the fourth-order Runge-Kutta estimate for \(y\) at \(x_{n+1} = x_n + h\) is:
$$ k_1 = h f(x_n, y_n) $$
$$ k_2 = h f(x_n + \frac{h}{2}, y_n + \frac{k_1}{2}) $$
$$ k_3 = h f(x_n + \frac{h}{2}, y_n + \frac{k_2}{2}) $$
$$ k_4 = h f(x_n + h, y_n + k_3) $$
$$ y_{n+1} = y_n + \frac{1}{6} (k_1 + 2k_2 + 2k_3 + k_4) $$
Example 1: Solve \( \frac{dy}{dx} = x + y \) with initial condition \( y(0) = 1 \) to find \( y \) at \( x = 0.1 \) using step size \( h = 0.1 \).
Given: \(f(x,y) = x + y\), \(x_0=0\), \(y_0=1\), \(h=0.1\)
Calculate:
$$ k_1 = 0.1 \times f(0, 1) = 0.1 \times (0 + 1) = 0.1 $$
$$ k_2 = 0.1 \times f(0 + \frac{0.1}{2}, 1 + \frac{0.1}{2}) = 0.1 \times f(0.05, 1.05) = 0.1 \times (0.05 + 1.05) = 0.11 $$
$$ k_3 = 0.1 \times f(0.05, 1 + \frac{0.11}{2}) = 0.1 \times f(0.05, 1.055) = 0.1 \times (0.05 + 1.055) = 0.1105 $$
$$ k_4 = 0.1 \times f(0.1, 1 + 0.1105) = 0.1 \times (0.1 + 1.1105) = 0.12105 $$
Calculate \(y_1\):
$$ y_1 = 1 + \frac{1}{6} (0.1 + 2 \times 0.11 + 2 \times 0.1105 + 0.12105) = 1 + \frac{1}{6} (0.1 + 0.22 + 0.221 + 0.12105) $$
$$ = 1 + \frac{1}{6} (0.66205) = 1 + 0.11034 = 1.11034 $$
Answer: \( y(0.1) \approx 1.1103 \)
Example 2: Solve \( \frac{dy}{dx} = y, x^2 + 1 \), \( y(0) = 0.5 \), find \( y \) at \( x=0.2 \) using two steps of \( h=0.1 \).
Step 1: \(x_0=0, y_0=0.5\)
Calculate \(k_1, k_2, k_3, k_4\):
$$ k_1 = 0.1 \times (0.5 - 0^2 + 1) = 0.1 \times 1.5 = 0.15 $$
$$ k_2 = 0.1 \times (0.05 - 0^2 + 1 + \frac{0.15}{2}) = 0.1 \times (0.05 - 0 + 1 + 0.075) = 0.1 \times 1.125 = 0.1125 $$
$$ k_3 = 0.1 \times (0.05 - 0^2 + 1 + \frac{0.1125}{2}) = 0.1 \times (0.05 + 1 + 0.05625) = 0.1 \times 1.10625 = 0.110625 $$
$$ k_4 = 0.1 \times (0.1 - 0^2 + 1 + 0.110625) = 0.1 \times (0.1 + 1 + 0.110625) = 0.1 \times 1.210625 = 0.1210625 $$
Calculate \(y_1\):
$$ y_1 = 0.5 + \frac{1}{6} (0.15 + 2 \times 0.1125 + 2 \times 0.110625 + 0.1210625) = 0.5 + \frac{1}{6} (0.15 + 0.225 + 0.22125 + 0.1210625) $$
$$ = 0.5 + \frac{1}{6} (0.7173125) = 0.5 + 0.119552 = 0.61955 $$
Step 2: \(x_1=0.1, y_1=0.61955\)
Calculate next \(k\) values:
$$ k_1 = 0.1 \times (0.61955 - (0.1)^2 + 1) = 0.1 \times (0.61955 - 0.01 + 1) = 0.1 \times 1.60955 = 0.160955 $$
$$ k_2 = 0.1 \times (0.15 - (0.15)^2 + 1 + \frac{0.160955}{2}) \text{ but } x = 0.15, y = 0.61955 + \frac{0.160955}{2} = 0.69953 $$
Calculating carefully:
\(x = 0.1 + \frac{0.1}{2} = 0.15\)
\(y = 0.61955 + \frac{0.160955}{2} = 0.61955 + 0.08048 = 0.70003\)
Evaluate \(f(0.15, 0.70003) = 0.70003 - (0.15)^2 + 1 = 0.70003 - 0.0225 + 1 = 1.67753\)
Then,
$$ k_2 = 0.1 \times 1.67753 = 0.167753 $$
Similarly,
$$ k_3 = 0.1 \times f(0.15, 0.61955 + \frac{0.167753}{2}) = 0.1 \times f(0.15, 0.70343) $$
Calculate \(f(0.15, 0.70343) = 0.70343 - 0.0225 + 1 = 1.68093\)
$$ k_3 = 0.1 \times 1.68093 = 0.168093 $$
$$ k_4 = 0.1 \times f(0.2, 0.61955 + 0.168093) = 0.1 \times f(0.2, 0.78764) $$
Calculate \(f(0.2, 0.78764) = 0.78764 - 0.04 + 1 = 1.74764\)
$$ k_4 = 0.1 \times 1.74764 = 0.174764 $$
Calculate \(y_2\):
$$ y_2 = 0.61955 + \frac{1}{6} (0.160955 + 2 \times 0.167753 + 2 \times 0.168093 + 0.174764) $$
$$ = 0.61955 + \frac{1}{6} (0.160955 + 0.335506 + 0.336186 + 0.174764) = 0.61955 + \frac{1}{6} (1.00741) $$
$$ = 0.61955 + 0.1679 = 0.78745 $$
Answer: \( y(0.2) \approx 0.7875 \)
Example 3: For the differential equation \( \frac{dy}{dx} = y \cos x \), with \( y(0) = 1 \), find \( y(0.2) \) using one step of the Runge-Kutta method with \( h=0.2 \).
Calculate:
$$ k_1 = 0.2 \times (1 \times \cos 0) = 0.2 \times 1 = 0.2 $$
$$ k_2 = 0.2 \times ( (1 + \frac{0.2}{2}) \times \cos(0 + \frac{0.2}{2}) ) = 0.2 \times (1.1 \times \cos 0.1) = 0.2 \times (1.1 \times 0.9950) = 0.2 \times 1.0945 = 0.2189 $$
$$ k_3 = 0.2 \times ( (1 + \frac{0.2189}{2}) \times \cos(0 + \frac{0.2}{2}) ) = 0.2 \times (1.1094 \times 0.9950) = 0.2 \times 1.104 = 0.2208 $$
$$ k_4 = 0.2 \times ( (1 + 0.2208) \times \cos(0.2) ) = 0.2 \times (1.2208 \times 0.9801) = 0.2 \times 1.196 = 0.2392 $$
Calculate \(y_1\):
$$ y_1 = 1 + \frac{1}{6} (0.2 + 2 \times 0.2189 + 2 \times 0.2208 + 0.2392) = 1 + \frac{1}{6} (0.2 + 0.4378 + 0.4416 + 0.2392) $$
$$ = 1 + \frac{1}{6} (1.3186) = 1 + 0.2198 = 1.2198 $$
Answer: \( y(0.2) \approx 1.2198 \)
Use the fourth-order Runge-Kutta method with \(h=0.1\) to estimate \(y(0.1)\) for \( \frac{dy}{dx} = x, y \), \(y(0)=2\). (6 marks)
Solve \( \frac{dy}{dx} = x y + x^3 \), \( y(0) = 1 \), find \( y(0.2) \) using two steps of \(h=0.1\) with Runge-Kutta. (8 marks)
For \( \frac{dy}{dx} = y \sin x \), \( y(0) = 1 \), estimate \( y(0.3) \) using three steps of Runge-Kutta with \(h=0.1\). (8 marks)
This chapter focused on key numerical methods used in engineering mathematics, starting with Simpson’s rule, which provides an efficient technique for approximating definite integrals by using parabolic arcs. The Newton-Raphson method was then explored as a powerful iterative approach for finding roots of nonlinear equations, offering rapid convergence under suitable conditions. Finally, the Runge-Kutta methods were introduced as advanced procedures for solving ordinary differential equations, enabling accurate step-by-step integration of complex dynamic systems. Each method was presented with clear mathematical formulations and progressively challenging examples to demonstrate practical application in engineering problems. Mastery of these numerical techniques enhances the ability to solve equations and integrals that are otherwise difficult or impossible to handle analytically. The chapter emphasized stepwise calculations and interpretation of results, preparing students to apply these methods confidently in real-world civil engineering contexts.
Use Simpson’s 1/3 rule to estimate the integral of the function \(f(x) = 2x^3 - 5x + 1\) over the interval \([1, 3]\) using 4 equal sub-intervals. (2 marks)
Apply the Newton-Raphson method to find the root of the equation \(x^3 - 7x^2 + 14x - 6 = 0\) starting from an initial guess of \(x_0 = 2\). Perform two iterations. (3 marks)
Use the 4th order Runge-Kutta method to approximate \(y(0.2)\) for the differential equation \(\frac{dy}{dx} = x + y\) with initial condition \(y(0) = 1\), using a step size \(h = 0.1\). (3 marks)
Calculate the volume of liquid in a chemical reactor tank using Simpson’s rule given the following cross-sectional area measurements (in m²) at equal intervals of depth (m): Depth (0, 1, 2, 3, 4), Area (0, 1.5, 3.0, 4.5, 6.0). (3 marks)
For the equation \(e^{-x} = x\), use Newton-Raphson method starting at \(x_0 = 0.5\) and perform three iterations to approximate the root. (4 marks)
Use the 2nd order Runge-Kutta method (Heun’s method) to estimate \(y(0.3)\) for the differential equation \(\frac{dy}{dx} = y, x^2 + 1\) with initial condition \(y(0) = 0.5\), using step size \(h = 0.1\). (3 marks)
A chemical concentration \(C(t)\) in a tank changes according to \(\frac{dC}{dt} = -0.5 C + 2\), with initial concentration \(C(0) = 4\). Use the 4th order Runge-Kutta method with step size \(h=0.2\) to estimate \(C(0.2)\). (4 marks)
Use Simpson’s 1/3 rule with 6 equal intervals to approximate the integral of \(f(x) = \sin(x)\) from \(x = 0\) to \(x = \pi\). (3 marks)
Apply Newton-Raphson method to find the root of \(x^3 - 2x - 5 = 0\) starting at \(x_0 = 2\). Perform four iterations. (4 marks)
Use the 4th order Runge-Kutta method to solve \(\frac{dy}{dx} = xy + x^3\) with initial condition \(y(0) = 1\) to find \(y(0.1)\) using step size \(h=0.1\). (4 marks)
1. Simpson’s 1/3 rule to estimate \(\int_1^3 (2x^3 - 5x + 1) dx\) with 4 sub-intervals
Given: \(a=1\), \(b=3\), \(n=4\) (even), \(h = \frac{3-1}{4} = 0.5\)
Points:
\(x_0=1\), \(x_1=1.5\), \(x_2=2.0\), \(x_3=2.5\), \(x_4=3.0\)
Calculate \(f(x_i)\):
\[
f(1) = 2(1)^3 - 5(1) + 1 = 2 - 5 + 1 = -2
\]
\[
f(1.5) = 2(1.5)^3 - 5(1.5) +1 = 2(3.375) - 7.5 +1 = 6.75 - 7.5 +1 = 0.25
\]
\[
f(2) = 2(8) - 10 +1 = 16 - 10 +1 = 7
\]
\[
f(2.5) = 2(15.625) - 12.5 +1 = 31.25 -12.5 +1 = 19.75
\]
\[
f(3) = 2(27) - 15 +1 = 54 -15 +1 = 40
\]
Apply Simpson’s 1/3 rule formula:
\[ I = \frac{h}{3} [ f(x_0) + 4 \sum_{\text{odd } i} f(x_i) + 2 \sum_{\text{even } i} f(x_i) + f(x_n) ] \]
\[ I = \frac{0.5}{3} [ -2 + 4(0.25 + 19.75) + 2(7) + 40 ] \]
Calculate sums:
\[
4(0.25 + 19.75) = 4 \times 20 = 80
\]
\[
2(7) = 14
\]
So,
\[ I = \frac{0.5}{3} [ -2 + 80 + 14 + 40 ] = \frac{0.5}{3} (132) = \frac{0.5 \times 132}{3} = \frac{66}{3} = 22 \]
Final answer: \(\boxed{22}\)
2. Newton-Raphson for \(x^3 - 7x^2 + 14x - 6 = 0\), \(x_0=2\), 2 iterations
Function: \(f(x) = x^3 - 7x^2 + 14x - 6\)
Derivative: \(f'(x) = 3x^2 - 14x + 14\)
Iteration formula:
\[ x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} \]
Iteration 1:
Calculate \(f(2)\):
\[ 2^3 - 7(2)^2 + 14(2) - 6 = 8 - 28 + 28 - 6 = 2 \]
Calculate \(f'(2)\):
\[ 3(4) - 14(2) + 14 = 12 - 28 + 14 = -2 \]
Calculate \(x_1\):
\[ x_1 = 2 - \frac{2}{-2} = 2 + 1 = 3 \]
Iteration 2:
Calculate \(f(3)\):
\[ 27 - 7(9) + 42 - 6 = 27 - 63 + 42 - 6 = 0 \]
Calculate \(f'(3)\):
\[ 3(9) - 14(3) + 14 = 27 - 42 + 14 = -1 \]
Calculate \(x_2\):
\[ x_2 = 3 - \frac{0}{-1} = 3 \]
Final answer after 2 iterations: \(\boxed{3}\)
3. 4th order Runge-Kutta for \(\frac{dy}{dx} = x + y\), \(y(0)=1\), find \(y(0.2)\), \(h=0.1\)
Step 1: From \(x_0=0\), \(y_0=1\), calculate \(y_1\) at \(x_1=0.1\)
\[
k_1 = h f(x_0, y_0) = 0.1 (0 + 1) = 0.1
\]
\[
k_2 = 0.1 ( x_0 + \frac{h}{2}, y_0 + \frac{k_1}{2} ) = 0.1 (0.05 + 1.05) = 0.1 \times 1.1 = 0.11
\]
\[
k_3 = 0.1 ( 0.05, 1 + \frac{0.11}{2} ) = 0.1 (0.05 + 1.055) = 0.1 \times 1.105 = 0.1105
\]
\[
k_4 = 0.1 (0.1 + 1 + 0.1105) = 0.1 (1.21) = 0.121
\]
Calculate \(y_1\):
\[
y_1 = y_0 + \frac{1}{6} (k_1 + 2k_2 + 2k_3 + k_4) = 1 + \frac{1}{6} (0.1 + 2(0.11) + 2(0.1105) + 0.121)
\]
\[
= 1 + \frac{1}{6} (0.1 + 0.22 + 0.221 + 0.121) = 1 + \frac{1}{6} (0.662) = 1 + 0.1103 = 1.1103
\]
Step 2: From \(x_1=0.1\), \(y_1=1.1103\), find \(y_2\) at \(x_2=0.2\)
\[
k_1 = 0.1 (0.1 + 1.1103) = 0.1 \times 1.2103 = 0.12103
\]
\[
k_2 = 0.1 (0.15 + 1.1103 + \frac{0.12103}{2}) = 0.1 (0.15 + 1.1103 + 0.06052) = 0.1 \times 1.32082 = 0.13208
\]
\[
k_3 = 0.1 (0.15 + 1.1103 + \frac{0.13208}{2}) = 0.1 (0.15 + 1.1103 + 0.06604) = 0.1 \times 1.32634 = 0.13263
\]
\[
k_4 = 0.1 (0.2 + 1.1103 + 0.13263) = 0.1 \times 1.44293 = 0.14429
\]
Calculate \(y_2\):
\[
y_2 = 1.1103 + \frac{1}{6} (0.12103 + 2(0.13208) + 2(0.13263) + 0.14429)
\]
\[
= 1.1103 + \frac{1}{6} (0.12103 + 0.26416 + 0.26526 + 0.14429) = 1.1103 + \frac{1}{6} (0.79474) = 1.1103 + 0.13246 = 1.24276
\]
Final answer: \(\boxed{y(0.2) \approx 1.243}\)
4. Volume of liquid in tank using Simpson’s rule
Depths (m): \(0,1,2,3,4\)
Areas (m²): \(0, 1.5, 3.0, 4.5, 6.0\)
\(n=4\), \(h=1\)
Simpson’s 1/3 rule:
\[
V = \frac{h}{3} [A_0 + 4(A_1 + A_3) + 2(A_2) + A_4]
\]
\[
= \frac{1}{3} [0 + 4(1.5 + 4.5) + 2(3.0) + 6.0] = \frac{1}{3} [0 + 4(6) + 6 + 6]
\]
\[
= \frac{1}{3} [0 + 24 + 6 + 6] = \frac{1}{3} (36) = 12
\]
Final answer: \(\boxed{12 \text{ m}^3}\)
5. Newton-Raphson for \(e^{-x} = x\), rearranged as \(f(x) = e^{-x} - x = 0\), \(x_0=0.5\), 3 iterations
Derivative:
\[ f'(x) = -e^{-x} - 1 \]
Iteration formula:
\[ x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} \]
Iteration 1:
\[
f(0.5) = e^{-0.5} - 0.5 = 0.6065 - 0.5 = 0.1065
\]
\[
f'(0.5) = -0.6065 - 1 = -1.6065
\]
\[
x_1 = 0.5 - \frac{0.1065}{-1.6065} = 0.5 + 0.0663 = 0.5663
\]
Iteration 2:
\[
f(0.5663) = e^{-0.5663} - 0.5663 = 0.5678 - 0.5663 = 0.0015
\]
\[
f'(0.5663) = -0.5678 - 1 = -1.5678
\]
\[
x_2 = 0.5663 - \frac{0.0015}{-1.5678} = 0.5663 + 0.0010 = 0.5673
\]
Iteration 3:
\[
f(0.5673) = e^{-0.5673} - 0.5673 = 0.5672 - 0.5673 = -0.0001
\]
\[
f'(0.5673) = -0.5672 - 1 = -1.5672
\]
\[
x_3 = 0.5673 - \frac{-0.0001}{-1.5672} = 0.5673 - 0.00006 = 0.5672
\]
Final answer: \(\boxed{0.5672}\)
6. 2nd order Runge-Kutta (Heun’s) for \(\frac{dy}{dx} = y, x^2 + 1\), \(y(0)=0.5\), find \(y(0.3)\), \(h=0.1\)
Calculate \(y_1, y_2, y_3\) stepwise.
General formula:
\[
k_1 = h f(x_n, y_n), \quad k_2 = h f(x_n + h, y_n + k_1)
\]
\[
y_{n+1} = y_n + \frac{1}{2}(k_1 + k_2)
\]
Step 1:
\[
x_0=0, y_0=0.5
\]
\[
k_1 = 0.1 (0.5 - 0^2 + 1) = 0.1 (0.5 + 1) = 0.15
\]
\[
k_2 = 0.1 (0.5 - 0.1^2 + 1) = 0.1 (y_0 + k_1 - 0.01 + 1)
\]
Calculate \(y_0 + k_1 = 0.5 + 0.15 = 0.65\)
\[
k_2 = 0.1 (0.65 - 0.01 + 1) = 0.1 (1.64) = 0.164
\]
\[
y_1 = 0.5 + \frac{1}{2}(0.15 + 0.164) = 0.5 + 0.157 = 0.657
\]
Step 2:
\[
x_1 = 0.1, y_1 = 0.657
\]
\[
k_1 = 0.1 (0.657 - 0.1^2 + 1) = 0.1 (0.657 - 0.01 + 1) = 0.1 (1.647) = 0.1647
\]
\[
k_2 = 0.1 (0.657 + 0.1647 - 0.2^2 + 1) = 0.1 (0.8217 - 0.04 + 1) = 0.1 (1.7817) = 0.1782
\]
\[
y_2 = 0.657 + \frac{1}{2} (0.1647 + 0.1782) = 0.657 + 0.1715 = 0.8285
\]
Step 3:
\[
x_2 = 0.2, y_2 = 0.8285
\]
\[
k_1 = 0.1 (0.8285 - 0.2^2 + 1) = 0.1 (0.8285 - 0.04 + 1) = 0.1 (1.7885) = 0.1789
\]
[
k_2 = 0.1 (0.8285 + 0.1789 -
Question 11 (Compulsory - 20 marks)
A chemical manufacturing plant in Mombasa uses a batch reactor where the concentration of a reactant is measured at discrete times. The reaction rate follows the differential equation \(\frac{dy}{dt} = -0.5 y^2\), with initial concentration \(y(0) = 2\) mol/L.
a) Using the Runge-Kutta 4th order method with step size \(h=0.1\), compute the concentration at \(t=0.1\) s. (10 marks)
b) The plant engineer needs to find the time when concentration reaches 1 mol/L by solving \(y(t) = 1\). Using the Newton-Raphson method, find the root of the function \(f(t) = y(t) - 1\) assuming \(y(t)\) is given by the implicit solution \(y = \frac{2}{1 + t}\). Start with \(t_0 = 0.5\) and perform two iterations. (10 marks)
Question 12 (20 marks)
A chemical process involves integrating experimental data for heat flow \(Q\) at times \(t = 0, 2, 4, 6, 8\) minutes measured as \(Q = 10, 18, 24, 30, 40\) kJ/min respectively.
a) Use Simpson’s 1/3 rule to estimate the total heat released over 8 minutes. (10 marks)
b) If the data points had been unevenly spaced, explain why Simpson’s rule might not be suitable and suggest an alternative numerical integration method with reasoning. (10 marks)
Question 13 (20 marks)
A Kenyan chemical company models the concentration of a pollutant in wastewater by solving the nonlinear equation \(x^3 - 2x - 5 = 0\).
a) Use the Newton-Raphson method to find the root starting at \(x_0 = 2\) and perform three iterations. (15 marks)
b) Discuss the importance of choosing a good initial guess in the Newton-Raphson method for chemical engineering problems. (5 marks)
Question 14 (20 marks)
A reaction rate \(r(t)\) is governed by the differential equation \(\frac{dr}{dt} = 4t, r\), with initial condition \(r(0) = 1\).
a) Use the second-order Runge-Kutta method with step size \(h=0.2\) to compute \(r(0.2)\) and \(r(0.4)\). (15 marks)
b) Explain how the Runge-Kutta methods improve the accuracy of numerical solutions in chemical reaction engineering compared to Euler’s method. (5 marks)
Question 11
a) Using RK4 with \(h=0.1\), compute \(k_1 = f(t_0,y_0) = -0.5 \times 2^2 = -2\),
\(k_2 = f(t_0 + h/2, y_0 + k_1 h/2) = -0.5 \times (2 - 0.1)^2 = -1.805\),
\(k_3 = f(t_0 + h/2, y_0 + k_2 h/2) = -0.5 \times (2 - 0.09025)^2 = -1.817\),
\(k_4 = f(t_0 + h, y_0 + k_3 h) = -0.5 \times (2 - 0.1817)^2 = -1.634\),
Then,
\(y_1 = y_0 + \frac{h}{6} (k_1 + 2k_2 + 2k_3 + k_4) = 2 + \frac{0.1}{6}(-2 + 2(-1.805) + 2(-1.817) + (-1.634)) = 1.819\) mol/L.
b) \(f(t) = \frac{2}{1 + t} - 1 = 0\) implies \(t = 1\).
Newton-Raphson iteration:
\(f(t) = \frac{2}{1 + t} - 1\),
\(f'(t) = -\frac{2}{(1+t)^2}\),
Start \(t_0=0.5\),
\(t_1 = t_0 - \frac{f(t_0)}{f'(t_0)} = 0.5 - \frac{\frac{2}{1.5} -1}{-\frac{2}{(1.5)^2}} = 0.5 - \frac{0.333}{-0.889} = 0.5 + 0.374 = 0.874\),
\(t_2 = 0.874 - \frac{\frac{2}{1.874} -1}{-\frac{2}{(1.874)^2}} = 0.874 - \frac{0.067}{-0.57} = 0.874 + 0.118 = 0.992\).
Question 12
a) Using Simpson’s 1/3 rule on intervals of 2 minutes:
\[
\int_0^8 Q dt \approx \frac{2}{3} [10 + 4(18 + 30) + 2(24) + 40] = \frac{2}{3} [10 + 4 \times 48 + 48 + 40] = \frac{2}{3} [10 + 192 + 48 + 40] = \frac{2}{3} \times 290 = 193.33 \text{ kJ}
\]
b) Simpson’s rule requires equally spaced data points; with uneven spacing, accuracy decreases. Trapezoidal rule or adaptive quadrature methods are preferred for uneven intervals.
Question 13
a) \(f(x) = x^3 - 2x - 5\), \(f'(x) = 3x^2 - 2\),
\(x_0=2\),
\(x_1 = 2 - \frac{8 - 4 - 5}{12 - 2} = 2 - \frac{-1}{10} = 2.1\),
\(x_2 = 2.1 - \frac{9.261 - 4.2 - 5}{13.23 - 2} = 2.1 - \frac{0.061}{11.23} = 2.095\),
\(x_3 = 2.095 - \frac{9.182 - 4.19 - 5}{13.17 - 2} = 2.095 - \frac{-0.008}{11.17} = 2.096\).
b) Good initial guess ensures convergence and prevents divergence or convergence to wrong roots, critical in chemical process modelling.
Question 14
a) For \(r(0.2)\), \(h=0.2\),
\(k_1 = f(0,1) = 4 \times 0 - 1 = -1\),
\(k_2 = f(0.2, 1 - 1 \times 0.2) = 4 \times 0.2 - 0.8 = 0\),
\(r(0.2) = 1 + \frac{0.2}{2}(-1 + 0) = 1 - 0.1 = 0.9\),
Similarly for \(r(0.4)\),
\(k_1 = f(0.2, 0.9) = 4 \times 0.2 - 0.9 = -0.1\),
\(k_2 = f(0.4, 0.9 - 0.1 \times 0.2) = 4 \times 0.4 - 0.88 = 0.72\),
\(r(0.4) = 0.9 + \frac{0.2}{2}(-0.1 + 0.72) = 0.9 + 0.062 = 0.962\).
b) Runge-Kutta methods use intermediate slope evaluations improving accuracy and stability compared to Euler’s single slope estimate, important for stiff chemical kinetics.