Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We are not supposed to use numpy, i don't think. At least for the question that says we can't use the built in matrix multiplication

image text in transcribed
We are not supposed to use numpy, i don't think. At least for the question that says we can't use the built in matrix multiplication of python.
Problem 1 Write a function matrix_multiply in Python. The function should take in 2 inputs: matrix X and Y. (2pts) Test to see if the dimensions of the 2 input matrices are eligible for multiplication X* Y. If not, display an error message. (2pts) Calculate matrix Z=X*Y. You CAN NOT use the built in matrix multiplication of Python. Doing this get no credits. (Remember for loops?) (5pts) Output matrix Z (2pts) In your code, write: matrix_multiply(X,Y) (1pts) Problem 2 Write a Python function my_quadratic: The function takes 3 input: Hessian matrix Q, vector b, and vector x. (2pts) Test to see if the inputs have proper dimension dimensions of vectors are not correct. (2pts) Print an error message if the Function returns 2 ouput: first is the quadratic function value evaluated at point x, second is the gradient of the function at point x. (6pts) Test to see if the quadratic is convex or not. Display a message if it is convex or not. You can use the a built-in function in Python that returns the eigenvalues of a matrix A. (5pts). Problem 3 The fused lasso regularization for a vector x is defined as follow: FL(x) = - 12 + Skin where l-li denotes absolute value. Write a function fused_lasso that inputs a vector x and return the value of FL(x). You can not use built-in function. (5pts)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions