Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Elementary row operations 1) Recall that the three types of elementary row operations are 1) multiplying a row by a scalar 2) int rows 3)

image text in transcribed
Elementary row operations 1) Recall that the three types of elementary row operations are 1) multiplying a row by a scalar 2) int rows 3) Adding a multiple of one row to another Write three separate Python python functions that each take an input matrix A an elementary row operation to A. You must choose what the appropriate arguments for row operation. You may call your functions ero.sm, ero.ri, ero.asmr, (for scalar multiple, rowi multiple of row, respectively) and return the result of applying the function are to specify the return a new matrix, but not modify the input matrix. You will need to copy the input matrix using the syntax B-A.copy O somewhere inside your functons. 2) Write a set of three function s that return the elementary matrices corresponding to these three types of row operations. tions should take as input the matrix size n, and the same arguments as you designed for your answers for problenm creating an identity matrix and applying the row operation to the identity matrix using your 1). You may do this by functions from problem 1). See page 176 in the text, and theorem 3.10, for more information. 3 3) i) Let A be the matrix -112. Using your functions above, apply a series of elementary row operations to transform A into the 3x3 identity matrix. Keep track of what operations you applied. i) Now, for each row operation that you applied, compute the corresponding elementary matrix using the functions you created in problem 2). Name these E1, E2, E3, etc. ii) Verify that the product of all of these elementary matrices (in reverse order) and A gives the identity matrix. v) Compute the product (in reverse order) of the elementary matrices, and verify that it is the same as A-1 (computed with the numpy command np.linalg.inv(A)) For loops and Matrix Multiplication 4) Write a Python function that takes a matrix A, and a scalar c, and returns the number of elements in A that have the value c. Do this using a nested for loop, i.e explicitly looping over all of the elements in the matrix A, comparing them to c, and then incrementing a counter variable. Test your code by choosing your own matrix A, a value c that A contains at least once, and show the results of calling your code with these inputs. 5) Matrix Multiplication Write a Python function that takes two matrices A and B, checks if the inner dimensions are equal, and if so returns a matrix C that is equal to the matrix product AB. Otherwise your code may print an error message (or raise an Exception) You should do this using a triply nested for loop: first create a matrix C of all zeros, then loop over all of the elements of C, and then for each element of C compute the appropriate value using Validate your code by your own choosing matrices A and B and computing the matrix product using both your code nd the built-in matrix multiplication operator G

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions