DEMO #8 - GAUSSIAN ELIMINATION USING MATHEMATICA. 1. Matrices in Mathematica

Similar documents
MAE140 - Linear Circuits - Fall 13 Midterm, October 31

MAE140 - Linear Circuits - Winter 16 Midterm, February 5

The Fundamental Theorem of Algebra. Objective To use the Fundamental Theorem of Algebra to solve polynomial equations with complex solutions

Introduction to Vapor/Liquid Equilibrium, part 2. Raoult s Law:

Advanced Circuits Topics - Part 1 by Dr. Colton (Fall 2017)

MAE140 - Linear Circuits - Fall 10 Midterm, October 28

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0

Physics 4B. A positive value is obtained, so the current is counterclockwise around the circuit.

Lecture 10 Support Vector Machines II

Formulation of Circuit Equations

Key component in Operational Amplifiers

Selected Student Solutions for Chapter 2

1 Matrix representations of canonical matrices

Transfer Functions. Convenient representation of a linear, dynamic model. A transfer function (TF) relates one input and one output: ( ) system

KIRCHHOFF CURRENT LAW

CinChE Problem-Solving Strategy Chapter 4 Development of a Mathematical Model. formulation. procedure

Electrical Circuits 2.1 INTRODUCTION CHAPTER

Section 3.6 Complex Zeros

