Linear Algebra is Your Friend: Least Squares Solutions to Overdetermined Linear Systems

Similar documents
TEACHING NUMERICAL LINEAR ALGEBRA AT THE UNDERGRADUATE LEVEL by Biswa Nath Datta Department of Mathematical Sciences Northern Illinois University

Reactor Design within Excel Enabled by Rigorous Physical Properties and an Advanced Numerical Computation Package

Lecture 6, Sci. Comp. for DPhil Students

Linear Algebra, part 3 QR and SVD

Singular Value Decompsition

Preface to Second Edition... vii. Preface to First Edition...

Lecture 6. Numerical methods. Approximation of functions

Applied Linear Algebra in Geoscience Using MATLAB

Principle of Chemical Process I

Computational Tools to Enhance the Study of Gas Power Cycles in Mechanical Engineering Courses

LINEAR ALGEBRA: NUMERICAL METHODS. Version: August 12,

Statistical Analysis of Engineering Data The Bare Bones Edition. Precision, Bias, Accuracy, Measures of Precision, Propagation of Error

Linear Algebra, part 3. Going back to least squares. Mathematical Models, Analysis and Simulation = 0. a T 1 e. a T n e. Anna-Karin Tornberg

What is "In" and What is "Out" in Engineering Problem Solving

Matrix decompositions

Applied Linear Algebra in Geoscience Using MATLAB

B553 Lecture 5: Matrix Algebra Review

AMS526: Numerical Analysis I (Numerical Linear Algebra)

Stability of the Gram-Schmidt process

Using MATLAB. Linear Algebra

p 1 p 0 (p 1, f(p 1 )) (p 0, f(p 0 )) The geometric construction of p 2 for the se- cant method.

1 Cricket chirps: an example

Special Two-Semester Linear Algebra Course (Fall 2012 and Spring 2013)

The SVD-Fundamental Theorem of Linear Algebra

Linear Algebra Done Wrong. Sergei Treil. Department of Mathematics, Brown University

How cubey is your prism? the No Child Left Behind law has called for teachers to be highly qualified to teach their subjects.

Numerical Methods I Non-Square and Sparse Linear Systems

