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

Please give me a code with matlab and with a explain.Thank you sooo much and I w

ID: 3861583 • Letter: P

Question

Please give me a code with matlab and with a explain.Thank you sooo much and I will give you a good thumb if the answer is correct or nearly correct.

Please give me a code with matlab Thank you sooo much and l will give you a good thumb. Problem 4. (20%) C the example of solving a system of nonlinear equations onsider by Newton's method, as given on Pages 95-97 of the Lecture notes. Write a program to carry out this iteration, using Gauss elimination to solve the 2 by 2 linear systems that arise. Use each of the following 16 initial data sets for the Newton iteration: (0) (0) (i, jo, i 0,1, 2, 3, j 0,1,2,3 Present and discuss your numerical results in a concise manner The lecture not is here: EXAMPLE Use Newton's method to solve the system T2 Here T1 g2(x) T2 The Jacobian matrix in this example is given by

Explanation / Answer

Matlab code

for ii = 0:3
    for jj = 0:3
        x = [ii;jj]; % initial guess of (x1,x2)
        Dx = [1;1]; % Give some high value for Delta x
        while max(Dx > 0.001) % Iterate unitil Dx become small
            A = [2*x(1)*x(2) x(1).^2; -4*x(1).^3 1]; % A matrix
            b = [1-(x(1).^2)*x(2);(x(1).^4)-x(2)]; % b vector
            % Performing gauss elimination
            n=2; % number of unknowns
            % Forward sweep
            for i=2:1:n
               for j=i:1:n
                    r=A(j,i-1)/A(i-1,i-1);
                    A(j,:)=A(j,:)-r*A(i-1,:);
                    b(j)=b(j)-r*b(i-1);
               end
            end
            % Backsubstitution
            for i=n:-1:1
               j=i+1;
               sum=0;
               while(j<=n)
                   sum=sum+A(i,j)*x(j);
                   j=j+1;
               end
               Dx(i)=1/A(i,i)*(b(i)-sum);
            end
            x = x+Dx; % updating the values of x
        end
        fprintf('For the initial guess (%d,%d) Newton iteration Converges to (%f,%f) ',ii,jj,x);
    end
end


OUTPUT

For the initial guess (0,0) Newton iteration Converges to (NaN,NaN)
For the initial guess (0,1) Newton iteration Converges to (NaN,NaN)
For the initial guess (0,2) Newton iteration Converges to (NaN,NaN)
For the initial guess (0,3) Newton iteration Converges to (NaN,NaN)
For the initial guess (1,0) Newton iteration Converges to (NaN,NaN)
For the initial guess (1,1) Newton iteration Converges to (0.500000,1.000000)
For the initial guess (1,2) Newton iteration Converges to (0.250000,1.000000)
For the initial guess (1,3) Newton iteration Converges to (0.166667,1.000000)
For the initial guess (2,0) Newton iteration Converges to (NaN,NaN)
For the initial guess (2,1) Newton iteration Converges to (0.250000,0.727273)
For the initial guess (2,2) Newton iteration Converges to (0.125000,1.176471)
For the initial guess (2,3) Newton iteration Converges to (0.083333,1.600000)
For the initial guess (3,0) Newton iteration Converges to (NaN,NaN)
For the initial guess (3,1) Newton iteration Converges to (0.166667,0.607362)
For the initial guess (3,2) Newton iteration Converges to (0.083333,1.097561)
For the initial guess (3,3) Newton iteration Converges to (0.055556,1.581818)

Remark : For some initial guess the matrix become singular that leads to devision by zero. and the result is NAN