Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Write a function called combo( ) that takes in P , Q , a , b . The variables P and Q are 2D
a) Write a function called combo( ) that takes in P , Q , a , b . The variables P and Q are 2D NumPy arrays, and a and b are scalars. combo( ) should compute and return the following nonlinear combination: R = aP3 + bQ3. i.e. Rij = an + 12%. - You need to make sure that matrices P and Q have the same dimensions, and if they do not, then return a number 0. . You must use |oop(s) to perform the calculation and cannot use any built in Python commands or vectorization (i .e. colon notation for additions). En [ ]: import numpy as up b) Using the above function, calculate 2X 3 + 3Y3 where X, Y are given below and store the result in matrix 2. En [ ]: X = np.array([[49,5],[8,10]]) Y = np.array([[3,42],[48,31]) # Type in solution here Z = 0 print(Z)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started