Question: Write a function matrix_op(X, n, m) which takes the arguments 'X' (a number), 'n' (an integer greater than 1), and 'm' (an integer greater
Write a function matrix_op(X, n, m) which takes the arguments 'X' (a number), 'n' (an integer greater than 1), and 'm' (an integer greater than 0), and constructs the matrices A and B of size n x n as below A = 2(i + X) + 3(j - X), where i and j are the row and column indices (starting at zero). After calculating A and B, the function should return the matrix product B" A, where all the elements of the answer are rounded to two decimal digits. Hints: Use np.around() for rounding. You can assume that X will always be such that j + X is real. B" should be understood as a matrix power. For instance, for m = 3, we have B = BBB, that is the matrix B multiplying itself 3 times (in terms of a matrix product, not element-wise). For example: Test Result print (matrix_op(6, 2, 3)) [[414.19 163.24] [250.05 98.55]] print (matrix_op (2, 3, 2)) [[ 6.03 33.89 61.76] [2.51 11.06 19.61] [-1. -11.77 -22.54]] Answer: (penalty regime: 10, 20, 30, 40, 50, 60 %) Reset answer 1 import numpy as np 2 3 def matrix_op(X, n, m): 4 5 6 7 TIT Bj=i-j+X, Returns the matrix B^m A as instructed. #your code here Precheck Check li
Step by Step Solution
3.39 Rating (146 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
