Question: Create a Python function named random _ square _ matrix _ power that can randomly generate a n - by - n squared matrix A

Create a Python function named random_square_matrix_power that can randomly generate a n-by-n squared matrix A and calculate its p-th power Ap. The specific requirements are as follows.
Two inputs: (i)n, the size of the squared matrix; (ii)p, the power of matrix to be calculated
Two outputs: (ii)A, the randomly generated matrix; (ii)Ap, the p-th power of A
Test instance: test your algorithm with inputs n=3 and p=10, print the outputs.
Packages and functions you may need to use (click will lead you to the webpages):
numpy.random.rand
numpy.random.randint
numpy.matmul
numpy.linalg.matrix_power
Note: adding comment in each line of code will receive one extra point given that code runs correctly.
 Create a Python function named random_square_matrix_power that can randomly generate a

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!