Question: In Matlab Please function [x,er,n_iter] = newtraph_vector(F,JF,x1,maxtol,maxitr) if nargin if nargin if isrow(x1), x1=x1.'; end % or use x=x(:); k = 0; % Initialize the
In Matlab Please
![In Matlab Please function [x,er,n_iter] = newtraph_vector(F,JF,x1,maxtol,maxitr) if nargin if nargin if](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f32e32a2024_10666f32e320648f.jpg)
function [x,er,n_iter] = newtraph_vector(F,JF,x1,maxtol,maxitr)
if nargin
if nargin
if isrow(x1), x1=x1.'; end % or use x=x(:);
k = 0; % Initialize the iteration number
er = 1; % Initialize the relative approximate error
n = length(x1);
x = [x1, zeros(n,maxitr)]; % pre-allocate the solution matrix
% alternatively, initialize x = x1;
while er >= maxtol && k
k = k+1;
if norm(x(:,k+1)) >= eps
er = % define the relative approx error
else
warning('A close to zero solution is obtained for the current estimated solution; approximate error is evaluated instead')
er = norm((x(:,k+1)-x(:,k)));
end
end
% Examine the condition under which the loop terminates
if er>=maxtol && k==maxitr
warning('Maximum number of iterations is reached before convergence')
elseif er fprintf(' The algorithm converges at the maximum number of iterations ')
end
n_iter = k;
disp(' ')
disp('The solution estimates are =')
disp(x(:,1:k+1)')
end
(Code Provided)
Problem 1: Newton's method for solving a system of nonlinear equations In the prelab, we applied the Newton's method to solve the following system of equations. 4x} xi = -28 (la) 3x} + 4x2 = 145 (1b) The above two equations can be compactly written in the vector form F(x) = 0, where F is the vector function of the system of equations. The Newton's Method can be used to determine the solution to a system of nonlinear equations where the algorithm iteratively updates the estimated solution using the following relationship: VF(xk) Xk+1 = VF(xx) XK F(xx) (2) where, Xk denotes the k-th estimate of the solution vector. Develop the numerical solver newtraph_vector to solve a set of nonlinear algebraic equations, based on the Newton's method to solve for a single algebraic equation. Test your code using x1=[1; 1], maxtol=1e-4, maxitr=20. = function(x, er, n_iter] newtraph_vector(F_system, Jacobian_system, x1, maxtol, maxitr) Note: Complete the function file newtraph_vector based on the programming logic of Newtonroot for solving a scalar equation. Problem 1: Newton's method for solving a system of nonlinear equations In the prelab, we applied the Newton's method to solve the following system of equations. 4x} xi = -28 (la) 3x} + 4x2 = 145 (1b) The above two equations can be compactly written in the vector form F(x) = 0, where F is the vector function of the system of equations. The Newton's Method can be used to determine the solution to a system of nonlinear equations where the algorithm iteratively updates the estimated solution using the following relationship: VF(xk) Xk+1 = VF(xx) XK F(xx) (2) where, Xk denotes the k-th estimate of the solution vector. Develop the numerical solver newtraph_vector to solve a set of nonlinear algebraic equations, based on the Newton's method to solve for a single algebraic equation. Test your code using x1=[1; 1], maxtol=1e-4, maxitr=20. = function(x, er, n_iter] newtraph_vector(F_system, Jacobian_system, x1, maxtol, maxitr) Note: Complete the function file newtraph_vector based on the programming logic of Newtonroot for solving a scalar equation