Currently browsing tag

Numerical Methods

Numerical Methods Integration of given function using Simpsons 13 rule in C

Numerical Methods: Integration of given function using Simpson’s 1/3 rule in C Source Code: ///integration of given function using Simpson’s 1/3 rule #include float y(float x){ return 1/(1+x*x); } int main(){ float x0,xn,h,s; int i,n; printf(“Enter x0, xn, no. of subintervals: “); scanf(“%f%f%d”,&x0,&xn,&n); h = (xn – x0)/n; s = …

Numerical Methods Integration of given function using Simpsons 38 rule in C

Numerical Methods: Integration of given function using Simpson’s 3/8 rule in C Source Code: //integration of given function using Simpson’s 3/8 rule #include float y(float x){ return 1/(1+x*x); //function of which integration is to be calculated } int main(){ float x0,xn,h,s; int i,n,j,flag; printf(“Enter x0, xn, no. of subintervals: “); …

Numerical Methods Integration of given function using Trapezoidal rule in C

Numerical Methods: Integration of given function using Trapezoidal rule in C Source Code: ///integration of given function using Trapezoidal rule #include float y(float x){ return 1/(1+x*x); } int main(){ float x0,xn,h,s; int i,n; printf(“Enter x0, xn, no. of subintervals: “); scanf(“%f%f%d”,&x0,&xn,&n); h = (xn-x0)/n; s = y(x0) + y(xn); for(i …

Numerical Methods Parabolic curve fitting using C

Numerical Methods: Parabolic curve fitting using C Source Code: #include #include int main(){ float xy[20][20], matrix[3][4], ratio, a; float sum_x = 0, sum_y = 0, sum_x2 = 0, sum_x3 = 0, sum_x4 = 0, sum_xy = 0, sum_x2y = 0; int i, j , k, n; printf(“Enter no of data: …

Numerical Methods Inverse of nxn matrix using C

Numerical Methods: Inverse of nxn matrix using C Source Code: #include int main(){ float matrix[10][10], ratio,a; int i, j, k, n; printf(“Enter order of matrix: “); scanf(“%d”, &n); printf(“Enter the matrix: \n”); for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ scanf("%f", &matrix[i][j]); } } …

Numerical Methods Determinant of nxn matrix using C

Numerical Methods: Determinant of nxn matrix using C Source Code: #include int main(){ float matrix[10][10], ratio, det; int i, j, k, n; printf(“Enter order of matrix: “); scanf(“%d”, &n); printf(“Enter the matrix: \n”); for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ scanf("%f", &matrix[i][j]); } …

Numerical Methods Solution of simultaneous algebraic equations using Gauss Jordan method in C

Numerical Methods: Solution of simultaneous algebraic equations using Gauss Jordan method in C Source Code: /***************************************************** Program: solution of linear algebraic equations using Gauss Jordan Method Language used: C Program written by Bibek Subedi July 2, 2011 Tribhuvan University *****************************************************/ #include int main() { double matrix[10][10],a,b; int i, j, k, …

Numerical Methods Solution of simultaneous algebraic equations using Gauss Elimination method in C

Numerical Methods: Solution of simultaneous algebraic equations using Gauss Elimination method in C Source Code: /***************************************************** Program: Solution of Linear algebraic equations using Gauss Elimination method Language used: C Program written by Bibek Subedi *****************************************************/ #include int main() { double matrix[10][10],a,b, temp[10]; int i, j, k, n; printf(“Enter the no …

Numerical Methods Interpolation with unequal interval with Lagranges method in C

Numerical Methods: Interpolation with unequal interval with Lagrange’s method in C Source Code: ///Interpolation with unequal intervals with Lagrange’s Formula #include #include #include COORD coord = {0, 0}; void gotoxy (int x, int y) { coord.X = x; coord.Y = y; // X and Y coordinates SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } int …