ANSWER:
CODE TEXT
1. lu_fact.m
% function for lu factorization
function [L,U]=lu_fact(A)
% fetching n
n=rank(A);
% defining L and U
L=zeros(n); % lower matrix
U=zeros(n); % upper matrix
% factorizing matrix into L and U
for i=1:n
% working on U
for j=i:n
% defining sum of multiplication of elements
sum=0;
for k=1:i
sum=sum+(L(i,k)*U(k,j));
end
% subtracting sum from A
U(i,j)=A(i,j) -sum;
end
% working on L
for j=i:n
if i==j
L(i,i)=1; % for diagonal
else
sum=0;
for k =1:i
sum = sum + (L(j,k) * U(k,i));
end
% subtracting sum from A
L(j,i)=(A(j,i)-sum)/U(i,i);
end
end
end
end
2. cholesky_fact.m
% function cholesky
function [L] = cholesky_fact(A)
% fetching n
n = rank(A);
% initializing L
L = zeros(n+1);
% factorizing a matrix
for i = 1:n
for j=1:i+1
sum = 0;
% suming for diagonals
if (j==i)
for k=1:j
sum = sum + L(j,k)^2;
end
L(j,j)=sqrt(A(j,j)-sum);
else % for remaining elements
for k=1:j
sum = sum + L(i,k) *L(j,k);
end
if L(j,j)>0
L(i,j) = (A(i,j) - sum)/L(j,j);
end
end
end
end
% removing 0 rows and cols
L=L(1:n,1:n);
end
3. main.m
% Initializing A, given in question
A=[6.25 -1 0.5;-1 5 2.12;0.5 2.12 3.6];
% finding LU Factorization using hand written function lu_fact
disp('LU Factorization');
[L,U]=lu_fact(A)
disp('Multiplying L*U gives');
disp(L*U);
% finding Cholesky factorization using hand written function
disp('Cholesky Factorization');
L=cholesky_fact(A);
disp("Multiplying L*L' gives");
disp(L*L');
CODE IMAGES
a. lu_fact.m
b. cholesky_fact.m
c. main.m
OUTPUT IMAGE
The Cholesky factorization one 3. Consider the linear system Ax = b, where 6.25 -1 0.5...
just 1,2,4
Problem 1 Consider the linear system of equations Ax = b, where x € R4X1, and A= 120 b = and h= 0.1. [2+d -1 0 0 1 1 -1 2+d -1 0 h2 0 -1 2 + 1 Lo 0 -1 2+d] 1. Is the above matrix diagonally dominant? Why 2. Use hand calculations to solve the linear system Ax = b with d=1 with the following methods: (a) Gaussian elimination. (b) LU decomposition. Use MATLAB (L,...
Linear equation question
Use Matlab for b) and c) and show all the
work
Oct 3,ao16 MTH 301: Matrix Theory and Applications Project 1 on Linear System of Equations, and LU factorization This project studies a problem on heat transfer, where a steady-state temperature distribution of a thin plate is sought when the temperature around the boundary is known. Assume the plate shown in the figure represents a cross-section of a metal beam with very negligible heat flow in the...
Linear Algebra Question:
18. Consider the system of equations Ax = b where | A= 1 -1 0 3 1 -2 -1 4 2 0 4 -1 –4 4 2 0 0 3 -2 2 2 and b = BENA 1 For each j, let a; denote the jth column of A. e) Let T : Ra → Rb be the linear transformation defined by T(x) = Ax. What are a and b? Find bases for the kernel and image...
Please do question 5 for me. Thanks
Question 1 (10 marks) For a linear system Ax- b with 1 0 -1 A-1 2-1 2 -1 3 b=14 18 and compute by hand the first four iterations with the Jacobi method, using x()0 Hint: for the ease of calculation, keep to rational fractions rather than decimals Question 2 For the same linear system as in Question 1, compute by hand the first three iterations (10 marks) with the Gauss Seidel method,...