Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CIV-350 Assignment 2B

Due on 02/23/2023
Total of 50 points (5 points for each question)
(Please stop by the office hour or email to ephraim.bryski@stonybrook.edu if any questions)

Code Description

The successive over-relaxation method (SOR) is used to solve a system of equations, which
can be represented as:

M*x=b

The attached code uses the SOR method to solve a system of equations. The SOR method is
performed in a function -- do not modify this function!

Analyzing Problem

1. Using the SOR method, the matrix M is decomposed into the matrices L, D, and U. What
is the meaning of those three matrices (you may want to check the textbook)?
2. After running the code, check the values of L, D, and U. Based on these values, what is
the combined matrix M? What is its size? (You can use ellipsis to represent repetition
when writing the matrix). Add a line of code to get the value of M.
3. What is the value of b in the sample script? What is its size?
4. What is the value of x, the solution to the problem? Add a line of code to check that it is
indeed the solution to the problem.
5. The function also outputs the errors for each iteration. Add a line of code to get the
length of the vector to determine the number of iterations required.

Varying the Relaxation Factor

6. The value for the relaxation factor 𝜔 is passed as an input into the SOR function. What
value is used? Try choosing a different value for 𝜔 between 1 and 2. Do you get the
same value for x? Do you get the same value for the number of iterations?
7. Write a for loop. Each iteration, it should call the SOR function, with a value of 𝜔 ranging
from 1 to 1.99 in intervals of 0.01. Plot the number of iterations required in terms of the
value of 𝜔.
8. What is the meaning of 𝜔? Why might you see the relation in the plot you created?
9. When 𝜔 equals 1, what is the SOR method equivalent to?
10. Try running the code with 𝜔 equal to 2. What happens? What might be the reason?

Submission

All questions except 7 require handwritten answers. Questions 2, 4, 5, and 7 require writing
additional code to the code provided, and question 7 also requires generating a figure. Submit
the handwritten answers, the modified code (as a single file), and an image of the figure.

You might also like