CS计算机代考程序代写 matlab algorithm ENGR20005

ENGR20005
Numerical Methods in Engineering
Workshop 4
Part A: MATLAB Livescripts
4.1 The livescript ENGR20005 Workshop4p1.mlx runs through the solution of systems of linear equations in MATLAB.
(a) Read through the livescript and understand what each command does.
(b) Consider another system of equations
26x+ y− 4z= 12 −3x+ 7y− 8z= 4 −x − 11y + 18z = −32
Modify the livescript to solve Eq. (4.1).
(4.1)
4.2 The livescript ENGR20005 Workshop4p2.mlx runs through the use of direct methods to solve systems of linear equations.
(a) Read through the livescript and understand what each command does.
(b) Modify the livescript to solve Eq. (4.1).
4.3 The livescript ENGR20005 Workshop4p3.mlx runs through the use of the Point Jacobi method to solve systems of linear equations.
(a) Read through the livescript and understand what each command does.
(b) Modify the livescript to solve Eq. (4.1).
4.4 The livescript ENGR20005 Workshop4p4.mlx runs through the use of the Gauss–Seidel method to solve systems of linear equations.
(a) Read through the livescript and understand what each command does. (b) Modify the livescript to solve Eq. (4.1).
1

Part B: Problems
4.5 * Consider the system of linear equations
4x− y−2z=1 x − 2y + 3z = 4 x+ y+ z=1
(a) Write Eq. (4.2) in the form
(b) Solve Eq. (4.2) by hand using Gaussian elimination. Check your answer with
MATLAB’s \ command.
(c) Use Crout’s method to decompose [A] into the lower and upper triangular matrices
[L] and [U].
(d) Use your answer to (c) to solve Eq. (4.2).
(e) Repeat the problem with {c} = {2, 6, 7}.
4.6 Consider the system of linear equations
􏰈 20 −3􏰉􏰈x􏰉 􏰈0􏰉 −10 2 y = 1
(4.3)
[A]{x} = {c}
(a) Decompose [A] into the [M] and [N] matrices for both the Point Jacobi and Gauss–Seidel methods.
(b) Perform 3 iterations with both methods assuming an initial condition of {X}(0) = {1, 1}.
(c) Use the code snippets provided in the livescripts to check your answer to part (b).
4.7 In lectures you would have seen that while LU decomposition is applicable to a wide
range of matrices, it does have a complexity of O(n3).
However, if the matrix admits a special structure, then modified algorithms may be
used to speed up these computations.
Assume that [A] is a real symmetric positive definite matrix. What we mean by positive
definite is that for any {z} ∈ Rn excluding the zero vector, the matrix [A] satisfies {z}T[A]{z} > 0
Then it can be shown that [A] may be written as [A] = [L][L]T
which is known as the Cholesky decomposition of [A]. Note that [L]T is an upper triangular matrix.
2
(4.2)

(a) From a compuatational standpoint, what are the advantages of having a Cholesky decomposition?
(b) Consider the 3 × 3 matrix
And a decomposition
a11 a12 a13  [A] = a21 a22 a23 
(4.4)
(4.5)
a31 l11
[L] = l21 l31
a32 a33
0 0 l22 0 l32 l33
i. Determine [L][L]T.
ii. Equate your answer to part i. with [A] and show that
√a11 0 0 [L] = a21/l11 􏰣a22 − l21 0 
a31/l11 (a32 − l31l21)/l22 􏰣a33 − l321 − l322 iii. Conclude that for an n × n matrix, the entries of L are given by
fori>j
􏰦 􏰥
j−1
l j j = ± 􏰥􏰤 a j j − 􏰐 l 2
1􏰌 j−1 􏰍 lij = l aij −􏰐likljk
jj k=1
jk k=1
(c) Modify the code snippets provided in lectures to compute the Cholesky decom- position of a matrix [A].
Check your answer with MATLAB’s chol function.
(d) Using your function in part (c), solve the following system of linear equations
x1− 3×2− x3+ x4= 1 −3×1 +13×2 + 7×3 + 5×4 =−3 −x1+ 7×2+14×3− 2×4= 2 x1+ 5×2− 2×3+30×4= 1
3