Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q4. Write a python code to do the following operations. 1. Create a 1000 x 1000 matrix A. Each element of the matrix is a

image text in transcribed

Q4. Write a python code to do the following operations. 1. Create a 1000 x 1000 matrix A. Each element of the matrix is a random integer in the range 1, 100). 2. Convert the type of the matrix elements from integer to floating point. 3. Create the matrix B by doing the following element-wise operation on A: 45VA Bij = sin Aij where Bij and Aij denote the elements of B and A. You are required to do this element-wise operation explicitly by loop over the elements of B and A Print the first element of B and get the time for creating this B in unit of nanosecond. 4. Create the same matrix B by Numpy element-wise operation. Print the first element of B and get the time for creating this B in unit of nanosecond. 5. Let's call the matrix B created in Q4.3 B1 and the matrix B created in Q4.4 B2. Although B, and B, are created in different ways, they should be identical in principle. In order to check if they are really identical, we can look at the Frobenius norm of the relative error: B2-B1 B In the above expression, all the operations inside || . || are element-wise. Evaluate this Frobenius norm and check if the relative error is small

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions