Reference no: EM132385809
COMP 350 Numerical Computing Assignment - Floating Point Arithmetic and IEEE Standard, McGill University, Canada
Question 1: GENP and LU Decomposition
Consider the linear system Ax = b defined by
(a) Use the GENP algorithm to solve the above system by hand. Show intermediate matrices, vectors and multipliers at each step.
(b) Find matrices L1, L2 where L2 is an elementary matrix, and L1 is a product of two elementary matrices such that L2L1A = U, an upper triangular matrix. Then compute a (unit) lower triangular matrix L such that A = LU.
(c) Solve Ly = b by forward substitution to find y.
(d) Solve Ux = y by backward substitution to find x. The value of x should be the same as what you found in part (a).
Question 2: LU Decomposition in Matlab
Write a Matlab function myLU(A) which takes an input matrix A and produces the L,U factors in the LU decomposition of A. Show the output of
>> A = [1 2 3 4; 2 0 3 5; 2 -1 2 7; 1 1 4 9]
>> [L, U] = myLU(A)
Question 3: GEPP
(a) Solve the following system using GEPP (Gaussian elimination with partial pivoting):
Show intermediate matrices, vectors and multipliers at each step. Do the computations by your hands and don't consider any rounding errors.
(b) Compute the LU factorization of the matrix in the previous question with partial pivoting: PA = LU. Show the intermediate results at each step. This question and the previous one can be answered together.
Question 4: Comparing Accuracy of GENP and GEPP
Write a Matlab function compareGENPGEPP(n, N) that compares the answers produced by GENP and GEPP as follows:
1. It creates a sample of N runs (inside a for loop).
2. For each run, it generates of random matrix A of size n x n, a random vector x of size n x 1 and a computes the right-hand-side Ax = b. Use the Matlab function randn to generate these.
3. It runs genp(A,b) and gepp(A,b) on each sample and constructs the log10||xcomputed - x||2 error term between the computed and the true value of x.
4. It plots the iteration index against the error terms for each run. Use red-dot to represent a genp-run and a blue-dot to represent a gepp-run.
Print your matlab code as well as the figure for compareGENPGEPP(200,1000). Comment what conclusion you can draw from your plot.
Question 5: Formulas for Polynomial Series
Consider the problem of finding a formula for the sum of squares and suppose we know the form of the solution:
a0 + a1n + a2n2 + a3n3 = j=0∑n j2
where the aj are unknown and to be determined.
(a) Using the column vector [a0, a1, a2, a3]T to represent to the polynomial on the left, write the equations for the above for n = 0, 1, 2, 3 into a linear system of the form Ax = b.
(b) Solve the system using Matlab. What is the formula for summing the squares?
(c) Explain how you would generalize this procedure to polynomials of arbitrary degree?