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 AAij Bij sin Ajj where By 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 B, and the matrix B created in Q4.4 B. Although B and B2 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: B In the above expression, all the operations inside . || are element-wise. Evaluate this Frobenius norm and check if the relative error is small. (5 X 4 = 20 marks)

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

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

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

How and why does an investor short sell a security?

Answered: 1 week ago

Question

Refer to Problem 10-1. What is the projects PI?

Answered: 1 week ago

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago

Question

Understand the roles of signs, symbols, and artifacts.

Answered: 1 week ago