Description
For all theoretical assignments, you can turn in as either handwriting or
typing in. For all programming assignments, please turn in your code along
with a solution document. You can discuss questions with others, but the
solutions/codes you submit must be entirely your own work, and please mention
who you collaborated with in your homework.
Software: MATLAB / C++ /Python/Java (or any language that you are
familiar)
Problem 1: Suppose we want to solve
21 32 14 8 6 9 11 3 5
17 2 8 14 55 23 19 1 6
41 23 13 5 11 22 26 7 9
12 11 5 8 3 15 7 25 19
14 7 3 5 11 23 8 7 9
2 8 5 7 1 13 23 11 17
11 7 9 5 3 8 26 13 17
23 1 5 19 11 7 9 4 16
31 5 12 7 13 17 24 3 11
| {z }
A
x1
x2
x3
x4
x5
x6
x7
x8
x9
| {z }
X
=
2
5
7
1
6
9
4
8
3
| {z }
B
(1)
1. Use ’inv’ functions in MATLAB or the like in the programming languages
you are using for this homework to get the inverse of A matrix, and the
result X = A−1B. Round X to 4 decimal places.
2. Program LU decomposition, backward-substitution, and forward substitution, to get the result X. Round X to 4 decimal places.
3. Considering the X from Q1 as the accurate results, use L-2 norm to evaluate the relative error kX−XLU k
kXk
,where XLU is the result from Q2. Round
the relative error to 4 decimal places.
1
Problem 2: Suppose we want to find the roots of
f(x) = exp(cos(x) + cos(x
2
)) + cos(x) − 1 = 0 (2)
where x ∈ [0, 2].
Set tolerance = 10−6
,
1. Find out the theoretical iterative step for convergence. Write down the
specific derivations. (You can directly use/duplicate the derivation process
in the Lecture 5-09 slides.)
2. Program the Bisection iterative method to solve this equation; output the
initial guess, iterative steps, results at each iterative step, and the converged result. Round the results at each iterative step and the converged
result to 4 decimal places.
3. Error plot. Plot X axis: iterative step number k, Y axis: the absolute value
of f(xk), where k represents iterative step. Round |f(xk)| to 4 decimal
places.
Submission should include (a) a solution document (PDF/ WORD/handwritten)
showing all results and (b) original codes. Students can find the example codes
on Canvas, and can use the example code accordingly. In the solution document,
students should include:
1. Problem 1
(a) Q1: X (Points: 5)
(b) Q2: Show the specific L matrix, U matrix, and the resulting X
(Points: 30)
Note: For Q2, using functions such as ’lu()’, ’inv’, matrix division,
in MATLAB and the like, will get few credits.
(c) Q3: show the relative error (Points: 5)
2. Problem 2
(a) Q1: write down the specific derivations to predict the minimal iterative number of a converged result, and the result. (Points: 15)
(b) Q2: show the initial guess, results xk at each iterative step, where k
represents iterative step, and the converged result. (Points: 30)
(c) Q3: plot X axis: k (iterative step number), Y axis: |f(xk)| (the
absolute value of residual). (Points: 15)
Note: To plot, any potential approach is acceptable.
3. Appendix
All codes should also be presented as appendix in the solution document.
2