Posts

Showing posts with the label Numerical Methods

Matrix Inverse: Matrix Inversion Technique

Image
Matrix Inversion Technique  The inverse of a matrix The inverse of a square n × n matrix A is another n × n matrix denoted by A -1  such that AA -1 =A -1 A=I where I is the n × n identity matrix. That is, multiplying a matrix by its inverse produces an identity matrix. Not all square matrices have an inverse matrix. If the determinant of the matrix is zero, then it will not have an inverse, and the matrix is said to be singular. Only non-singular matrices have inverses. A formula for finding the inverse Given any non-singular matrix A, its inverse can be found from the formula A -1  = adj A |A| where adj A is the adjoint matrix and |A| is the determinant of A. The procedure for finding the adjoint matrix is given below. Finding the adjoint matrix The adjoint of a matrix A is found in stages: Find the transpose of A, which is denoted by A T . The transpose is found by interchanging the rows and columns of A. So, for example, the first column of A is the first row of the transpo

Eigen Values and Eigen Vectors

Eigenvalues Eigenvalues are a special set of scalars associated with a linear system of equation (i.e., a matrix equation) that are sometimes also known as characteristic roots, characteristic values, proper values, or latent roots.

Doolittle Algorithm: LU Decomposition Algorithm

Image
DOOLITTLE Algorithm In the numerical method Doolittle Algorithm : LU Decomposition Algorithm (where LU stands for Lower and Upper and also called LU factorization Algorithm) factors a matrix as the product of a lower triangular matrix and an upper triangular matrix. Computers usually solve square systems of linear equations using the LU decomposition, and it is also a key step when inverting a matrix, or computing the determinant of a matrix. Let A be a square matrix. An LU factorization algorithm refers to the factorization of A, with proper row and/or column orderings or permutations, into two factors, a lower triangular matrix L and an upper triangular matrix U,  A=LU . Assume that  A  has a Crout factorization  A  =  LU . 

Improved Euler's Method and Euler's Method with their C Program

Image
Improved Euler’s Method The Improved Euler’s method, also known as the Heun formula or the average slope method, gives a more accurate approximation than the Euler rule and gives an explicit formula for computing  y n+1 . The basic idea is to correct some errors of the original Euler's method. The syntax of the Improved Euler’s method is similar to that of the trapezoid rule, but the  y  value of the function in terms of  y n+1  consists of the sum of the  y  value and the product of  h  and the function in terms of  x n  and  y n .

Runge Kutta Method Formula and C Program

Image
Runge Kutta Method A Runge Kutta Method of numerically integrating ordinary differential equations by using a trial step at the midpoint of an interval to cancel out lower-order error terms. The second-order formula is

C Program for Shooting Method | C Programming

Introduction The  shooting method  is a method for solving a Boundary Value Problem by reducing it to the solution of an Initial Value Problem. Roughly speaking, we 'shoot' out trajectories in different directions until we find a trajectory that has the desired boundary value.

C Program for Laplace Algorithm | C Programming

Image
Laplace Algorithm Laplace’s approximation is one of the most fundamental asymptotic techniques for the estimation of integrals containing a large parameter or variable. For integrals of the form

C Program To Find The Value Using Poison Algorithm | C Programming

C Programming | C Program to find the value using poison algorithm #include<stdio.h> #include<conio.h> #include<math.h> #define g(x,y) 2*(x)*(x)*(y)*(y) int main(){ int n,i,j,k; float sum,error,E[10],a[10][10],b[10],new_x[10],old_x[10],tl,tr,tu,tb,h,buffer; printf("\nPoision's' \n"); printf("Enter the dimension of plate\n"); scanf("%d",&n); printf("\nEnter the dimension of grid\n"); scanf("%f",&h); printf("\nEnter the temperatures at left, right, bottom and top of the plate \n"); scanf("%f%f%f%f",&tl,&tr,&tb,&tu); //construction of coefficient matrix for(i=0;i<=n;i++) a[i][i]=-4; for(i=0;i<=n;i++) a[i][n-i]=0; for(i=0;i<=n;i++) for(j=0;j<=n;j++){ if(i!=j && j!=(n-i)) a[i][j]=1; } //Construction of RHS vector k=0; for(i=1;i<n;i++) for(j=1;j<n;j++) b[k++]=h*h*g(i,j); k=0; for(i=1;i<n;i++){ for(j=1;j&l

C program for Simpson's 1/3 Rule | C Programming

Image
C program for Simpson's 1/3 Rule  Before Starting the program let us know about the Simpson's 1/3 rule and How it works? Simpson’s 1/3 Rule The trapezoidal rule was based on approximating the integrand by a first-order polynomial and then integrating the polynomial over an interval of integration. Simpson’s 1/3 rule is an extension of the Trapezoidal rule where the integrand is approximated by a second-order polynomial.

C Program to calculate value using composite trapezoidal rule | C Programming

