%%%%%FUNCTION FOR PART A
function d = numdigs(n)
d = strlength(string(n));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%SCRIPT FOR PART 2
n=input('Enter a positive integer: ');
d = numdigs(n);
if rem(d,2)==0
x0=7*10^((d-2)/2);
else
x0=7*10^((d-1)/2);
end
xi=1/x0;
xi1=x0;
while xi~=xi1
xi=xi1;
xi1=floor((xi+ceil(n/xi))/2);
end
fprintf('RSR value: %d\n',xi1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%SCRIPT FOR PART 3
RSR=zeros(1,length(1000:9999));
for n=1000:9999
d = numdigs(n);
if rem(d,2)==0
x0=7*10^((d-2)/2);
else
x0=7*10^((d-1)/2);
end
xi=1/x0;
xi1=x0;
while xi~=xi1
xi=xi1;
xi1=floor((xi+ceil(n/xi))/2);
end
RSR(n-999)=xi1;
end
MATLAB Question: TASK 5 12 MARKS -L06N] The rounded-square-root (RSR) of a positive integer n is...
1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear system A b (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in Matlab functions for solving linear systems (a) Write a Matlab function called Jacobi that consumes a square n x n matrix A, and an n x 1 vector b, and uses the Jacobi technique to solve the system Ax-b, starting with the zero...