Question
Numpy and Python . Create a 1000x1000 matrix A with random numbers and a random number vector b with 1000 elements. Solve the simultaneous equation
Numpy and Python. Create a 1000x1000 matrix A with random numbers and a random number vector b with 1000 elements. Solve the simultaneous equation Ax = b in the following ways:
i) By using the inverse of A, i.e. A-1, with numpy.linalg.inv and then solving for Ax = b.
ii) By using numpy.linalg.solve
Find the estimation error in the solution, ||Ax - b||. It should be very close to zero.
Use @timeit to find how long it takes to use i and ii.
What difference is the between the results? Why is there a difference?
Start with the following code:
A = np.random.rand(1000,1000)
b = np. random.rand(1000)
*enter rest of code here*
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