Docsity

Homework Set 6 for Numerical Methods | CS 257, Assignments of Computer Science

Toggle sidebar
bg1
CS 257: Numerical Methods
Spring 2006
Homework, Set 6 Due Thursday March 2, 2006
(-) Start EACH PROBLEM on a SEPARATE piece of paper (This is important since we may
assign each problem to a different grader).
(-) Put your NETID and HW NUMBER on top of EACH PAGE clearly,
e.g. ā€œnetid: zamani hw2ā€.
(-) Write descriptive solutions. Comment your code!
(-) Include your curves/graphs (and other supporting materials) in your write-up.
(-) Don’t use handwritten code (unless you want to lose points), copy-paste your code into
your write-up or attach a proper print of code to your papers.
(-) Please write everything in a ā€œportraitā€ style (not landscape).
(-) Please number problems according to numbers presented in the homework write-up that
appears on the course page, NOT according to the numbers in the textbook.
(-) Please type your homework or hand-write it legibly (but yet attach a print of your codes
to your handwritten stuff).
(-) Show that your code works (even if the problem doesn’t explicitly asks to test your code!)
The purpose of this homework is threefold:
•To highlight several problematic situations in linear algebra.
•To investigate Gaussian elimination.
•To develop cheaper and more stable alternatives to GE, Gaussian elimination.
The required files for this assignment:
•GEbasic.m : http://www.cs.uiuc.edu/class/sp06/cs257/homework/GEbasic.m
•GEppiv.m : http://www.cs.uiuc.edu/class/sp06/cs257/homework/GEppiv.m
•GE.m : http://www.cs.uiuc.edu/class/sp06/cs257/homework/GE.m
(1) Uniqueness of Solutions Show (by hand) that the system of equations:
x1+ 4x2+αx3= 6
2x1āˆ’x2+ 2αx3= 3
αx1+ 3x2+x3= 5
has a unique solution when α= 0, no solution when α=āˆ’1, and infinitely many solutions when
α= 1.
(2) Finite Precision and Gaussian Elimination Consider the following system of equations:
0.1036x1+ 0.2122x2= 0.7381
0.2081x1+ 0.4247x2= 0.9327
Solve by hand using Gaussian elimination (without pivoting) in two ways:
•retain only 4 significant digits after each operation by chopping the extras
pf2

Partial preview of the text

Download Homework Set 6 for Numerical Methods | CS 257 and more Assignments Computer Science in PDF only on Docsity!

CS 257: Numerical Methods Spring 2006 Homework, Set 6 Due Thursday March 2, 2006

(-) Start EACH PROBLEM on a SEPARATE piece of paper (This is important since we may assign each problem to a different grader). (-) Put your NETID and HW NUMBER on top of EACH PAGE clearly, e.g. ā€œnetid: zamani hw2ā€. (-) Write descriptive solutions. Comment your code! (-) Include your curves/graphs (and other supporting materials) in your write-up. (-) Don’t use handwritten code (unless you want to lose points), copy-paste your code into your write-up or attach a proper print of code to your papers. (-) Please write everything in a ā€œportraitā€ style (not landscape). (-) Please number problems according to numbers presented in the homework write-up that appears on the course page, NOT according to the numbers in the textbook. (-) Please type your homework or hand-write it legibly (but yet attach a print of your codes to your handwritten stuff). (-) Show that your code works (even if the problem doesn’t explicitly asks to test your code!)

The purpose of this homework is threefold:

  • To highlight several problematic situations in linear algebra.
  • To investigate Gaussian elimination.
  • To develop cheaper and more stable alternatives to GE, Gaussian elimination.

The required files for this assignment:

  • GEbasic.m : http://www.cs.uiuc.edu/class/sp06/cs257/homework/GEbasic.m
  • GEppiv.m : http://www.cs.uiuc.edu/class/sp06/cs257/homework/GEppiv.m
  • GE.m : http://www.cs.uiuc.edu/class/sp06/cs257/homework/GE.m

(1) Uniqueness of Solutions Show (by hand) that the system of equations:

x 1 + 4 x 2 + αx 3 = 6 2 x 1 āˆ’ x 2 + 2 αx 3 = 3 αx 1 + 3 x 2 + x 3 = 5

has a unique solution when α = 0, no solution when α = āˆ’1, and infinitely many solutions when α = 1.

(2) Finite Precision and Gaussian Elimination Consider the following system of equations:

  1. 1036 x 1 + 0. 2122 x 2 = 0. 7381
  2. 2081 x 1 + 0. 4247 x 2 = 0. 9327

Solve by hand using Gaussian elimination (without pivoting) in two ways:

  • retain only 4 significant digits after each operation by chopping the extras
  • retain only 8 significant digits after each operation by chopping the extras

Show your work for the Gaussian elimination. Using MATLAB’s solution as the exact solution,

compute the 2-norm of the error, ‖x āˆ’ xāˆ—ā€– 2 , using norm(error,2), where x is your solution and xāˆ— is the solution from Matlab. You should notice one error is larger than the other.

(3) Gaussian Elimination with and without Pivoting GEbasic.m and GEppiv.m are implementa- tions of the basic Gaussian elimination (both forward elimination and backward substitution) pre- sented in class. Test the two routines on the following matrix. With GEppiv, use a pivot tolerance of

50 m. Present the two different solutions. Use MATLAB’s slash to obtain an exact solution. Compute

and compare the 2-norm of the error for the basic and pivoted solutions using norm(error,2). You should notice one error is larger than the other. These routines also output the pivot at each step. What do you notice about the size of the pivots between the two cases?    

x 1 x 2 x 3 x 4

(4) The Cost of Gaussian Elimination In this problem, we will use GE.m (Gaussian elimination with- out pivoting) to investigate computational cost. We will compare the time to use:

  • the GE method to solve Ax = b

• MATLAB’s slash to solve Ax = b

  • a Matrix-Matrix multiply AB
  • a Matrix-Vector multiply Au

Use the provided code, GE.m, as a base. Feel free to vary the problem size until you reach the limits of your machine. Output required:

  • a plot of the problem size n on the x-axis versus the time, t, to carry out the operation on the y-axis for the four operations.
  • 2-3 sentences discussing the cost of the four operations.

• do not hand in code or MATLAB command line output for this problem.