Question: This needs to be done in python. 0. Create a new markdown cell below and type in the answers. 1. Write a function that takes

This needs to be done in python.

This needs to be done in python. 0. Create a new markdown

0. Create a new markdown cell below and type in the answers. 1. Write a function that takes in two vectors and returns their inner product. Use a loop or nditer, not inbuilt functions (we aren't aiming for a good implementation, but to ensure you understand inner products :)) 2. Verify the previous function by using the numpy inbuilt command np.dot that computes the inner product. 3. Write a function that takes in two vectors and returns their outer product. Again, use a loop or nditer, not inbuilt functions. 4. Verify the previous function by using the numpy inbuilt command np.matmul or the operator @. In this sequence of problems, we will generate random matrices (2d arrays), and calculate the product by using by both inner and outer product methods and then compare them with the product implemented in numpy. 5. Write a function in numpy that takes two arbitrary shape matrices and calculates the product by the inner product method. Make sure it checks whether their shapes are compatible. 6. Write a function in numpy that takes two arbitrary shape matrices and calculates the product by the outer product method. Make sure it checks whether their shapes are compatible. 7. Calculate the product by using the numpy operator '@' or np.matmul and verify that it equals the output from the functions written above. 8. Verify that a matrix multiplied by a column vector is simply a linear combination of the columns of the matrix. Namely, if the columns of the matrix A are a_1, a_2, .. a_n and the vector x is (x_1,... X_n), then Ax = x_1 a_1 + ... +x_n a n. Explain why this is simply the outer product way of multiplying A and X. 9. Now verify that a row vector multiplied by a matrix is simply a linear combination of the rows of the matrix. Explain again that this is just the outer product way of multiplying. 10. Using the insights in 8: obtain a matrix P such that if A is any matrix with 3 columns, AP is a cyclic shift of the columns of A (namely the first column of A is the second column of AP, second column of A is the third column of AP, and the third column of A becomes the first column of AP). 11. Using the insight in 9: obtain P such that if A is any matrix with 3 rows, PA is a cyclic shift of the rows (cyclic as explained in 10.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!