format long; clear; fprintf('Solve the nonlinear system by Newton method and SOR method.\n'); fprintf('Use the solution of u with N = 400 as exact solution ue.\n'); u1 = Solve_System(100,1.91); u2 = Solve_System(200,1.97); ue = Solve_System(400,1.98); e1 = 0; e2 = 0; for j = 2:100 for i = 2:100 e1 = max(e1,abs(ue(4*i-3,4*j-3)-u1(i,j))); end end for j = 2:200 for i = 2:200 e2 = max(e2,abs(ue(2*i-1,2*j-1)-u2(i,j))); end end p = log2(e2/e1); fprintf('The error with N = 100 is %.8f.\n',e1); fprintf('The error with N = 200 is %.8f.\n',e2); fprintf('The error of the numerical method is O(N^%.0f).\n\n',p); clear;