Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial VI



Similar documents
Question 2: How do you solve a matrix equation using the matrix inverse?

Matrices 2. Solving Square Systems of Linear Equations; Inverse Matrices

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

5.5. Solving linear systems by the elimination method

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

Typical Linear Equation Set and Corresponding Matrices

MATHEMATICS FOR ENGINEERS BASIC MATRIX THEORY TUTORIAL 2

1 Determinants and the Solvability of Linear Systems

Solving Systems of Linear Equations Using Matrices

Reduced echelon form: Add the following conditions to conditions 1, 2, and 3 above:

Solving simultaneous equations using the inverse matrix

Linear Equations ! $ & " % & " 11,750 12,750 13,750% MATHEMATICS LEARNING SERVICE Centre for Learning and Professional Development

WEEK #3, Lecture 1: Sparse Systems, MATLAB Graphics

x = + x 2 + x

EXCEL SOLVER TUTORIAL

8.2. Solution by Inverse Matrix Method. Introduction. Prerequisites. Learning Outcomes

Introduction to Matrices for Engineers

A Concrete Introduction. to the Abstract Concepts. of Integers and Algebra using Algebra Tiles

Name: Section Registered In:

1 Introduction to Matrices

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

The Characteristic Polynomial

Notes on Determinant

IEOR 4404 Homework #2 Intro OR: Deterministic Models February 14, 2011 Prof. Jay Sethuraman Page 1 of 5. Homework #2

MatLab - Systems of Differential Equations

Linear Algebra and TI 89

α = u v. In other words, Orthogonal Projection

SOLVING LINEAR SYSTEMS

Introduction to Engineering Analysis - ENGR1100 Course Description and Syllabus Monday / Thursday Sections. Fall '15.

Precalculus REVERSE CORRELATION. Content Expectations for. Precalculus. Michigan CONTENT EXPECTATIONS FOR PRECALCULUS CHAPTER/LESSON TITLES

Linearly Independent Sets and Linearly Dependent Sets

x y The matrix form, the vector form, and the augmented matrix form, respectively, for the system of equations are

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = i.

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

Linear Algebra Notes

Using row reduction to calculate the inverse and the determinant of a square matrix

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Solution of Linear Systems

Lecture 5: Singular Value Decomposition SVD (1)

Introduction to Matrix Algebra

( ) which must be a vector

Eigenvalues and Eigenvectors

Solving Systems of Linear Equations

1.5 SOLUTION SETS OF LINEAR SYSTEMS

Row Echelon Form and Reduced Row Echelon Form

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Lecture 2 Matrix Operations

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

Balancing Chemical Equations

Nonlinear Algebraic Equations Example

Chemical Process Simulation

These axioms must hold for all vectors ū, v, and w in V and all scalars c and d.

Methods for Finding Bases

Solving Simultaneous Equations and Matrices

To give it a definition, an implicit function of x and y is simply any relationship that takes the form:

SOLVING COMPLEX SYSTEMS USING SPREADSHEETS: A MATRIX DECOMPOSITION APPROACH

Tutorial on Using Excel Solver to Analyze Spin-Lattice Relaxation Time Data

Direct Methods for Solving Linear Systems. Matrix Factorization

8. Linear least-squares

CONTROLLABILITY. Chapter Reachable Set and Controllability. Suppose we have a linear system described by the state equation

6. Cholesky factorization

LINEAR ALGEBRA. September 23, 2010

Data Mining: Algorithms and Applications Matrix Math Review

CD-ROM Appendix E: Matlab

State of Stress at Point

Recall that two vectors in are perpendicular or orthogonal provided that their dot

2.3. Finding polynomial functions. An Introduction:

CITY UNIVERSITY LONDON. BEng Degree in Computer Systems Engineering Part II BSc Degree in Computer Systems Engineering Part III PART 2 EXAMINATION

Arithmetic and Algebra of Matrices

Chapter 13 - Chemical Equilibrium

Lecture 10 Solving Material Balances Problems Involving Reactive Processes

Module 2 Introduction to SIMULINK

Degrees of Freedom. This suggests a possible definition: degrees of freedom = # variables - # equations. Definition:

Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

Chapter 6. Linear Programming: The Simplex Method. Introduction to the Big M Method. Section 4 Maximization and Minimization with Problem Constraints

8.1. Cramer s Rule for Solving Simultaneous Linear Equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

How To Understand And Solve A Linear Programming Problem

LINEAR ALGEBRA W W L CHEN

ASEN Structures. MDOF Dynamic Systems. ASEN 3112 Lecture 1 Slide 1

Reciprocal Cost Allocations for Many Support Departments Using Spreadsheet Matrix Functions

The Image Deblurring Problem

Linear Programming. March 14, 2014

DATA ANALYSIS II. Matrix Algorithms

1 Finite difference example: 1D implicit heat equation

3.2 Roulette and Markov Chains

Lecture 5 Principal Minors and the Hessian

Linear Algebra Review. Vectors

Operation Count; Numerical Linear Algebra

Beginner s Matlab Tutorial

What is Linear Programming?

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

Discrete Convolution and the Discrete Fourier Transform

5 Systems of Equations

Nonlinear Programming Methods.S2 Quadratic Programming

1 Sets and Set Notation.