(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB

Ideal Gas Law Experiment

7. Dimension and Structure.

Orthonormal Transformations and Least Squares

PDE Model Reduction Using SVD

Linear Algebra Massoud Malek

Statistics for Social and Behavioral Sciences

5.1 Least-Squares Line

Roundoff Error. Monday, August 29, 11

LINEAR ALGEBRA KNOWLEDGE SURVEY

Matrix decompositions

Chapter 9: Gaussian Elimination

Some Notes on Least Squares, QR-factorization, SVD and Fitting

HOSTOS COMMUNITY COLLEGE DEPARTMENT OF MATHEMATICS

AMS526: Numerical Analysis I (Numerical Linear Algebra for Computational and Data Sciences)

MATCOM and Selected MATCOM Functions

Linear Algebra Linear Algebra : Matrix decompositions Monday, February 11th Math 365 Week #4

Parallel Singular Value Decomposition. Jiaxing Tan

course overview 18.06: Linear Algebra

be a Householder matrix. Then prove the followings H = I 2 uut Hu = (I 2 uu u T u )u = u 2 uut u

1 Number Systems and Errors 1

Chapter 1 Mathematical Preliminaries and Error Analysis

CITS2401 Computer Analysis & Visualisation

Calculate the mass of L of oxygen gas at 25.0 C and 1.18 atm pressure.

Least squares: the big idea

Numerical Methods. Elena loli Piccolomini. Civil Engeneering. piccolom. Metodi Numerici M p. 1/??

Lecture 9: Numerical Linear Algebra Primer (February 11st)

Numerical Methods in Matrix Computations

Design of de-coupler for an interacting tanks system

An Exploration of Coordinate Metrology

Early Introduction of Design Fundamentals into the Chemical Engineering Curriculum

COMP 558 lecture 18 Nov. 15, 2010

Partial Eigenvalue Assignment in Linear Systems: Existence, Uniqueness and Numerical Solution

Analysis of Performance of Packed Columns

ENGG5781 Matrix Analysis and Computations Lecture 8: QR Decomposition

Linear algebra for MATH2601: Theory

Properties of Matrices and Operations on Matrices

(Refer Slide Time: 2:04)

AM205: Assignment 2. i=1

Applied Linear Algebra in Geoscience Using MATLAB

Summary of Iterative Methods for Non-symmetric Linear Equations That Are Related to the Conjugate Gradient (CG) Method

Ideal Gas Law. Name, Date, Partner Lab Section. Date, Partner and Lab Section

chapter 12 MORE MATRIX ALGEBRA 12.1 Systems of Linear Equations GOALS

Notes on Solving Linear Least-Squares Problems

The Tangent Parabola The AMATYC Review, Vol. 23, No. 1, Fall 2001, pp

Combining Numerical Problem Solving with Access to Physical Property Data a New Paradigm in ChE Education

Lectures on Linear Algebra for IT

CITS2401 Computer Analysis & Visualisation

CHAPTER 1 INTRODUCTION TO NUMERICAL METHOD

Systems of linear equations

Least Squares. Tom Lyche. October 26, Centre of Mathematics for Applications, Department of Informatics, University of Oslo

Calorimetry and Hess s Law Prelab

Enhancing Computer-Based Problem Solving Skills with a Combination of Software Packages

Algorithm 853: an Efficient Algorithm for Solving Rank-Deficient Least Squares Problems

Image Compression Using Singular Value Decomposition

CN - Numerical Computation

Vector and Matrix Norms. Vector and Matrix Norms

Measurements and Data Analysis

RECURSIVE SUBSPACE IDENTIFICATION IN THE LEAST SQUARES FRAMEWORK

A primer on matrices

Numerical Linear Algebra Primer. Ryan Tibshirani Convex Optimization /36-725

MATH 350: Introduction to Computational Mathematics

Hands-on Matrix Algebra Using R

PRE-AP CHEMISTRY Course Syllabus

Linear Algebra. and

AM 205: lecture 8. Last time: Cholesky factorization, QR factorization Today: how to compute the QR factorization, the Singular Value Decomposition

Numerical Linear Algebra

Notes on Eigenvalues, Singular Values and QR

Teaching Assistant: Tracy Bucholz CPE office hours: M, W, F 8:30-9:30am

y = A T x = A T (x r + x c ) = A T x r

σ 11 σ 22 σ pp 0 with p = min(n, m) The σ ii s are the singular values. Notation change σ ii A 1 σ 2

Utah Secondary Mathematics Core Curriculum Precalculus

Linear Least-Squares Data Fitting

Transcription:

Linear Algebra is Your Friend: Least Squares Solutions to Overdetermined Linear Systems R. E. Babcock, Mark E. Arnold Department of Chemical Engineering and Department of Mathematical Sciences Fayetteville, AR Most engineering students are quite familiar with least squares regression analysis of experimental data on Y versus X plots using EXCEL or other similar spreadsheet software programs. They use the reported coefficient of determination, R 2, as a measure of the closeness of fit. Most chemical engineering students, however, are not well versed enough with the concepts of modern day computational techniques for finding the least squares solution or with the application of linear algebra for determining the best solution to overdetermined linear systems of equations. For chemical engineers these systems commonly result from material balance analysis of multicomponent flow through processing equipment. Take the very simple example of a Prism membrane system used in the senior lab course at the Ralph E. Martin Department of Chemical Engineering at the University of Arkansas shown in Figure 1 1. It is used for separating a pressurized air stream into an oxygen rich stream and a nitrogen rich stream. Figure 1 Prism Membrane Separation System

2 Traditional material balance analysis would involve obtaining a unique solution by writing an overall balance and an oxygen component balance over the membrane system: (1)*F = (1)*N p + (1)* N np (eq. 1) (0.21)*F = (Y O2 ) p * N p + (Y O2 ) np * N np (eq. 2) or, alternatively, an overall balance and a nitrogen component balance, (0.79)*F = (Y N2 ) p * N p + (Y N2 ) np * N np (eq. 3) but not all three because the component balances sum to give the overall balance and therefore all three equations are not strictly independent. Furthermore, traditionally the mole fractions, y, of each stream are forced to sum to 1.0. However, when each flow rate is individually determined by flow meters and when each mole fraction is determined individually by sensors (except for the inlet air), the student is faced with obtaining the best solution to the overdetermined system of equations that has uncertainty introduced due to the inaccuracy of instrumentation. Consider the following example data taken during an experiment using the equipment above: F- Total molar flow rate of air through the system as measured by the dry gas meter,1.98 mole/min Inlet air composition certified by the air supplier as 21 mole% O 2 and 79 mole% N 2 N p - Molar flow rate of permeate exit stream as measured by the rotameter, 0.150 mole/min N np -Molar flow rate of the non-permeate exit stream as measured by the rotameter,1.86 mole/min (Y xx ) p Component mole fraction of the permeate stream measured by sensors as 42 mole% O 2 and 60 mole% N 2 where xx represents either O 2 or N 2 (Y xx ) np - Component mole fraction of the non-permeate stream measured by sensors as 19 mole% O 2 and 84 mole % N 2 where xx represents either O 2 or N 2 Thus, an overdetermined system of linear equations is formed, having matrix format represented by the classical Ax=b system of linear equations (eq. 4). The symbol A is an m by n matrix consisting of the coefficients of the N p and N np flow streams in each equation; x is an n-vector representing the molar flow rates variables themselves (F, N p, N np ). The m-vector b represents the total and individual component molar flow rates of material flowing through the system.

3 1 1 1.980 1.980 0.42 0.19. (x) = 0.417 0.416 eq. 4 0.60 0.84 1.652 1.564 A. (x) = b Several items need to be noted with respect to the system of equations represented by equation 4. First, one notes that matrix A, the mole fractions of the permeate and the non-permeate streams do not sum to one due to inaccuracy of the compositional sensors. Secondly, b presents two different column vectors representing two different modeling approaches for determining the total amount of each component, oxygen and nitrogen, flowing through the system. The first column vector in b denotes the total flow of each component by assuming that both permeate and non-permeate stream flow meters are accurate as well as each compositional sensor. The second column vector in b represents the total component flows by assuming the feed dry gas flow meter is accurate and assuming the composition of atmospheric air to be 79% nitrogen and 21% oxygen. Further, note that in this case the only significant difference between these two modeling approaches shows up in the total nitrogen flow. The least squares type problem may be formally defined mathematically by Datta 2 as finding the n-vector x such that the norm of the residual vector, Ax-b 2, is a minimum. This is synonymous to saying the sum of the squares of the individual residuals is a minimum. This technique was first published by A. M. Legendre in 1806 although Carl Friedrich Gauss actually used it in astronomical calculations as early as 1797 3. Solving equations 1 and 2 simultaneously, then equations 1 and 3 simultaneously, followed by simultaneously solving equations 2 and 3, results in differ values of N n and N np. Table 1 presents the resulting flow rates and each respective residual using the first column vector of b. Table 1 Simultaneous Pair-Wise Solutions to Equations 1-3 Equations 1 & 2 Equations 1 & 3 Equations 2 & 3 Measured Values N n 0.177 0.124 0.152 0.150 N np 1.802 1.866 1.858 1.860 Residuals* 0.031 0.018 0.030 0.030 * Ax-b 2 The values of the permeate flow rate varies by up to 42%, while the value of the sum of the residuals varies by up to 72%. Therefore, the question arises as to how to determine the least squares solution to the above overdetermined system of linear equations, i.e. minimize the sum of the residuals to determine the best value of N n and N np. Linear algebra offers a variety of methods for doing this, each one having their individual advantages and disadvantages

4 depending on such factors as computer time (cost), precision required, conditioning of the system of equations, etc. The method used for the simple example of this paper is known as the normal equations solution resulting in the unique least squares solution to the original system of equations provided the matrix, A, has rank of n, which it does. This method involves left multiplying through by A T and then using a fundamental theorem of linear algebra which states that is the unique solution for which we are looking. x = (A T A) -1 A T b (eq. 5) MATLAB is a readily available and a convenient computer language for making such matrix algebraic manipulations 4. The MATLAB output for the example discussed above is shown below: A = 1.0000e+000 1.0000e+000 4.2000e-001 1.9000e-001 6.0000e-001 8.4000e-001 b = 1.9800e+000 4.1700e-001 1.6520e+000 Answers returned by MATLAB for values of x are: N n = 1.2395e-001 N np = 1.8663e+000 with the sum of the residuals = 0.01763 While the least squares solution is nearly the same as solving equations 1 and 3, it does a better job of satisfying all three equations than any of the other solutions obtained by simply solving any 2 of the 3 equations. The least squares solution for the second column of b is N n = 2.7128e-001 N np = 1.6898e+000

5 with the sum of the residuals = 0.03241. And finally, the least squares solution for the 5 different equations is N n = 1.9458e-001 N np = 1.7790e+000 with the sum of the residuals = 0.06288. One might argue the merits of one model over another, for example, the least squares solution for the first column of b satisfies all three equations better than solving equations 2 and 3, but the solution to equations 2 and 3 gives a solution which is closer to the measured values. But in the measured values, the overall balance is violated much more than with the least squares solution. Which is more correct? Is there an experimental error in the measured values or the measured rotameter solution? Which right hand side model is better? Since one can compute a best approximate solution to an overdetermined system, one can include competing and even inconsistent models as components (sets of equations) of the least squares model. So, hence the title linear algebra is your friend. Much more complicated problems exist with much larger matrices which require careful consideration of the method used for the least squares solution. An example of a much larger system of equations would be the modeling of a simple flash vessel calculation that separates a compressed liquid stream comprised of more than 100 components into two lower pressure vapor and liquid streams. The least squares problem always has a unique solution as long as the columns of A are linearly independent. If the columns are dependent, then there are infinitely many solutions. In the case that the columns of A are close to being linearly dependent, sensor inaccuracies (or the computer s rounding errors) can make it difficult or even impossible to compute an accurate solution. In this case one can turn to alternatives to the normal equations approach which are more robust, but more costly in terms of computer time. The normal equations approach to solving an m by n LS problem requires approximately mn 2 +n 3 /3 floating point operations (FLOPS). The standard alternative to this approach, the Householder QR factorization, requires about 2mn 2 2n 3 /3 FLOPS, but solves a wider class of problems. The Modified Gram-Schmidt QR factorization requires about 2mn 2 FLOPS and is as robust as the Householder approach. The Rolls-Royce of LS methods is based on a singular value decomposition (SVD) of A, which requires about 2mn 2 + 11n 3 FLOPS. These techniques are standard fair in software packages like Matlab, SAS, Mathematica, Maple, etc, and do not require any special expertise to use. If the problem is quite large, then memory requirements and/or computer time may allow no choice but the normal equations approach, but otherwise the Householder QR is popular as a good balance of speed and robustness. Every engineer need not be an expert in linear algebra computations but every engineering curriculum should include a fundamental course in linear algebra so that the engineer is aware of its capabilities. This will allow engineers to take advantage of the expertise available when

6 applicable. Again, these calculation techniques are currently in use in software and process simulators readily available for use by the process engineer. However, the engineer needs to have at least a rudimentary knowledge of the principles behind these calculations. 1. CHEG 4332, Lab III Experimentation Manuel, Ralph E. Martin Department of Chemical Engineering, University of Arkansas, Fayetteville, AR 200.1 2. Data, Biswa Nath, Numerical Linear Algebra and Applications, Thomson Custom Publishing, 2003. 3. Leon, Steven J, Linear Algebra with Applications, Prentice Hall, Upper Saddle River, NJ, 5 th Edition, 1998. 4. Moore, Holly, MATLAB for Engineers, Prentice Hall, Upper Saddle River, NJ, 2007. R. E. BABCOCK Dr. Babcock, professor of Chemical Engineering, received his Ph.D. from the University of Oklahoma. He currently teaches thermodynamics, fluid mechanics, and unit operations laboratories at the University of Arkansas MARK E. ARNOLD Dr. Arnold, associate professor and vice-chair of Mathematical Sciences received his Ph.D. from Northern Illinois with a specialty in computational mathematics. He teaches linear algebra and numerical linear algebra at the University of Arkansas and is active in computational research.