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 randomsquarematrixpower that can randomly generate a byn squared matrix A and calculate its th power The specific requirements are as follows.
Two inputs: i the size of the squared matrix; ii the power of matrix to be calculated
Two outputs: ii the randomly generated matrix; ii the th power of
Test instance: test your algorithm with inputs and 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.matrixpower
Note: adding comment in each line of code will receive one extra point given that code runs correctly.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