C programming to calculate value using composite trapezoidal rule #include<stdio.h> #include<conio.h> #include<math.h> #define F(x) 2*x int main() { int n,i; float a,b,h,x,sum=0,integral; printf("Enter the two limits:\n"); scanf("%f%f",&a,&b); printf("Enter the difference n:\n"); scanf("%d",&n); h=(b-a)/n; for(i=1;i<n;i++) { x=a+i*h; sum=sum+F(x); } integral=(h/2)*(F(a)+F(b)+2*sum); printf("\nThe integral is: %f\n",integral); return 0; }

C Programming Codes To Compute Value Using Trapezoidal Rule

C Programming Codes To Compute Value Using Trapezoidal Rule #include<stdio.h> #include<conio.h> #include<math.h> #define F(x) exp(-(x/2)) int main() { int a,b,h; float i,x,y; printf("Enter the value for lower and upper limit\n"); scanf("%d%d",&a,&b); h=b-a;//Calculating height x=F(a);//Calculation Function and storing in x and y. y=F(b); i=h*((x+y)/2); printf("The Intregrated Value is %.3f",i); }

C Program To Calculate Values Using Fixed Point Iteration and Honors Method | C Programming

C Program To Calculate Values Using Fixed Point Iteration Method Algorithm Start Read values of x0 and e. *Here x0 is the initial approximation e is the absolute error or the desired degree of accuracy, also the stopping criteria* Calculate x1 = g(x0) If [x1 – x0] <= e, goto step 6. *Here [ ] refers to the modulus sign* Else, assign x0 = x1 and goto step 3. Display x1 as the root. Stop #include<stdio.h> #include<math.h> #include<conio.h> #define EST 0.05 #define F(x) exp(-x)-x #define G(x) exp(-x) int main() { int i=1; float error,x0,x1,temp; printf("Enter the initial guess x0:\n"); scanf("%f",&x0); printf("Iteration x0\t\t x1\t Error\n"); x1=G(x0); error=fabs((x1-x0)/x1); printf("%d\t %.4f\t%.4f\t %.4f\n",i,x0,x1,error); do { i++; temp=x1; x0=temp; x1=G(x0); error=fabs((x1-x0)/x1); printf("%d\t %.4f\t%.4f\t %.4f\n",i,x0,x1,error); }while (error>EST); } C Program To Calculate Values Using Ho

C program to find value using Bisection Method | C Programming

C program to find value using Bisection Method | C Programming #include<stdio.h> #include<conio.h> #include<math.h> #define EST 0.05 #define F(x) pow(x,3)-x-3 int main() { int i=1; float xl,xu,xm,f1,f2,f3,error; printf("Enter the values for xl and xu respectively\n"); scanf("%f%f",&xl,&xu); printf("Iteration\tXl\t Xu\t f(Xm)\t Error\n"); do { xm=(xl+xu)/2; f1=F(xl); f2=F(xu); f3=F(xm); error=fabs((xl-xu)/xu); if((f1*f3)<0) { xu=xm; } else { xl=xm; } f3=F(xm); error=fabs((xl-xu)/xu); printf("%d\t %.4f\t %.4f\t%.4f\t %.4f\n",i,xl,xu,xm,error); i++; }while (error>=EST); }

C program to find value using secant method | C programming

C program to find value using secant method | C programming #include<stdio.h> #include <math.h> #include<conio.h> #define EST 0.05 #define F(x) x-exp(x)+2 int main() { int i = 1; float x0,x1,a,b,c,d,f1,x2,f0,error; printf("\nEnter the value of x0: "); scanf("%f",&x0); printf("\nEnter the value of x1: "); scanf("%f",&x1); printf("\n__________________________________________________________________\n"); printf("\niteration\tx0\t x1\t f0\t f1\t x2\t\terror"); printf("\n___________________________________________________________________\n"); f0=F(x0); f1=F(x1); x2=x1-((f1*(x1-x0))/(f1-f0)); printf("%f",x2); error=fabs((x2-x1)/x2); printf("\n %d \t %.2f\t %.2f\t %.2f \t %.3f \t %.3f \t %.3f", i, x0,x1,f0,f1,x2,error); do{ i++; x0=x1; f0= f1; x1=x2; f0=F(x0); f1=F(x1); x2=x1-((f1*(x1-x0))/(f1-f0)); error=fabs((x2-x1)/x2); printf("\n %d \t %.2f\t %.2f\t %.2f \t %.4f \

C program to find the value using Newton Raphson | C Programming

C program to find the value using Newton Raphson Before starting with the program let us learn something about Newton Raphson Method Newton Raphson Method  is open method and starts with one initial guess for finding real root of non-linear equations. In other Words,  Newton Raphson method, also called the Newton’s method, is the fastest and simplest approach of all methods to find the real root of a nonlinear function. It is an open bracket approach, requiring only one initial guess. This method is quite often used to improve the results obtained from other iterative approaches