Question
Solve a system of linear equations Ax=b using Gaussian elimination with and without partial pivoting. Use a matrix size of 1000 x 1000 initialized with
Solve a system of linear equations Ax=b using Gaussian elimination with and without partial pivoting. Use a matrix size of 1000 x 1000 initialized with random numbers in the interval [-0.7, 0.7]. Initialize the right hand side by computing b=Az with all z values = 1. (Thus, the solution is in fact known.).
Write your own MATLAB function that performs the initialization of A, b and z. The matrix size is chosen with the intent to make the running time long enough for a reasonably good time measurement, but not excessively long. Use tic and toc to measure execution time.
- Write your own MATLAB function in the spirit of the pseudocode in the lecture slides (from the book) that performs Gaussian Elimination without partial pivoting and apply it to solve for x in Ax=b with A and b generated by your code as described above. Then compute the mean squared error (MSE) ((x-1)2i)/N, and the square root thereof (SMSE). Measure the time to compute x. Do not include the time to initialize A, b and z, and the time to compute the average mean squared error ((x-1)2i)/N, and the square root thereof. Thus, only measure the time to compute x once A and b are known.
i) Carry this out in single precision. Report SMSE and time.
ii) Carry this out in double precision. Report SMSE and time.
Note that by default all variables are represented in double precision. Single precision must be specified explicitly.
- Write your own MATLAB function that performs Gaussian Elimination with partial pivoting. The coding should be at a comparable level as in a) (i.e., not by using high level MATLAB function calls). Then carry out the same set of computations and measurements as in a) for the same A and b (Do not reinitialize A and .
- Solve Ax=b using the MATLAB built in function Linsolve for the same A and b as in a) and b) using double precision, compute MSE and SMSE and measure the time. Report SMSE and time.
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