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

(A) From linear Algebra we know, that when multiplying the matrices A and B toge

ID: 2995351 • Letter: #

Question

(A) From linear Algebra we know, that when multiplying the matrices A and B together we can find the elements of the resulting matrix C using the following formula

(C_{i,j} = sum_{k}^{n} A_{i, k}B_{k,j})

Write a function that computes the product of two square matrices by implementing the

previous formula. Your function should accept the input matrices A and B as inputs, and

return the product matrix AB as its output. You can use MATLAB to

code the solution to this problem. You will get no credit if you simply use A*B or other built-in

functions that do this for you.

In MATLAB, your function declaration should look something like this:

Function AB = matrimul (A, B)

(B) Write a function that implements a Gauss siedel iterative method to solve for the solution

to the system of equations Ax = b. Your function should accept the input matrix A, righthand-

if you use a built-in linear algebra function to compute the solution to the system.

in MATLAB your function declaration should look something like

   (function x_{i} = gausssiedel( A , b, x_{0}, epsilon _{a,max}))   

not sure if above equation is correct as I dont know how to use gauss siedel in matlab, but can do it by hand. So please use your knowledge to figure that out what the function would infact be.

(C)Use the code you wrote in part (A) and Part (B) to solve the following question:

use least squares regression to fit a staright line to

(see image for data)

(a)Along with the slope and intercept, compute the standard error of the estimate and the correlation coefficient. Plot the data and the straight line. Assess the fit.

(b) Recompute (a), but use polynomial regression to fit a parabola to the data. Compare the results with those of (a).

Please solve the whole question and make the code so it can be pasted right into matlab to work and make a file. Thank you in advance.

Explanation / Answer

function AB = matrimul (A, B)


[nRow1,nCol1]=size(A);

[nRow2,nCol2]=size(B);


if nCol1 ~= nRow2

error('inner dimensions must match');

end


AB = zeros(nRow1,nCol2);


for i = 1:nRow1

for j = 1:nCol2

for k = 1:nCol1

AB(i,j) = AB(i,j) + A(i,k)*B(k,j);

end

end

end


% sample input

% A = [8 1 6

% 3 5 7

% 4 9 2];

%

% B= [1 2 6

% 4 2 7

% 2 1 8];

% matrimul(A,B)

%

% ans =

%

% 24 24 103

% 37 23 109

% 44 28 103