Question: please use python 6. [2] Create a Python function array_log(a,b,oper) which has three arguments: a and b are numpy arrays of numbers, and oper (standing

 please use python 6. [2] Create a Python function array_log(a,b,oper) whichhas three arguments: a and b are numpy arrays of numbers, and

please use python

6. [2] Create a Python function array_log(a,b,oper) which has three arguments: a and b are numpy arrays of numbers, and oper (standing for operation) is a string. If oper equals 'add' the function returns the array whose entries are the sums of the logarithms of the corresponding entries in a and b i.e., log a[i,j]+log b[i,j]. If oper equals 'subtract' the function returns the array whose entries are the differences of the logarithms of the corresponding entries in a and b i.e., log a[i,j]-log b[i,j]. The function array_log(a,b,oper) should return the string Error if: (a) the string operation has a value other than 'add' or 'subtract', (b) the two arrays have different shapes, and (c) there is an entry in either a or b which is zero or negative. #Question 6 import numpy as np def array_log(a, b, oper): """ operations on matrices, if defined # test cases to try out: print(array_log(np. array([[1,2.34],[4,5]]), np.array([[1.0, 0],[2, 4]]),"add")) print(array_log(np.array([[1,2],[4,5]]), np.array([1,2]), "subtract")) print(array_log(np.array([[1,2],[4,5]]), np.array([[1,2],[2,4]]), "subtract")) print(array_log(np.array([[1,2],[4,5]]), np.array([[1,5),[2,6]]),"add")) print(array_log(np.array([[1,2],[4,5]]), np.array([[1,5],[2,6]]),"subtract")) print(array_log(np.array([[1,2],[4,5]]), np.array([[1,5],[2,6]]), "multiply"))

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!