Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. In class we discussed a problem involving two reversible chemical reactions as an example of a system of nonlinear equations. After simplifying, the
2. In class we discussed a problem involving two reversible chemical reactions as an example of a system of nonlinear equations. After simplifying, the equations can be written as f (C, C) = C + C k(ao 2c - C) (bo C) = 0, g (C, C) = = C + C - k(ao 2c c) (do c) = 0, - where C, C are the equilibrium product concentrations arising from the two reactions, k, k2 are the equilibrium reaction constants, and ao, bo, do are the initial concentrations of the reactants. Let ao = 20 mole/liter, bo = do = 10 mole/liter, k 1.63 10-4, k = 3.27 10-. The Matlab code on the back of this sheet applies Newton's method to solve for C, C. The code takes six steps starting from initial guess c = C2 = 0.5 mole/liter and it prints the results in a table with the following format. column 1: n (step index) column 2: C column 3: C column 4: f(c, C) column 5: g(C, C) = Your assignment is to run the code and present the table of results in your writeup. You may put the code into an M-file. In order to run the code, you must fill in the two functions f(C, C), g(C, C) and the Jacobian matrix. % % MTH 422, exercise on Newton's method for solving a nonlinear system % function Newton clear; format long; c1 = 0.5; c2 = 0.5; for n = 1:6 result (n, 1) = n-1; result (n, 2) = c1; result (n, 3) = c2; result (n, 4) result (n,5) = answer = f(c1, c2); g(c1, c2); [c1; c2] jacobian (c1, c2)\[f(c1, c2); g(c1, c2)]; c1 = answer (1); c2 = answer (2); end result % function ffun = f(c1, c2) a0 = 20; b0 = 10; d010; k1 = 1.63e-4; k2= 3.27e-3; ffun = % fill in 1st function % function gfun a0 = 20; bo gfun = % fill in 2nd function % function j = jacobian (c1, c2) a0 = 20; b0 = 10; d0 = 10; k1 = 1.63e-4; k2 = 3.27e-3; j11 % fill in 11 element = j12 % fill in 12 element g(c1, c2) = 10; do 10; k1 = 1.63e-4; k2 = 3.27e-3; j = j21 % fill in 21 element = j22 = % fill in 22 element [j11 j12; j21 j22]; =
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started