04_linear_algebra
Homework 4
#Problem 2
Part A Outputs
- norm2_H4 = 1.5002
- normf_H4 = 1.5097
- norm1_H4 = 2.0833
- normi_H4 = 2.0833
- norm2_H5 = 1.5671
- normf_H5 = 1.5809
- norm1_H5 = 2.2833
- normi_H5 = 2.2833
Part B Outputs
- norm2_H4i = 1.0341e+04
- normf_H4i = 1.0342e+04
- norm1_H4i = 13620
- normi_H4i = 13620
- norm2_H5i = 3.0414e+05
- normf_H5i = 3.0416e+05
- norm1_H5i = 413280
- normi_H5i = 413280
Part C Outputs
- H4_cond2 = 1.5514e+04
- H4_condf = 1.5614e+04
- H4_cond1 = 2.8375e+04
- H4_condi = 2.8375e+04
- H5_cond2 = 4.7661e+05
- H5_condf = 4.8085e+05
- H5_cond1 = 9.4366e+05
- H5_condi = 9.4366e+05
Problem 3 Function chol_tridiag
- function [d,u] = chol_tridiag(e,f)
- %Function takes two vectors as inputs and
- %calculates the Cholseky factorization of
- %the tridiagonal matrix, where e is off-
- %diagonal vector and f is diagonal vector
-
n = length(f);
-
d = zeros(1,n);
-
u = zeros(1,n-1);
-
d(1) = sqrt(f(1));
-
u(1) = e(1)/d(1);
-
for i = 2:n-1
-
d(i) = sqrt(f(i)-u(i-1)^2);
-
u(i) = e(i)/d(i);
-
end
- d(n) = sqrt(f(n)-u(n-1)^2);
- end
- %Outputs two vectors, diagonal of upper
- %matrix (d) and off-diagonal of upper
- %matrix (u)
Problem 4 Function solve_tridiag
- function x = solve_tridiag(d,u,b)
- %This function solves Ax = b with the
- %diagonal and off-diagonal of the Cholesky
- %and Diagonal matrices d and u, respectively
-
n = length(d);
-
x = zeros(1,n);
-
y = zeros(1,n);
-
for i = 1:n
-
if i == 1
-
y(1) = b(1)/d(1);
-
else
-
y(i) = (b(i)-u(i-1)* y(i-1))/d(i);
-
end
-
end
-
for i = fliplr(1:n)
-
if i == n
-
x(i) = y(i)/d(i);
-
else
-
x(i) = (y(i)-u(i)* x(i+1))/d(i);
-
end
-
end
- end
Problem 5 Outputs
- For all k's = 1000, x = 29.2841 and Error = 29.2841
- For k2 = 1000e12, x = Error = 1.1291e+13
- For k2 = 1000e-12, x = Error = 9.0010e+12
Problem 6 Outputs
- x = [0.0392,0.0687,0.0833,0.0981]
Problem 7 Outputs
- ans = [40.522,14.409,2.569]
Problem 8 Table of Outputs
# of Segments | Largest Load (N) | Smallest Load (N) | # of Eigen Values |
---|---|---|---|
5 | 1.1756 | 0.6180 | 2 |
6 | 1.2000 | 0.6212 | 3 |
10 | 1.2361 | 0.6257 | 7 |
- As the segment length approaches zero, there would be no eigen values