Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(A + omega GG^T) x + G lambda = P (Eq. 1) G^T x = 0 (Eq. 2) In Eqs. (1) and (2),

ID: 3111729 • Letter: #

Question

(A + omega GG^T) x + G lambda = P (Eq. 1) G^T x = 0 (Eq. 2) In Eqs. (1) and (2), A is an nxn coefficient matrix, x is an n times 1 vector of unknowns, G is an n times m matrix, P is a known n times 1 vector, GT is the transpose of G, lambda is an unknown m times 1 vector, 0 is an m times 1 vector of zeros, and omega is a scalar value greater than zero. For such a problem, m tolerance) y = G^Tx lambda = lambda + omega y solve (A + omega GG^T)x = P - G lambda for x end a) Write a MATLAB function that implements the above iteration, taking advantage of MATLAB's abilities for solving systems of equations. Your function must take A, G, P, and omega as input, and return x, lambda, and the number of iterations to convergence as output. Note that you are solving a linear system repeatedly, but the coefficient matrix. A + omega GG^T, does not change: your code must take advantage of this. Your error term should be error = norm(G^T x), which in theory goes to zero. Use tolerance = 10^-0.8

Explanation / Answer

function [x,lambda,iterations]=tol(A,G,P,w)
if(size(A)==size(A'))
    n=size(A,1);
else
    disp('Please Enter matrix A square matrix i.e n by n!');
end
if(size(A,2)==size(G,1))
    m=size(G,2);
else
    disp('Please Enter matrix G of size i.e n by m!');
end
x=zeros(n,1);
lambda=zeros(m,1);
tolerance=10^(-8)
error=true;
iterations=0;
while(error>tolerance)
    y=G'*x  
    error=norm(y)
    iterations=iterations+1
    lambda=lambda+w*y
    part1=A+(w*G*G')
    part2=P-(G*lambda)
    x=linsolve(part1,part2)
  
  
end
end