1 Electrical mesh circuits Systems of simultaneous equations Solving using Gauss Elimination Simple C program to count letters Using gnuplot to see results.

Slides:



Advertisements
Similar presentations
MAT 105 FALL 2008 Graphs of Linear Functions
Advertisements

4.3 Matrix Approach to Solving Linear Systems 1 Linear systems were solved using substitution and elimination in the two previous section. This section.
Chapter 4 Systems of Linear Equations; Matrices Section 2 Systems of Linear Equations and Augmented Matrics.
Unit 3, Day 7-8 Kirchhoff’s Junction Rules Calculation of Circuit Currents using Kirchhoff’s Rules Circuit Analysis Approach.
Lecture 81 Loop (Mesh) Analysis (3.2) Prof. Phillips February 17, 2003.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
Physics 1402: Lecture 11 Today’s Agenda Announcements: –Lectures posted on: –HW assignments, solutions.
Lecture 261 Nodal Analysis. Lecture 262 Example: A Summing Circuit The output voltage V of this circuit is proportional to the sum of the two input currents.
ECE201 Lect-91 Nodal Analysis (3.1) Dr. Holbert February 22, 2006.
Systematic Circuit Analysis Nodal Analysis Chapter 4 Section 1.
TRIVIA Click for Question What kind of matrix contains the coefficients and constants of a system of linear equations? An augmented matrix Click for:
Chapter 1 Systems of Linear Equations
Chapter 8 Methods of Analysis. 2 Constant Current Sources Maintains same current in branch of circuit –Doesn’t matter how components are connected external.
LINEAR EQUATIONS IN TWO VARIABLES. System of equations or simultaneous equations – System of equations or simultaneous equations – A pair of linear.
Gauss-Jordan Matrix Elimination Brought to you by Tutorial Services – The Math Center.
Chapter 20: Circuits Current and EMF Ohm’s Law and Resistance
Matrices Write and Augmented Matrix of a system of Linear Equations Write the system from the augmented matrix Solve Systems of Linear Equations using.
Introduction Information in science, business, and mathematics is often organized into rows and columns to form rectangular arrays called “matrices” (plural.
Linear Algebra – Linear Equations
Chapter 28A - Direct Current Circuits
© 2005 Baylor University Slide 1 Fundamentals of Engineering Analysis EGR 1302 Unit 1, Lecture F Approximate Running Time - 24 minutes Distance Learning.
Section 8.1/8.2 Matrix Solutions to Linear Systems Inconsistent and Dependent Systems.
~Moving Charge Put to Use
Sect 8.1 Systems of Linear Equations A system of linear equations is where all the equations in a system are linear ( variables raised to the first power).
Pre-Calculus Lesson 7-3 Solving Systems of Equations Using Gaussian Elimination.
MATH 250 Linear Equations and Matrices
 Lecture #9: 1.Linear Equations: y=mx +b 2.Solution System: N.S., U.S., I.S. 3.Augmented Matrix 4.Solving a System of Linear Equations  Today: 1.Echelon.
Alex Kearns Richard Kerr Rocio Rodriguez.  An electric circuit is a collection of electrical devices connected by conductors, usually wires, to a power.
A.Abhari CPS1251 Multidimensional Arrays Multidimensional array is the array with two or more dimensions. For example: char box [3] [3] defines a two-dimensional.
Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices.
METHODS OF CIRCUIT ANALYSIS
Series Circuits EE 2010: Fundamentals of Electric Circuits Mujahed AlDhaifallah.
1. Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Solving Systems of Linear Equations in Three Variables 4 1.Determine.
Fundamentals of Electric Circuits
Copyright © 2011 Pearson Education, Inc. Solving Linear Systems Using Matrices Section 6.1 Matrices and Determinants.
Matrices and Systems of Linear Equations
Linear Equation System Pertemuan 4 Matakuliah: S0262-Analisis Numerik Tahun: 2010.
Algebra II Honors Problem of the Day Homework page eoo The following system has been solved and there are infinite solutions in the form of (
Chapter 1 Linear Algebra S 2 Systems of Linear Equations.
10.3 Systems of Linear Equations: Matrices. A matrix is defined as a rectangular array of numbers, Column 1Column 2 Column jColumn n Row 1 Row 2 Row 3.
Matrices and Systems of Equations
Meeting 19 System of Linear Equations. Linear Equations A solution of a linear equation in n variables is a sequence of n real numbers s 1, s 2,..., s.
Slide Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley A set of equations is called a system of equations. The solution.
1 Section 5.3 Linear Systems of Equations. 2 THREE EQUATIONS WITH THREE VARIABLES Consider the linear system of three equations below with three unknowns.
Chapter 1 Systems of Linear Equations Linear Algebra.
RECOGNIZING INCONSISTENT LINEAR SYSTEMS. What is an Inconsistent Linear System?  An inconsistent linear system is a system of equations that has no solutions.
Multiply one equation, then add
1 ECE 221 Electric Circuit Analysis I Chapter 6 Cramer’s Rule Herbert G. Mayer, PSU Status 11/14/2014 For use at Changchun University of Technology CCUT.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Chapter 5: Matrices and Determinants Section 5.5: Augmented Matrix Solutions.
Multivariable linear systems.  The following system is said to be in row-echelon form, which means that it has a “stair-step” pattern with leading coefficients.
College Algebra Chapter 6 Matrices and Determinants and Applications
Multivariable Linear Systems and Row Operations
Section 6.1 Systems of Linear Equations
Ch. 7 – Matrices and Systems of Equations
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Systems of linear equations
12-2: Matrices.
Chapter 1 Prerequisites for Calculus Section 1.1 Linear Functions.
Chapter 8: Lesson 8.1 Matrices & Systems of Equations
Phys102 Lecture 12 Kirchhoff’s Rules
Chapter 4 Systems of Linear Equations; Matrices
Simultaneous Equations
Matrix Solutions to Linear Systems
Simultaneous Equations
Chapter 1: Linear Equations in Linear Algebra
Simultaneous Equations
Chapter 4 Systems of Linear Equations; Matrices
Section 8.1 – Systems of Linear Equations
Matrices are identified by their size.
Presentation transcript:

1 Electrical mesh circuits Systems of simultaneous equations Solving using Gauss Elimination Simple C program to count letters Using gnuplot to see results CSE Lecture 35 – Gauss Elimination & Circuits, and more

2 Electrical mesh circuits Basically a mesh circuit is one including both series and parallel paths Example shown below: Given all voltages and resistances Solve for the 3 unknown currents V1V1 V2V2 R4R4 R5R5 R3R3 R2R2 R1R1 I1I I2I2 I3I3

3 Electrical mesh circuits Sum of voltages within each circuit is zero, so … We have 3 linear equations with 3 unknowns 0 = -V 1 + i 1 R 1 + (i 1 -i 2 )R 2 0 = (i 2 -i 1 )R 2 + i 2 R 3 + (i 2 -i 3 )R 4 0 = (i 3 -i 2 )R 2 + i 3 R 5 + V 2 V1V1 V2V2 R4R4 R5R5 R3R3 R2R2 R1R1 i1i i2i2 i3i3

4 Electrical mesh circuits These 3 linear equations 0 = -V 1 + i 1 R 1 + (i 1 -i 2 )R 2 0 = (i 2 -i 1 )R 2 + i 2 R 3 + (i 2 -i 3 )R 4 0 = (i 3 -i 2 )R 2 + i 3 R 5 + V 2 Can be rewritten as ( R 1 +R 2 )i 1 + R 2 i 2 = V 1 -R 2 i 1 + ( R 1 +R 2 +R 3 )i 2 – R 4 i 3 = 0 -R 4 i 2 + ( R 4 +R 5 )i 3 = -V 2

5 A brief aside: Matrix form of linear system Any 3 linearly independent equations … a 1 x + b 1 y + c 1 z = d 1 a 2 x + b 2 y + c 2 z = d 2 a 3 x + b 3 y + c 3 z = d 3 Can be placed in matrix form … a 1 b 1 c 1 x = d 1 a 2 b 2 c 2 y = d 2 a 3 b 3 c 3 z = d 3

6 Augmented matrix The same system in augmented matrix form looks like this … a 1 b 1 c 1 d 1 a 2 b 2 c 2 d 2 a 3 b 3 c 3 d 3

7 Gauss Elimination By replacing selected rows in the matrix with linear (scaled) combinations of that and other rows, the leading coefficients can be reduced to 0 in this reduced row echelon pattern … a b c u 0 d e v 0 0 f w

8 Gauss Elimination The values of x, y and z can be computed from this matrix using a “back substitution” method Solving first for z, then y and finally x a b c u x = (u – by – cz)/a 0 d e v y = (v – ez)/d 0 0 f wz = w/f

9 Electrical mesh circuits The mesh equations stored in an augmented Matrix are … (R 1 +R 2 ) R 2 0 V 1 -R 2 (R 1 +R 2 +R 3 ) –R R 4 (R 4 +R 5 ) -V 2

10 Eliminating leading coefficients void eliminate(double a[][N+1], int n, int rc) { // add appropriate multiples of the key row (rc) to each row following // it so the leading coefficient in each following row is eliminated for (int row=rc+1; row<n; row++) { // find ratio of leading coefficients (in column rc) double scale = -a[row][rc]/a[rc][rc]; // add multiple of key row (rc) to this row for (int col=rc; col<=n; col++) a[row][col] += scale*a[rc][col]; } // // the function is called in main() from a loop like this for (int rc = 0; rc < N-1; rc++) { eliminate(a,N,rc); // eliminate leading coeff. in rows below rc }

11 Back substitution // Given this matrix for these equations we find these solutions // | a b c : u | ax + by + cz = u x = (u - cz - by) / a // | 0 d e : v | dy + ez = v y = (v - ez) / d // | 0 0 f : w | fz = w z = w / f // void back_substitute(double a[][N+1], int n, double soln[]) { // solve for last unknown soln[n-1] = a[n-1][n] / a[n-1][n-1]; // work through rows bottom up, solving for unknowns for (int row = n-2; row > =0; row--) { for (int col=n-1; col>row; col--) { // subtract multiples of other unknowns from constant a[row][n] -= a[row][col]*soln[col]; } // divide by leading coefficient soln[row] = a[row][n] / a[row][row]; }

12 Something different: Counting letters & plotting results Use a simple program to count all occurrences of each letter in a file Convert all to lower case and ignore other chars Dump results to screen (or file) Use gnuplot to see results Requires a plot command file or use interactively Data is in file in x y pairs

13 gnuplot Here is a sample data file “data.txt” A sample command to display the data points connected by line segments and wait for a mouse click before closing display plot ‘data.txt’ with lines; pause mouse A sample command to display data with histogram type steps and wait for return key plot ‘data.txt’ with histep; pause -1 “hit ENTER” A sample command to display two data sets and wait 10 seconds before closing display plot ‘dataP.txt’ with histep, ‘dataC.txt’ with histep; pause 10

14 gnuplot Sample command file “plot_lc.cmd” plot ‘lcdata.txt’ with histep; pause mouse Sample use on command line to invoke gnuplot gnuplot plot_lc.cmd Note: this runs gnuplot in batch mode, so it opens and displays data files in response to commands in the command file

15 Something different Counting letters /* FILE: lc.c ** ** Read stdin and count number of occurrences of each letter. ** Case does not matter, and all other characters are skipped. ** single command line option specifies whether output summary ** is printed. List of letter positions and totals is ** always output to stdout */ #include int main(int argc, char *argv[]) { int i, ltrCount[26], ltrTotal; char ch;

16 Something different Counting letters (lc.c) /* FILE: lc.c ** ** Read stdin and count number of occurrences of each letter. ** Case does not matter, and all other characters are skipped. ** single command line option specifies whether output summary ** is printed. List of letter positions and totals is ** always output to stdout */ #include int main(int argc, char *argv[]) { int i, ltrCount[26], ltrTotal; char ch;

17 Counting letters (lc.c) /* initialize counters to zero */ ltrTotal = 0; for (i=0; i<26; i++) ltrCount[i] = 0; /* read input and count letters */ while (scanf("%c",&ch) == 1) if (isalpha(ch)) { ltrCount[tolower(ch)-'a']++; ltrTotal++; } /* always dump this list to screen */ for (i=0; i<26; i++) { printf("%d %d\n",i,ltrCount[i]); }

18 Counting letters (lc.c) /* if command line has argument –s then print a summary */ if (argc >= 2 && strcmp(argv[1], "-s")==0) { printf(“\n\nLetter counts and frequencies (c:count:freq) are...\n"); for (i=0; i<26; i++) { if (i%2 == 0) printf("\n"); printf("(%c:%4d:%7.4f) ", (i+'a'),ltrCount[i],(double)ltrCount[i]/ltrTotal); } printf("\n\n"); printf("Total number of letters : %7d\n",ltrTotal); } return 0; }

19 gnuplot of “lcdata.txt” – data from running lc on “lc.c”