Question: ( a ) Write a loop - based code that computes q 2 , where q is size 1 0 0 1 . To test
a Write a loopbased code that computes q where q is size To test
your code and show that it works, use the rand function to create a vector q
with random entries. Store the value of q as a variable Nq Then, apply your
method. At the end of the loop, check your error with the following code:
looperror abs normq Nq
b Now write a code for computing q that avoids using any loops and instead uses
transposes and a matrixvector product. Store your value in the variable NqIP,
and then compute the error
IPerror abs normq NqIP
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