C/CS/Phy191 Problem Set 3 Solutions Out: Oct 1, 2008., where ( 00. ), so the overall state of the system is ) ( ( ( ( 00 ± 11 ), Φ ± = 1

Complex Numbers, Signals, and Circuits

Polynomial Regression Models

Inner Product. Euclidean Space. Orthonormal Basis. Orthogonal

SUMMARY OF STOICHIOMETRIC RELATIONS AND MEASURE OF REACTIONS' PROGRESS AND COMPOSITION FOR MULTIPLE REACTIONS

Structure and Drive Paul A. Jensen Copyright July 20, 2003

8.4 COMPLEX VECTOR SPACES AND INNER PRODUCTS

Resource Allocation and Decision Analysis (ECON 8010) Spring 2014 Foundations of Regression Analysis

Pre-Calculus Summer Assignment

Robert Eisberg Second edition CH 09 Multielectron atoms ground states and x-ray excitations

Formulas for the Determinant

Salmon: Lectures on partial differential equations. Consider the general linear, second-order PDE in the form. ,x 2

2.3 Nilpotent endomorphisms

EE 2006 Electric Circuit Analysis Fall September 04, 2014 Lecture 02

The Exact Formulation of the Inverse of the Tridiagonal Matrix for Solving the 1D Poisson Equation with the Finite Difference Method

Econ107 Applied Econometrics Topic 3: Classical Model (Studenmund, Chapter 4)

Physics 5153 Classical Mechanics. D Alembert s Principle and The Lagrangian-1

MAE140 - Linear Circuits - Winter 16 Final, March 16, 2016

ELASTIC WAVE PROPAGATION IN A CONTINUOUS MEDIUM

G = G 1 + G 2 + G 3 G 2 +G 3 G1 G2 G3. Network (a) Network (b) Network (c) Network (d)

PHYSICS - CLUTCH CH 28: INDUCTION AND INDUCTANCE.

Chapter 12. Ordinary Differential Equation Boundary Value (BV) Problems

Kinematics in 2-Dimensions. Projectile Motion

Fundamental loop-current method using virtual voltage sources technique for special cases

LECTURE 9 CANONICAL CORRELATION ANALYSIS

Chapter Newton s Method

Linear Feature Engineering 11

Chapter 6 Electrical Systems and Electromechanical Systems

Finite Differences, Interpolation, and Numerical Differentiation

Sections begin this week. Cancelled Sections: Th Labs begin this week. Attend your only second lab slot this week.

Important Instructions to the Examiners:

U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017

Analytical Chemistry Calibration Curve Handout

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

Chapter 11: Simple Linear Regression and Correlation

1 Derivation of Rate Equations from Single-Cell Conductance (Hodgkin-Huxley-like) Equations

Lecture 3. Ax x i a i. i i

The optimal delay of the second test is therefore approximately 210 hours earlier than =2.

Foundations of Arithmetic

β0 + β1xi. You are interested in estimating the unknown parameters β

Homework Notes Week 7

e i is a random error

Poisson brackets and canonical transformations

Linear Approximation with Regularization and Moving Least Squares

Numerical Solution of Ordinary Differential Equations

EE 2006 Electric Circuit Analysis Spring January 23, 2015 Lecture 02

NUMERICAL DIFFERENTIATION

p 1 c 2 + p 2 c 2 + p 3 c p m c 2

x yi In chapter 14, we want to perform inference (i.e. calculate confidence intervals and perform tests of significance) in this setting.

APPENDIX 2 FITTING A STRAIGHT LINE TO OBSERVATIONS

Finite Difference Method

Chapter 13: Multiple Regression

Indeterminate pin-jointed frames (trusses)

UNIVERSITY OF UTAH ELECTRICAL & COMPUTER ENGINEERING DEPARTMENT. 10k. 3mH. 10k. Only one current in the branch:

PHYSICS - CLUTCH 1E CH 28: INDUCTION AND INDUCTANCE.

Physics 1202: Lecture 11 Today s Agenda

FE REVIEW OPERATIONAL AMPLIFIERS (OP-AMPS)( ) 8/25/2010

Physics 114 Exam 2 Fall 2014 Solutions. Name:

Rockefeller College University at Albany

SIMPLE LINEAR REGRESSION

36.1 Why is it important to be able to find roots to systems of equations? Up to this point, we have discussed how to find the solution to

EEE 241: Linear Systems

Supplemental document

DO NOT DO HOMEWORK UNTIL IT IS ASSIGNED. THE ASSIGNMENTS MAY CHANGE UNTIL ANNOUNCED.

Expected Value and Variance

DC Circuits. Crossing the emf in this direction +ΔV

e - c o m p a n i o n

CHEMICAL REACTIONS AND DIFFUSION

An introduction to least-squares fitting

Nodal analysis of finite square resistive grids and the teaching effectiveness of students projects

6.01: Introduction to EECS I Lecture 7 March 15, 2011

= = = (a) Use the MATLAB command rref to solve the system. (b) Let A be the coefficient matrix and B be the right-hand side of the system.

Module 2. Random Processes. Version 2 ECE IIT, Kharagpur

Negative Binomial Regression

Prof. Dr. I. Nasser Phys 630, T Aug-15 One_dimensional_Ising_Model

% & 5.3 PRACTICAL APPLICATIONS. Given system, (49) , determine the Boolean Function, , in such a way that we always have expression: " Y1 = Y2

College of Computer & Information Science Fall 2009 Northeastern University 20 October 2009

9 Derivation of Rate Equations from Single-Cell Conductance (Hodgkin-Huxley-like) Equations

INDUCTANCE. RC Cicuits vs LR Circuits

PART 8. Partial Differential Equations PDEs

Introduction to circuit analysis. Classification of Materials

CHAPTER 4. Vector Spaces

Transcription:

demo8.nb 1 DEMO #8 - GAUSSIAN ELIMINATION USING MATHEMATICA Obectves: - defne matrces n Mathematca - format the output of matrces - appl lnear algebra to solve a real problem - Use Mathematca to perform Gauss-Jordan elmnaton on a matrx Bran Knowlton ChE 50B, Chemcal Engneerng Department, UC Santa Barbara created: 1/7/98 revsed: 1/7/98 revsed b G. Fredrckson for Eng 5A: 10/27/98 1. Matrces n Mathematca In Mathematca, matrces are called Lsts. A Lst s ust a collecton of numbers, separated b commas, and surrounded b curl braces { }. For example, the followng defnes a 1x matrx. u = 8 1, 2, < 81, 2, < You can also use varables n matrces. v = 8x,, < 8x,, < The elements of a Lst don't have to be numbers or varables; the can also be other lsts. For example, a 2x5 matrx can be thought as a 2x1 Lst, where both elements are 1x5 Lsts. Therefore, to specf a 2x5 matrx n Mathematca, specf a two element Lst, where each element s a fve element Lst. Ths tpe of Lst s also referred to as a nested Lst, snce the fve element Lsts resde are 'nested' n another Lst. A = 8 8a11, a12, a1, a14, b1<, 8a21, a22, a2, a24, b2< < 88a11, a12, a1, a14, b1<, 8a21, a22, a2, a24, b2<< The matrx A mght be an augmented matrx derved from a par of lnear equatons n 4 unknowns, a 11 x 1 + a 12 x 2 + a 1 x + a 14 x 4 = b 1 a 21 x 1 + a 22 x 2 + a 2 x + a 24 x 4 = b 2

demo8.nb 2 where a are coeffcents multplng the unknowns x. The matrces u and v are called one-dmensonal matrces, where A s a two-dmensonal matrx. You can also specf three or hgher dmensonal matrces n Mathematca b further nestng of Lsts, and although we wll not use these n Eng 5A, the are useful mathematcal structures n varous branches of phscs and engneerng. 2. Eas-To-Read Matrx Output The format that Mathematca uses for matrx output s a lttle dffcult to read. Mathematca provdes a functon, MatrxForm, that produces more readable output. MatrxForm@AD a11 a12 a1 a14 b1 J a21 a22 a2 a24 b2 N. Applng Lnear Algebra to a Real Problem In Fgure 1 s a crcut dagram, representng a collecton of tpcal household applances, connected (perhaps unsafel) to a sngle wall outlet. The power that each applance uses s lsted n the fgure, along wth the voltage provded b the outlet. The problem s to predct the amount of current that s requred to run all the applances at once. Ths nformaton can be mportant, snce f too much current s drawn from the outlet, a fuse wll fal and ou wll lose to power to all applances. Fgure 1: Crcut Dagram of Common Household Applances In order to fnd the current passng through the outlet, we need to fnd the current runnng through each applance and the voltage at varous places n the crcut. The frst step n analng ths crcut s to fnd the resstance of each applance. Usng the nformaton suppled b the manufacturer, the resstance for each applance can be determned. Fgure 2 shows the resstance of each applance, and also the remanng unknown currents and voltages.

demo8.nb Fgure 2: Applance Resstances and Labelng Notaton of Unknowns To fnd the unknowns, we use two phscal laws to wrte down lnear equatons descrbng the behavor of ths crcut. Frst, at each pont where the crcut branches or ons (ponts A or C), we emplo a "balancng equaton" of currents. Because current s ust the movement of electrons, the total current enterng an gven pont must equal the total current flowng out. Usng the notaton n Fgure 2, we can wrte the followng two (redundant) equatons. I 1 = I 2 + I I 2 + I = I 1 Equatons can be wrtten usng Ohm's Law, whch descrbes how the electrc potental drops when current flows through a resstor. Ohm's Law sas that the voltage drop across a resstor s proportonal to the current flowng through the resstor, where the constant of proportonalt s the resstance. As an equaton, Ohm's Law can be wrtten as, V = IR Applng ths law to each of the applances n Fgure 2, we can wrte fve more equatons, 120 - V 1 = 12 I 1 V 1 - V 2 = 9 I V 2 - V = 60 I V 1 - V = (2/) I 2 V - 0 = (2/) I 1 In total, we have seven equatons n sx unknowns. Wrtten n a more standard form, the equatons look lke the followng. I 1 - I 2 - I = 0 - I 1 + I 2 + I = 0 12 I 1 + V 1 = 120-9 I + V 1 - V 2 = 0-60 I + V 2 - V = 0 - (2/) I 2 + V 1 - V = 0

demo8.nb 4 - (2/) I 1 + V = 0 NOTE: We have chosen here to nclude the redundant equaton. In man applcatons, the fact that two equatons are redundant wll not be so obvous. Also, ou wll see that ncludng a redundant equaton wll not affect the soluton to the problem (see below). 4. Usng Mathematca To Perform Gauss-Jordan Elmnaton Usng Mathematca, we can wrte the equatons nto an augmented matrx: A = 8 8 1, 1, 1, 0, 0, 0, 0<, 8 1, 1, 1, 0, 0, 0, 0<, 812, 0, 0, 1, 0, 0, 120<, 8 0, 0, 9, 1, 1, 0, 0<, 8 0, 0, 60, 0, 1, 1, 0<, 8 0, 2, 0, 1, 0, 1, 0<, 8 2, 0, 0, 0, 0, 1, 0< <; MatrxForm@AD k 1 1 1 0 0 0 0 1 1 1 0 0 0 0 12 0 0 1 0 0 120 0 0 9 1 1 0 0 0 0 60 0 1 1 0 0 2 0 1 0 1 0 2 0 0 0 0 1 0 { To perform Gauss-Jordan Elmnaton on ths augmented matrx, we can call the alread prepared Mathematca functon RowReduce, whch performs Gauss-Jordan elmnaton, producng a matrx n reduced row-echelon form. B = RowReduce@AD; MatrxForm@BD 1 0 0 0 0 0 102510 0 1 0 0 0 0 9960 2880 0 0 1 0 0 0 2156160 0 0 0 1 0 0 210240 0 0 0 0 1 0 0 0 0 0 0 1 109440 k 0 0 0 0 0 0 0 {

demo8.nb 5 N@ MatrxForm@BDD k The fnal answer s: 1. 0 0 0 0 0.6266 0 1. 0 0 0 0.506 0 0 1. 0 0 0 0.102059 0 0 0 1. 0 0 76.4081 0 0 0 0 1. 0 75.4896 0 0 0 0 0 1. 8.7484 0 0 0 0 0 0 0 I 1 =.6; I 2 =.51; I = 0.102; V 1 = 76.408; V 2 = 75.490; V = 8.748; The total amperage requred to run all the applances at once s I 1 or.6 Amperes. { NOTE: The matrx B, the reduced matrx, has a row of eros as the last row. Ths row s the result of the redundant equaton that we ncluded n our sstem of equatons. An equaton that s not ndependant of the others wll show up as a row of eros, and can be neglected. Appendx 1: An Even Better Wa of Formattng Matrces The use of the MatrxForm functon s a rather cumbersome wa to format matrx output, snce ou must call the functon ever tme ou output a matrx. However, there s a wa ou can tell Mathematca to alwas prnt Lsts n matrx form. The followng command, when evaluated, wll cause Mathematca, b default, to use the MatrxForm functon for output of Lsts. $Post := If@MatrxQ@#1D, MatrxForm@#1D, #1D& Tpcall, ths command would come at the begnnng of the notebook. In order to restore the orgnal formattng, smpl clear the varable $Post. See the followng example for a demonstraton.

demo8.nb 6 Clear@$PostD A $Post := If@MatrxQ@#1D, MatrxForm@#1D, #1D& A 981, 1, 1, 0, 0, 0, 0<, 8 1, 1, 1, 0, 0, 0, 0<, 812, 0, 0, 1, 0, 0, 120<, 80, 0, 9, 1, 1, 0, 0<, 80, 0, 60, 0, 1, 1, 0<, 90, 2, 0, 1, 0, 1, 0=, 9 2, 0, 0, 0, 0, 1, 0== k 1 1 1 0 0 0 0 1 1 1 0 0 0 0 12 0 0 1 0 0 120 0 0 9 1 1 0 0 0 0 60 0 1 1 0 0 2 0 1 0 1 0 2 0 0 0 0 1 0 {