K80TTQ1EP-??,VO.L,XU0H5BY,_71ZVPKOE678_X,N2Y-8HI4VS,,6Z28DDW5N7ADY013

Transcription:

Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial VI Solving a System of Linear Algebraic Equations (last updated 5/19/05 by GGB) Objectives: These tutorials are designed to show the introductory elements for any of the topics discussed. In almost all cases there are other ways to accomplish the same objective, or higher level features that can be added to the commands below. Read Chapter 3 of the textbook to learn more about matrix operations Any text below appearing after the double prompt (>>) can be entered in the Command Window directly or in an m-file. The following topics are covered in this tutorial; Introduction Solving Using Matrix Algebra Commands Solved Problems (guided tour) Proposed Problems Introduction: There are a number of common situations in chemical engineering where systems of linear equations appear. Any system of 'n' linear equations in 'n' unknowns can be expressed in the general form: a 11 x 1 + a 1 x +... + a 1n x n = b 1 a 1 x 1 + a x +... + a n x n = b : : a n1 x 1 + a n x +... + a nn x n = b n where x j is the j th variable, a ij is the constant coefficient on the j th variable in the i th equation, and b j is the constant term. There are at least three ways in Matlab of solving these systems; (1) using matrix algebra commands, (the preferred method) () using the symbolic algebra solve command, (3) using the numerical equation solver, ie. the fsolve command. Only the matrix algebra method will be demonstrated in this tutorial. 1

===================================================================== Method Using Matrix Algebra Commands The system of equations given above can be expressed in the following matrix form. a a...... a a a...... a : : a 1 a...... a 11 1 1n 1 n x1 x : : x n n nn n n In short_hand notation this is listed as [ A]{ x} = { b}. Remember that the rules of matrix multiplication dictate that the '[A]' matrix be consistent with the '{x}' and '{b}' vectors. The first column of 'A' contains the coefficients for x 1. The first row of 'A' and element of 'b' contain the coefficients for the first equation. To determine the variables contained in the column vector '{x}', complete the following steps. (a) Create the coefficient matrix '[A]'. Also remember to include zeroes where an equation doesn't contain a variable. (b) Calculate the determinant of the coefficient matrix to make sure that you have an independent set of equations. If the determinant is zero you have a singular matrix. The meaning of this is that your equations are not independent therefore; you will have to verify each of your equations. You will start learning how to formulate equations to understand different processes when you take ChE-00. The command used in Matlab to calculate the determinant of a matrix is det. See the example given below: = b1 b : : b Calculate the determinant of the matrix 3 1 1 A= 0 1 3 4 Because the determinant is different to zero the inverse matrix of A exists.

(c) (d) Create the right_hand_side column vector '{b}' containing the constant terms from the equation. This must be a column vector, not a row. Calculate the values in the '{x}' vector of unknowns by performing the following matrix 1 operation: { x} = [ A] {} b Where [A] -1 is the inverse matrix of the coefficient matrix A. The command used in Matlab to calculate the inverse of a matrix is inv. See the example given below: This is the inverse matrix of A Therefore, if the {b} vector is given by: { } calculated in Matlab as shown below: 1 b = 0. The solution of the system of LAEs can be 1 3

This must be a column vector This is the operational symbol for the product of matrices (see Tutorial 3) Solution for the system of LAEs The inv command will give you an error message if the matrix that you are trying to calculate the inverse to is singular. See the example given below: Remember: This means that you don t have a set of independent equations 4

SOLVED PROBLEMS 1. The following series of reversible reactions occurs; A <=====> B A <=====> D B <=====> C B <=====> D C <=====> D Assume that the reactions are carried out in a batch reactor at constant temperature and pressure, and that the reactor initially contains only component A at a concentration of 1 mole/liter. Given the first order rate constants for each reaction, determine the equilibrium concentration of each component. Given an example set of rate constants, and applying a mass balance on three of the components and the constraint that the concentration of all four species must sum to one, results in the following system of linear equations. C A + C B + C C + C D = 1 _0.3C A + 0.0C B + 0.05C D = 0 0.1C A _ 0.8C B + 0.1C C + 0.1C D = 0 0.5C B _ 0.11C C + 0.1C D = 0 Write a program in Matlab to calculate the concentration of each of the components in the reactor.. Solution: 1. The first step is to express the system of linear algebraic equations in matrix form: 1 1 1 1 C() 1 03. 00. 0 005. C( ) 01. 08. 01. 01. C() 3 0 05. 011. 01. C( 4) = 1 0 0 0. Follow the tips for solving problems 3. Write a flowchart diagram (see H-). In the space given below draw your flowchart diagram 5

4. Write the code in Matlab. See the solution given below. 5. This is the solution of the problem 6

PROPOSED PROBLEMS The analysis of a reactor used to chlorinate ethane results in the following set of equations: 0.87N1 = N3 13.3N4 = 100 N1 = N3 = 00+ N4 6N = 6N + 500+ 4N + N 1 3 4 5 where N 1 trough N 5 represents the flowrates in moles/hr of ethane fed, chlorine fed, ethane remaining, dichloroethane produced, and hydrogen chloride produced respectively. Is the system of equations linear or nonlinear? Justify your answer. If linear express the system of equations in matrix form and develop a program in Matlab to obtain the solution for the flowrates. 7