Introduction When large programs are written, they are normally broken down into smaller parts called subroutines...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Introduction When large programs are written, they are normally broken down into smaller parts called subroutines or in the case of Python, functions. This semester we will write a Python library to perform naïve gaussian elimination. A library is just a collection of related functions that can be reused in different programs. For example, we often use the math library because it contains several useful functions like sqrt(), sin(), cos (), etc. In Projects 1 through 3, we'll write a library called my_solver that contains three functions required to perform naïve Gaussian elimination. Together, these functions will take a system of linear equations of the from Ax = b and solve them. In project 4 we'll solve an electrical circuit using our library and write a report on the results. The overall structure of the library is shown in the dashed box in Fig 1. main.py solve() my_solver.py aug() gauss() Figure 1 Structure of the Library with Functions. The program called main, is not part of the library but uses the library just like we use the math library. Main will set up the problem by forming the A and b matrices for a system of linear equations and pass them to the function solve. Then solve will call aug to form the augmented matrix [A]b]. The augmented matrix will then be passed to the function gauss which will perform naïve Gaussian elimination on [Alb]. The resulting echelon form of the augmented matrix will be returned to solve. Back substitution will be performed and solve will return the solution to the main program. A very high level pseudo code for performing naïve Gaussian elimination can be written as: augment matrices A and B perform gaussian elimination # done in aug() # done in gauss() #done in solve() perform back substitution We've broken done a large programming problem into small pieces that we implement in functions. We program those functions in a library so that we can easily import them and use whenever we need them. Also notice that the program performs Gaussian elimination just like we do when solving by hand. The Augmented Matrix Function Project 1 requires a documented function named aug that forms an augmented matrix from two matrices passed to it. The use of for loops is required to perform the augmentation. The function should return the augmented matrix to the calling program. Include error checking to ensure both matrices to be augmented have the same number of rows. If they do not, display a descriptive error message and stop rogram execution. The function should be in a Python file that you name my solver.py, NOT in a file called aug. py. To use aug in a program, we'll need to import the library with import my_solver as ms and then call the function with ms.aug(). Do not assume that either matrix is a vector. This will allow the function to be more general so that it can be used for situations where we might want to augment a given matrix with the identity matrix. Pseudo Code for the Augmented Matrix Function For full credit, your function must follow this pseudo code and you can not use any functions we have not discussed in class. Significant points will be lost if this criteria is not followed. find rows m₁ and columns n₁ in A find rows m2 and columns n2 in B if m₁m₂ print error message saying rows must be equal stop # Find size of the augmented matrix aux_A rows in aug_A = rows in A (or we could use rows in B) columns in aug_A columns in A+ columns in B initialize empty aug A matrix # Copy A into aug_A for i to m₁ for je to n₁ Copy contents of A₁, into aug_A₁,5 # Append B to the right of A in the augmented matrix for i 0 to m₂ for j 0 to n₂ Copy contents of B₁, into aug_A₁, 5+1 = Introduction When large programs are written, they are normally broken down into smaller parts called subroutines or in the case of Python, functions. This semester we will write a Python library to perform naïve gaussian elimination. A library is just a collection of related functions that can be reused in different programs. For example, we often use the math library because it contains several useful functions like sqrt(), sin(), cos (), etc. In Projects 1 through 3, we'll write a library called my_solver that contains three functions required to perform naïve Gaussian elimination. Together, these functions will take a system of linear equations of the from Ax = b and solve them. In project 4 we'll solve an electrical circuit using our library and write a report on the results. The overall structure of the library is shown in the dashed box in Fig 1. main.py solve() my_solver.py aug() gauss() Figure 1 Structure of the Library with Functions. The program called main, is not part of the library but uses the library just like we use the math library. Main will set up the problem by forming the A and b matrices for a system of linear equations and pass them to the function solve. Then solve will call aug to form the augmented matrix [A]b]. The augmented matrix will then be passed to the function gauss which will perform naïve Gaussian elimination on [Ab]. The resulting echelon form of the augmented matrix will be returned to solve. Back substitution will be performed and solve will return the solution to the main program. A very high level pseudo code for performing naïve Gaussian elimination can be written as: augment matrices A and B perform gaussian elimination # done in aug() # done in gauss() #done in solve() perform back substitution We've broken done a large programming problem into small pieces that we implement in functions. We program those functions in a library so that we can easily import them and use whenever we need them. Also notice that the program performs Gaussian elimination just like we do when solving by hand. The Augmented Matrix Function Project 1 requires a documented function named aug that forms an augmented matrix from two matrices passed to it. The use of for loops is required to perform the augmentation. The function should return the augmented matrix to the calling program. Include error checking to ensure both matrices to be augmented have the same number of rows. If they do not, display a descriptive error message and stop rogram execution. The function should be in a Python file that you name my_solver.py, NOT in a file called aug.py. To use aug in a program, we'll need to import the library with import my_solver as ms and then call the function with ms.aug(). Do not assume that either matrix is a vector. This will allow the function to be more general so that it can be used for situations where we might want to augment a given matrix with the identity matrix. Pseudo Code for the Augmented Matrix Function For full credit, your function must follow this pseudo code and you can not use any functions we have not discussed in class. Significant points will be lost if this criteria is not followed. find rows m₁ and columns n₁ in A find rows m2 and columns n2 in B if m₁m₂ print error message saying rows must be equal stop # Find size of the augmented matrix aux A rows in aug_A = rows in A (or we could use rows in B) columns in aug_A columns in A+ columns in B initialize empty aug A matrix # Copy A into aug_A for i to m₁ for j to n₁ Copy contents of A₁, into aug_A₁,5 # Append B to the right of A in the augmented matrix for i 0 to m₂ for j 0 to n₂ Copy contents of B₁, into aug_A₁, 5+1 = Introduction When large programs are written, they are normally broken down into smaller parts called subroutines or in the case of Python, functions. This semester we will write a Python library to perform naïve gaussian elimination. A library is just a collection of related functions that can be reused in different programs. For example, we often use the math library because it contains several useful functions like sqrt(), sin(), cos (), etc. In Projects 1 through 3, we'll write a library called my_solver that contains three functions required to perform naïve Gaussian elimination. Together, these functions will take a system of linear equations of the from Ax = b and solve them. In project 4 we'll solve an electrical circuit using our library and write a report on the results. The overall structure of the library is shown in the dashed box in Fig 1. main.py solve() my_solver.py aug() gauss() Figure 1 Structure of the Library with Functions. The program called main, is not part of the library but uses the library just like we use the math library. Main will set up the problem by forming the A and b matrices for a system of linear equations and pass them to the function solve. Then solve will call aug to form the augmented matrix [A]b]. The augmented matrix will then be passed to the function gauss which will perform naïve Gaussian elimination on [Alb]. The resulting echelon form of the augmented matrix will be returned to solve. Back substitution will be performed and solve will return the solution to the main program. A very high level pseudo code for performing naïve Gaussian elimination can be written as: augment matrices A and B perform gaussian elimination # done in aug() # done in gauss() #done in solve() perform back substitution We've broken done a large programming problem into small pieces that we implement in functions. We program those functions in a library so that we can easily import them and use whenever we need them. Also notice that the program performs Gaussian elimination just like we do when solving by hand. The Augmented Matrix Function Project 1 requires a documented function named aug that forms an augmented matrix from two matrices passed to it. The use of for loops is required to perform the augmentation. The function should return the augmented matrix to the calling program. Include error checking to ensure both matrices to be augmented have the same number of rows. If they do not, display a descriptive error message and stop rogram execution. The function should be in a Python file that you name my solver.py, NOT in a file called aug. py. To use aug in a program, we'll need to import the library with import my_solver as ms and then call the function with ms.aug(). Do not assume that either matrix is a vector. This will allow the function to be more general so that it can be used for situations where we might want to augment a given matrix with the identity matrix. Pseudo Code for the Augmented Matrix Function For full credit, your function must follow this pseudo code and you can not use any functions we have not discussed in class. Significant points will be lost if this criteria is not followed. find rows m₁ and columns n₁ in A find rows m2 and columns n2 in B if m₁m₂ print error message saying rows must be equal stop # Find size of the augmented matrix aux_A rows in aug_A = rows in A (or we could use rows in B) columns in aug_A columns in A+ columns in B initialize empty aug A matrix # Copy A into aug_A for i to m₁ for je to n₁ Copy contents of A₁, into aug_A₁,5 # Append B to the right of A in the augmented matrix for i 0 to m₂ for j 0 to n₂ Copy contents of B₁, into aug_A₁, 5+1 = Introduction When large programs are written, they are normally broken down into smaller parts called subroutines or in the case of Python, functions. This semester we will write a Python library to perform naïve gaussian elimination. A library is just a collection of related functions that can be reused in different programs. For example, we often use the math library because it contains several useful functions like sqrt(), sin(), cos (), etc. In Projects 1 through 3, we'll write a library called my_solver that contains three functions required to perform naïve Gaussian elimination. Together, these functions will take a system of linear equations of the from Ax = b and solve them. In project 4 we'll solve an electrical circuit using our library and write a report on the results. The overall structure of the library is shown in the dashed box in Fig 1. main.py solve() my_solver.py aug() gauss() Figure 1 Structure of the Library with Functions. The program called main, is not part of the library but uses the library just like we use the math library. Main will set up the problem by forming the A and b matrices for a system of linear equations and pass them to the function solve. Then solve will call aug to form the augmented matrix [A]b]. The augmented matrix will then be passed to the function gauss which will perform naïve Gaussian elimination on [Ab]. The resulting echelon form of the augmented matrix will be returned to solve. Back substitution will be performed and solve will return the solution to the main program. A very high level pseudo code for performing naïve Gaussian elimination can be written as: augment matrices A and B perform gaussian elimination # done in aug() # done in gauss() #done in solve() perform back substitution We've broken done a large programming problem into small pieces that we implement in functions. We program those functions in a library so that we can easily import them and use whenever we need them. Also notice that the program performs Gaussian elimination just like we do when solving by hand. The Augmented Matrix Function Project 1 requires a documented function named aug that forms an augmented matrix from two matrices passed to it. The use of for loops is required to perform the augmentation. The function should return the augmented matrix to the calling program. Include error checking to ensure both matrices to be augmented have the same number of rows. If they do not, display a descriptive error message and stop rogram execution. The function should be in a Python file that you name my_solver.py, NOT in a file called aug.py. To use aug in a program, we'll need to import the library with import my_solver as ms and then call the function with ms.aug(). Do not assume that either matrix is a vector. This will allow the function to be more general so that it can be used for situations where we might want to augment a given matrix with the identity matrix. Pseudo Code for the Augmented Matrix Function For full credit, your function must follow this pseudo code and you can not use any functions we have not discussed in class. Significant points will be lost if this criteria is not followed. find rows m₁ and columns n₁ in A find rows m2 and columns n2 in B if m₁m₂ print error message saying rows must be equal stop # Find size of the augmented matrix aux A rows in aug_A = rows in A (or we could use rows in B) columns in aug_A columns in A+ columns in B initialize empty aug A matrix # Copy A into aug_A for i to m₁ for j to n₁ Copy contents of A₁, into aug_A₁,5 # Append B to the right of A in the augmented matrix for i 0 to m₂ for j 0 to n₂ Copy contents of B₁, into aug_A₁, 5+1 =
Expert Answer:
Answer rating: 100% (QA)
Based on the given information and pseudo code we can outline the process to create an augmented mat... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
Calculate the gross pay with ei, cpp and claim code of canada. 1. Chris makes $48,000 a year. He is paid semi-monthly. What is his gross pay per pay period? 2. John earns $59,800 a year. He is paid...
-
How much will $106 become if discounted 9% per year for 6 years? Enter your answer as a number with four decimal places but without the currency symbol, like this: 90.1234 Type your answer...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Window World extended credit to customer Nile Jenkins in the amount of $130,900 for his purchase of window treatments on April 2. Terms of the sale are 2/60, n/150. The cost of the purchase to Window...
-
A block having mass m and charge + Q is connected to a spring having constant k. The block lies on a frictionless horizontal track, and the system is immersed in a uniform electric field of magnitude...
-
Show that when f(z) = x3 + i(1 y)3, it is legitimate to write f'(z) = ux + ivx = 3x2 only when z = i.
-
Helium at a free stream temperature of \(T_{\infty}=25^{\circ} \mathrm{C}\) is in parallel flow over a flat plate of length \(L=3 \mathrm{~m}\) and temperature \(T_{s}=85^{\circ} \mathrm{C}\)....
-
Gold Clothiers reported the following selected items at September 30, 2016 (last years2015amounts also given as needed): Accounts Payable .......... $ 331,000 Cash ................. 302,900...
-
The following account balances are taken from Oriole Ltd's adjusted trial balance at June 30, 2024: Debit Credit Sales revenue $1,246,000 Advertising expense $124,000 Cost of goods sold 595,000...
-
Redang Chalet Sdn Bhd (RCSB) rents out chalet to tourists at a popular beach in Redang, Terengganu. RCSB own 10 chalets, in which the construction cost amounted to RM1 million. Each chalet is...
-
2022 testifies to the resilience of the air transport industry. After the largest shock in aviation's history, recovery is well underway and forecast to continue through 2022 and beyond Do you agree...
-
K Internal control is a plan of organization and a system of procedures, implemented by company. A. external auditors; management B. external auditors; board of directors OC. internal auditors;...
-
What is 'audit risk', and discuss/analyze the components of audit risk. b. List the four (4) things involved in the initial audit planning and which should be done early in the audit.
-
The incentive to consume tax-deductible goods, instead of nondeductible goods, increases when
-
Joseph and Milena purchase a very successful Italian restaurant "Ciao" from Giuseppe. It is located on the famous Italian eatery strip in Lygon St in Carlton, Melbourne. To ensure Giuseppe does not...
-
point Which is NOT one of the 3 Cs of user story creation? Conversation-The user story is supported by a conversation or is a starting point for a conversation between business and project teams....
-
Find the first 4 terms of the Taylor series for the following functions: 1 T (a) In x centered at a=1, (b) - centered at a=1, (c) sinx centered at a = - 4
-
Listed below are common types of current liabilities, contingencies, and commitments: a. Accounts payable b. Bank loans and commercial paper c. Notes payable d. Dividends payable e. Sales and excise...
-
Seller had manufactured forty thousand pounds of plastic resin pellets specially for the buyer, who agreed to accept them at the rate of one thousand pounds per day upon his issuance of shipping...
-
The MacGilvray Shiras was a ship owned by the Kinsman Transit Company. During the winter months, when Lake Erie was frozen, the ship and others moored at docks on the Buffalo River. As oftentimes...
-
For the balance due on the purchase of a tractor Henry Brown executed and delivered to Jane Jones his promissory note containing the following language: January 1, 2011, I promise to pay to the order...
-
The materials which exhibit the same elastic properties in all directions are known as: (a) Homogeneous (b) Isotropic (c) Isentropic (d) Inelastic
-
In a reaction steam turbine, steam expands: (a) In nozzle only (b) In moving blades only (c) Partly in nozzle partly in blades (d) None of the above
-
In impulse turbines, pressure on the two sides of the moving blades: (a) Increases (b) Decreases (c) Remains same (d) None of the above
Study smarter with the SolutionInn App