Question: Hi there , can you please help me completing this C program code ? #include #include #include // Size of the system #define N 2
Hi there , can you please help me completing this C program code ?









#include #include #include // Size of the system #define N 2 // global declarations to simplify functions prototypes double A[N][N], x[N], nx[N], b[N]; double max_move; // threshold error int max_iter; // max number of iterations double max_error; // max error of last iteration int ite; // iteration index // reads A, b, max_move, max_iter void read_input(); // print a heading line before printing x void print_heading(); // print the values of x (passing the current iteration number) void print_x(int); // update the maximum error void update_error(); // solves for x[i] from equation (i) and returns the // result without updating x double solve(int i); int main(void) { int i, j; printf("**Solving a %d-by-%d system** ", N, N); read_input(); /* initial guess */ for (i=0; imax_move); printf("max error=%.25f ", max_error); return 0; } // reads A, b, max_move, max_iter void read_input() { // Read A and b int r, c; for (r=0; r uestion 1 - Solving a svstem of linear equations Summary Write a program to solve an N-by-N system of linear equations, where N is a constant given by a "define" directive. Details The importance of solving an N-by-N system of linear equations arises in many areas of engineering and sciences. The system is usually represented in matrix form as Ax b, where A is an N-by-N matrix and x and b are N-dimensional vectors Solving the system means finding the value of x that satisfies the system. There are many methods that can be used to solve such a system, analytical and numerical In this exercise, we explain an easy method to solve such system; however, the method we present here assumes that the matrix A is diagonally dominant, i.e., the magnitude of the values of the diagonal elements in A are greater than or equal to the sum of the magnitudes of all the other elements belonging to the same row. Mathematically speaking, IAii2 -Aij IJ i. Here is an example of a diagonally dominant matrix Since 21 and 32, this matrix is diagonally dominant. Here is an example of a matrix that is not diagonally dominant Although 21 in the first row; however, since there is one row in which the diagonal element is less than the sum of the other elements (21+2 (first row), 104+5 (second row), and 2015+3 (third row) Given that the matrix A is diagonally dominant, the iterative method we explain here can be used to solve this system. However, if A is not diagonally dominant, the method may fail to converge to a solution. In case you would like to learn more about diagonally dominant matrices, please continue reading here: https://en.wikipedia.org/wiki/Diagonally_dominant matrix. An Iterative Method for Solving Ax - b Let us describe the iterative method for solving a system of linear equations by means of a 2-by-2 system example. 5 and b = (Please verify that A is diagonally Let us suppose that A = dominant). This results in the following system of equations: 2 -6 5 x[0] + x[1] = 5 2x(01-6 x[1] =-2 Please note that I'm using a semi-C language subscripts for the x vector The method starts by initializing the vector x to all zeros and loops as follows First iteration 1. Solve for the new value of x[0] from Eq. (0) using the previously estimated values of the other x's (from initialization step) x-new[0] (5-x[1])/5-1<><>