MCS 507 --- Individual Computer Project 1 --- Fall 2004
LU Decomposition Solve & Iterative Refinement
for Industrial Chemical Reactor Application:


MATLAB and/or Programming Computation


MATLAB and/or Program with both Outputs are Due Friday 24 September 2004 in Class

Some Comment Corrections: 12 September 2004 .


General Project Objectives: Often in Industry, solutions are developed for small scale test problems using some high level computational system like MATLAB and later solutions for larger production problems are developed using an intermediate level programming language like C or perhaps Fortran so that the final product is more efficient for large scale production problems, i.e., problems that are very large with many computing runs.

Problem Options:

  1. MATLAB Small Scale & Programming Large Scale: Hence, develop a procedure for the following project using MATLAB and then use the MATLAB procedure to develop a larger scale programming language (like in C or other scientific language such as FORTRAN, but MATLAB may also be used for the large scale problem too) procedure.

  2. Entirely in MATLAB: Alternatively, you can do the problem entirely in MATLAB by finding the largest size problem you can run on the system of your choice based upon the initial test problem, but give justification for using the largest size.

  3. Entirely in Ch: Another alternative is to use the Ch Language System which combines the benefits of Unix, C and MATLAB in one self-contained package for MSwindows and other operating systems and is free for academic use. (Developed by Prof. Harry Cheng of UC/Davis; he is a UIC Ph.D. in ME, Prof. K. Gupta was his primary advisor and Hanson was his secondary advisor).


Project Statement: An industrial chemical diffusion reactor has been modeled as a partial differential equations, reduced to a linear algebraic problem, a*Z = b, bZ finite differences and requires a numerical solution in terms of a LU decomposition solution technique since the solution procedure may be performed multiple times for different parameter values that do not affect the

The reactor has a 2-dimensional cross-section that is rectangular (L1×L2 meters) with the following parameter values:


General Instructions:

  1. Small Scale MATLAB Test Case Part: In MATLAB (see help resources below), use LU decomposition function "[L,U,P] = lu(a)" where "P" is the pivot matrix such that "P*a = L*U" approximately, and the forward with backward solve steps like "Y1 = L\P*b" and "Z1 = U\Y1" (backslash alert, see "help \"), to get an approximate solution "Z1" for "Z" to the smaller test problem "a*Z = b". Then, use one iterative refinement with the residual "r1 = b - a*Z1", and another solve for the approximate error solution "e1" for "e" in "L*U*e=P*r1" using the same LU-decomposition. Get the second approximation to the exact solution "Z", "Z2 = Z1 + e1", the infinity-norm of the difference "||Z2 - Z1||", the infinity-norm of the first relative residual "||r1||/||b||", and the infinity-norm of the second relative residual "||r2||/||b||",

  2. Small Scale Output: Hand in your printed MATLAB (*.m file) code and output with explanatory comments for documentation. (Code documentation is very important in Industry.) Report your output in 5 significant digits by print formatting using exponential notation, unless you are tabulating a column of numbers that do not contain very small or very large numbers. Errors and changes should always be printed in e-notation for professional industrial output. In this project the approximate solutions, "Z1" and "Z2", must be printed in e-notation (use fprintf in both MATLAB (or variants in C and Fortran languages).

  3. Large Scale Part:

  4. Plot test, and if possible large scale, results for "Z1", say using MATLAB's surf or mesh 3D plotting functions, on the original rectangular model, i.e., convert the LU solution "Z1 = [Z1(i)]n×1" to rectangular form

  5. Hand In: your printed programming code and truncated output with explanatory comments for documentation together with your MATLAB test.

  6. Printing Output: In order to conserve printing and paper resources, you need only print out the coefficient matrix "a", right hand side vector "b" and solution "Z" for i = 1 to n in steps of "K = (n-1)/(nml-1)", designed to make large scale values comparable to small scale values, and the same for the column index "j" of "a", where "nml = 3*4" is the MATLAB (ml) array size. You will have to fold the printing of the rows of a in half, at least.

  7. Computer Precision: In your code calculations, you must use at least double precision (64 bit; MATLAB is double by default), since float or single is not suitable for "non-toy" problems. Report your output in 5 significant digits by print formatting using exponential notation, unless you are tabulating a column of numbers that do not contain very small or very large numbers. Errors and changes should always be printed in e-notation for professional output. The solution "Z" must be printed in e-notation.


Project Report: Your report needs the following parts:

  1. Cover Page: Put a project title, your name, your affiliation, date and other identifying information on this individual computer project. What you submit must be your own work (this in NOT a group project), else points will be deducted for similar work, i.e. your grade will receive a discount.

  2. Executive Summary: This is about a page briefly summarizing the project and results for a busy boss . This should be in the form of a page outline or itemized list for easy and fast reading. This summary is not the same thing as an abstract. To give the boss a taste of the results, show a graph of the most important results.

  3. Project Description or Introduction: Describe the project in your own words as an introduction to your report, in sufficient depth so that a reader such as yourself would understand it.

  4. Methods: Describe the methods used to solve the problem, giving both advantages and disadvantages in a fair manner. Describe the theory and model behind the computer problem.

  5. Results: Describe the nature of the results and illustrate them with appropriate tables or plots. You can use MATLAB for plotting both your MATLAB and C or equivalent results, importing the latter's output date into MATLAB. Clearly label tables and plot figures. Also give the maximum and minimum of "u" in both small and large scale cases.

  6. Discussion of Results: Discuss the results, including how they can be used elsewhere for different industrial applications.

  7. Acknowledgements: Acknowledge what resources you used in this project, including what versions of MATLAB and C or equivalent that you used, the operating system, the computer or hardware platform, persons consulted (this is important to help avoid deductions for plagerism), and any other resources (references are listed in the next section) used.

  8. Conclusions: List what you have learned from this project and explain why it is significant.

  9. References: Cite all books, scientific papers, websites and other library or web resources that you used. Give author, title, journal name or book publisher or URL where appropriate, and date of publication or web access.

  10. Appendices: Include MATLAB and C or equivalent documented source code and output.


Project Resources:

  1. UIC PCLabs MATLAB available software. Also check out your departmental or laboratory computers such as in EECS and MSCS.

  2. MATLAB Help Page (Hanson).

  3. (NRC): William H. Press et al., Numerical Recipes in C, C++ or F: The Art of Scientific Computing, CambridgeU. Press, ISBN: 0521431085 (See UIC TextBookStore or www.amazon.com price: $57.95 last year; also available for F77 and/or F90; Disk of programs available in Fortran and nonstandard fortran translated C); (See www.amazon.com or similar online bookstores). Also, available at

  4. Google Numerical Recipies or MATLAB. Many students have "googled" online to find NR information and codes. For example, search for "ludcmp.c" or "ludcmp.f".

  5. C/C++ Help Page (Hanson).

  6. Fortran Help Page (Hanson).

  7. Ch Homepage, a combined Unix, C and MATLAB like package, so no additional software, no C compiler, no Unix system or no MATLAB, are needed, even in MSwindows. The primary interface is a Unix-like terminal window in which commands can be issued, including the execution of C programs. The Ch command names are typically longer than MATLAB names.


Web Source: http://www.math.uic.edu/~hanson/mcs507/cp1f04, .html

MCS 507 HomePage: http://www.math.uic.edu/~hanson/mcs507/

Email Comments or Questions (MCS 507 only, please) to hanson A T math uic edu .