# Numerical

## Numerical Methods Multiplication of two matrices using two dimensional array in CC

Numerical Methods: Multiplication of two matrices using two dimensional array in C/C++ Source Code   #include int main() { int r1, c1, r2, c2, matrix1[10][10], matrix2[10][10], result[10][10]; int i, j, k; printf(“Enter the row and column of the first matrix: “); scanf(“%d%d”,&r1,&c1); printf(“Enter the row and column of the second …

## Numerical Method Newtons Forward and Backward Interpolation in CC

Numerical Method: Newton’s Forward and Backward Interpolation in C/C++ #include #include int main() { float x[10],y[15][15]; int n,i,j; printf(“Enter n : “); scanf(“%d”,&n); printf(“X\tY\n”); for(i = 0;i

## Numerical Methods Condition number and ill condition checking using C

Numerical Methods: Condition number and ill condition checking using C Source Code: #include #include void inverse(float matrix[6][6], int n){ int i,j, k; float ratio,a; for(i = 0; i < n; i++){ for(j = n; j < 2*n; j++){ if(i==(j-n)) matrix[i][j] = 1.0; else matrix[i][j] = 0.0; } } for(i = …

## Numerical Methods: Greatest Eigen value and corresponding Eigen vector using power method in C

Source Code: void matrix_mul(float matrix1[3][3],float matrix2[3][1],float matrix3[3][1]){ int i,j,k; for(i = 0; i < 3; i++){ for(j = 0; j < 1; j++){ matrix3[i][j] = 0; for(k = 0; k < 3; k++){ matrix3[i][j] += matrix1[i][k]*matrix2[k][j]; } } } } float findmax(float array[3][1]){ int i; float maximum; maximum = …

## 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 MethodsFitting the curve of the form y a bx using least square method in C

Numerical Methods:Fitting the curve of the form y = a + bx using least square method in C ///Curve fitting of a straight line of the form y = a + bx #include #include int main(){ int ax[20], ay[20], i, n; int sum_x = 0, sum_xy = 0, sum_x2 = …

## 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 …