Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab (Linear algebra) function C = cofactor(A, i, j) % cofactor Matrix of cofactors. % % C = cofactor(A) returns the matrix of cofactors of

Matlab (Linear algebra)

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

function C = cofactor(A, i, j) % cofactor Matrix of cofactors. % % C = cofactor(A) returns the matrix of cofactors of A. % If A is invertible, then inv(A) = C' / det(A). % % C = cofactor(A, i, j) returns the cofactor of % row i, column j of A. if nargin == 3 % Remove row i and column j to produce the minor. M = A; M(i,:) = []; M(:,j) = []; C = (-1)^(i+j) * det(M); else [n,n] = size(A); for i = 1:n for j = 1:n C(i,j) = cofactor(A, i, j); end end end 

function [P, L, U, sign] = splu(A) % splu Square PA=LU factorization *with row exchanges*. % % [P, L, U] = splu(A), for a square, invertible matrix A, % uses Gaussian elimination to compute a permutation % matrix P, a lower triangular matrix L and % an upper triangular matrix U so that P*A = L*U. % P, L and U are the same size as A. % sign = det(P); it is 1 or -1. % % See also slu, lu, rref, partic, nulbasis, colbasis. [m, n] = size(A); if m ~= n error('Matrix must be square.') end P = eye(n, n); L = eye(n, n); U = zeros(n, n); tol = sqrt(eps); sign = 1; for k = 1:n if abs(A(k, k)) = tol break end if r == n if nargout == 4 sign = 0; return else disp('A is singular within tolerance.') error(['No pivot in column ' int2str(k) '.']) end end end A([r k], 1:n) = A([k r], 1:n); if k > 1, L([r k], 1:k-1) = L([k r], 1:k-1); end P([r k], 1:n) = P([k r], 1:n); sign = -sign; end for i = k+1:n L(i, k) = A(i, k) / A(k, k); for j = k+1:n A(i, j) = A(i, j) - L(i, k)*A(k, j); end end for j = k:n U(k, j) = A(k, j) * (abs(A(k, j)) >= tol); end end if nargout   LAB 3: LU Decomposition and Determinants In this lab you wil use MATLAB to study the following topics: The LU decomposition of an invertible square matrix A. . How to use the LU decomposition to solve the system of linear equations Ax b. Comparison of the computation time to solve Ax - b by Gaussian elimination vs. solution by LU decomposition of A. . The determinant of a square matrix, how it changes under row operations and matrix multiplication, and how it can be calculated efficiently by the LU decomposition . The geometric properties of special types of matrices (rotations, dilations, shears)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions